This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: a namespace problem


Hi Bryan,

>>Namespace prefixes (or lack of them) in the XML document don't
>>matter. Namespace prefixes in the XSLT document don't matter, but if
>>you want to refer to an element or attribute in a namespace then you
>>must associate some kind of prefix with that namespace.
>
> hmm so this means that if you have two prefixes pointing at the same
> namespace for example
> xmlns:foo="http://www.namespaces.org/foo";
> and
> xmlns:goo="http://www.namespaces.org/foo";
>
> xsl:template match="goo:bar"
>
> would match instances in our document of <foo:bar>...</foo:bar>?

Yes. If goo was associated with the namespace URI
http://www.namespaces.org/foo in the stylesheet, and foo was
associated with the namespace URI http://www.namespaces.org/foo in the
document, then the pattern "goo:bar" would match elements that were
serialised as <foo:bar>...</foo:bar> in the original document.

> I was gonna say that was not to my liking either but then I remember
> I made a little prefix parsing-re-arranging tool about a month ago
> that could be adapted to handle that kind of situation, if for
> example one wanted to do some distinguishing between members of the
> foo namespace that had the goo prefix. I must admit this is one of
> those cases where it really seems counter-intuitive.

I'm not sure what your tool was doing, but I think it's highly
inadvisable to treat prefixes as anything but a
string-that-happens-to-currently-be-associated-with-a-namespace.
Namespace-aware tools such as XSLT, DOM, SAX, XML Schema, RELAX NG,
etc etc will not make any distinction between foo:bar and goo:bar as
long as foo and goo are associated with the same namespace URI in the
same document. For example, given that both prefixes are declared
within a document, when XSLT creates a copy of a document, the
processor is quite within its rights to choose either prefix for a
particular element. When you use the name() function, it could return
either 'foo:bar' or 'goo:bar' - it doesn't matter which you used in
the document. If you need to distinguish between a foo:bar element and
a goo:bar element, then foo and goo should be associated with
different namespaces.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]