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]

RE: Wanted: All unique namespaces in a document


> 		<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

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