RE: [xsl] how to read attribute if defined as <namespace>:<attname>

Subject: RE: [xsl] how to read attribute if defined as <namespace>:<attname>
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 15 Jul 2003 15:42:46 +0100
> 
> However, this is not guaranteed to work because
> XSL isn't obligated to preserve prefix names (though it
> usually will). It's only obligated to make sure the right 
> namespace-URIs continue to be associated with the right 
> nodes.  (Someone please correct me if that's inaccurate.)

It's inaccurate.

The namespace nodes in the data model hold a prefix and URI. Operations
on namespace nodes are therefore prefix-preserving. But element and
attribute nodes don't hold a namespace prefix, they only hold a
namespace URI. This means, for example, that if you use the name()
function on an element, it's (in theory) unpredictable what the prefix
will be, but whatever the prefix is, you can find out what URI it
relates to by looking for that prefix in the namespace nodes. In
practice, prefixes returned by name() (or generated in output by the
serializer) are predictable except in unusual cases, for example (a) if
two prefixes have been declared for the same URI, or (b) if the same
prefix has been used for two different URIs.

Michael Kay


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


Current Thread