RE: Wanted: All unique namespaces in a document

Subject: RE: Wanted: All unique namespaces in a document
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Wed, 5 Apr 2000 14:12:57 +0100
> 		<xsl:for-each select="//namespace::*">
> 			<xsl:value-of select="."/>
> 		</xsl:for-each>
> 
> In SAXON it outputs many, many namespace-uri. I guess it may return all
namespaces > > visible from each element.
yes, the XPath tree model says that each element node has a namespace node
for each namespace that is in scope for that element, and the namespace
nodes are not shared between elements.

> <xsl:for-each select="//*[not( namespace-uri(.) =
namespace-uri(preceding::.))]">

Firsly, preceding::. is wrong because . is not a NodeTesT. Secondly, this
only considers namespace URIs that are referenced by element names in the
source document, it will not consider namespaces that are used only for
attributes, or that are unused.

It's difficult to do a uniqueness test because namespaces aren't on the
preceding axis. Sounds like a good case for saxon:distinct():

select="saxon:distinct(//namespace::*)"

Mike Kay


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


Current Thread