File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes xsl namespace and root of xml document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xsl namespace and root of xml document" Watch "xsl namespace and root of xml document" New topic

xsl namespace and root of xml document

Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
I am new to xslt and got stuck on 2 things.

1. Every xsl file needs the following element.

According to the document the namespace can be any unique string, but if I change the string or just the case of any of the alphabet ,I get the following error-

Note : I am using xalan for processing.

2.I have a following xml

and xsl, to copy the above xml.

It works fine but if I change the xls to

The change is within [b]
I get an empty file.My question is why?Isn't "info" descendent of root element "data"?Doesn't "/" represent root element,in this case "data"?

g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 633
The document the namespace can be any unique string, ...

So be it as long as you are contented with authoring xml documents conformed to the well-formedness (even that the uniqueness is never a question).

Once, your xml document is intended to serve up to an intended group of clients ( e.g. a software application or else) then the intended group of clients should have the ability to interprete the document in the sense that the document being not only a stream of characters but capable of making a semantically coherent "message" (not only the set of information consisting of raw data contained in the document) and act upon it. In order to interprete it, the intended audience (the group of clients) is endowed (internally) with or can obtain on demand a book of grammar - the schema of the namespace so specified by the "unique" string of appropriate format - to get it done: by validating it.

For instance, Ant processor would validate the build document with "null" namespace (but all the same with a specific and rigid schema unique to its comprehension, not any other null namespace). WSDL, its own; browser/xhtml, its own; browser/html4 its own DTD... (I simplify certain quite a lot.)

XSLT processor, the same. Before xalan process the xslt document, it starts validating it against its namespace and if the xslt document fails the validation, nothing would perform against the xml source.

That's about it, the story, in layman terms.

A2. Instead of
<xsl:apply-templates select="info"/>

You have to write this instead

in order the processor to be successful in finding a match.
I agree. Here's the link:
subject: xsl namespace and root of xml document
It's not a secret anymore!