Re: [xsl] Default namespace problem

Subject: Re: [xsl] Default namespace problem
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 1 Sep 2005 16:35:17 +0100
> You mean the second one is in no space, not the first one, correct?

No, he meant what he said.

> And this one with prefix is specified namespace:
> <OrderRequest xmlns:bt="";>

No. That binds the prefix bt to the namespace
so element names prefixed by bt: would be in tha namespace, but as this
element is unprefixed this namespace binding nas no effect on this
element. (It would have an effect on children of this element that have
a bt: prefix).

> So namespaces link an XML and XSLT file thru the URI, not the prefix.  

The namspace spec goes to some lengths to stress that prefixes are not
to be consided as important
<foo xmlns="ns"/> <x:foo xmlns:x="ns"/> <y:foo xmlns:y="ns"/>
all mean the same thing, just as they all mean the same as
<foo   xmlns='ns'/>   <x:foo   xmlns:x   ='ns'/> <y:foo   xmlns:y='ns'/>

So XSLT is more or less forced to use the URI not the prefix.

> But these seems to be confusing to many programmers, and that's why it
> should have been changed in XSLT 2.0.  I still use XSLT 1.0 though.

This part is the same in XSLT2 and in any other application that
supports XML namespaces. What is different in xpath2 is that you can
specify that an unprefixed name in xpath denotes a namespace other than
the null namespace, so if your xpath default element namespace is
"ns" then select="foo" will select foo in that namespace so it will
not select
but will select any of the forms listed above:
<foo xmlns="ns"/> <x:foo xmlns:x="ns"/> <y:foo xmlns:y="ns"/>

It remains to be seen whether this will be more or less confusing to
people. personally I see it as sometimes useful, but more likely to be a
source of confusion than a source of help.


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread