This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Name space from xslt into transformed xml

 
John Robert
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a couple of questions

1.My xslt uses namespace because the input xml(the xml being transformed) uses a name space. In my transformed xml I see the name spaces I used in the xslt, even thought I do not have any elements from the name space in my transformed xml. Is there a way to ask the xslt to not include these name spaces?

2. Is it considered a xsd validation error, if the xml has additional name spaces , than what the xsd contains?

Thank you.
 
Paul Clapham
Sheriff
Pie
Posts: 20946
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Robert wrote:1.My xslt uses namespace because the input xml(the xml being transformed) uses a name space. In my transformed xml I see the name spaces I used in the xslt, even thought I do not have any elements from the name space in my transformed xml. Is there a way to ask the xslt to not include these name spaces?


Well, unused namespace declarations don't do anything except take up a little bit of space, so they aren't really a big problem. However I believe there's an attribute of the <xsl:output> element which allows you to exclude them -- I don't remember what it is right now but I do remember having used it myself. (Even though the unused namespace declarations didn't make any difference, I too still wanted to get rid of them.)

2. Is it considered a xsd validation error, if the xml has additional name spaces , than what the xsd contains?


I don't know much about Schema but I would find it very unlikely for validation to care about something which makes no difference to the meaning of the document. I suppose you could try it yourself to see what happens.
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1.
My xslt uses namespace because the input xml(the xml being transformed) uses a name space. In my transformed xml I see the name spaces I used in the xslt, even thought I do not have any elements from the name space in my transformed xml. Is there a way to ask the xslt to not include these name spaces?

A1. If your xslt uses namespaces not that appeared in the input xml, such as some xslt-extension-functionality etc..., and that those namespaces would not matter in any material sense in the output xml, you can search and use xsl:exclude-result-prefixes, with value of a space separated list of prefixes involved to achieve the purpose. If your xslt uses namespaces because it needs so for matching the input xml, then it is very much trickier. Basically, you need to completely "rewrite" the output to achieve the purpose. "rewrite" in this sense: you refrain from using xsl:copy-of and xsl:copy. For xsl:copy-of it might be easier to understand because it will output what appears in the input xml hence, you cannot stop those namespaces appearing in the output. For xsl:copy, it is harder to understand. In some case, you make xsl:copy of nodes which are namespace-blind, such as text nodes, but the effect is that it is not a complete "rewrite" of the output and you cannot stop input's namespace appearing in the output document. All it sounds very confusing... it is. Maybe after one has had dealt with many xml, one may come to term with that subtlety.

Q2.
Is it considered a xsd validation error, if the xml has additional name spaces , than what the xsd contains?

A2. No, it is not and it should not matter.
 
John Robert
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the responses. Those did help me understand what I am looking for better. I just realized I never responded back. Thanks and sorry about that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic