Subject: Re: [xsl] conditional namespaces From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 14 Dec 2001 17:10:11 +0000 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] conditional namespaces, ronald heller | Thread | Re: [xsl] conditional namespaces, Trevor Nash |
Re: [xsl] No data appearing, Jeni Tennison | Date | RE: [xsl] translets vs. templates, Michael Kay |
Month |