[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: conditional namespaces

Subject: Re: conditional namespaces
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 14 Dec 2001 17:10:11 +0000
xsl conditional xmlns
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.