[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: conditional namespaces
Hi Ronald, > OUTPUT: > <?xml version="1.0" encoding="UTF-8"?> > <document xmlns:ns0="http://www.google.com" ns0:type="gg"> > <title>title</title> > <a>aaa</a> > </document> > > Why are these 0 characters there? We had exspected something like: > > <?xml version="1.0" encoding="UTF-8"?> > <document xmlns:ns="http://www.google.com" ns:type="gg"> > <title>title</title> > <a>aaa</a> > </document> > > The result we get with msxml 4 is more or less the same only it's > doesn;t generate a zero but a string "auto" or something. What's > going on here? As far as XSLT, and any namespace-aware application, is concerned, these documents are logically exactly the same. The prefix that you use for a namespace - ns or ns0 or auto - doesn't matter when it comes to interpreting the logical structures in the document. Whichever prefix is used, the attribute you've added is still a type attribute in the 'http://www.google.com/' namespace. I suspect that Saxon and Xalan uses ns0 so that they can make up prefixes for multiple namespaces, for example: <document xmlns:ns0="http://www.google.com" ns0:type="gg" xmlns:ns1="http://www.lycos.com" ns1:type="ly" xmlns:ns2="http://www.yahoo.com" ns2:type="yh" ...> ... </document> If you want to tell the XSLT processor to use the prefix 'ns' for the namespace, then include that prefix in the name attribute of the xsl:attribute: <xsl:attribute name="ns:{$attribute}" namespace="{$namespace}"> <xsl:value-of select="$value" /> </xsl:attribute> It's not guaranteed to use that prefix, but I think most of the processors honor it. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|