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

Re: a namespace problem

Subject: Re: a namespace problem
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 5 Apr 2002 00:02:55 +0100
jeni baer
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


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-2011 All Rights Reserved.