[thelist] Another XSL question

Mark Kennedy mark at eurogamer.net
Thu Mar 13 10:13:21 CST 2003


Of course, yeah.  It didn't occur to me that you could select ALL namespaces and
then pick through them.  Thanks for that, it should come in useful one day!  I
guess this opens up possibilities for importing stylesheet modules at
processing-time based on the namespaces found in your document source.  Is this
what you're doing?

Mark

>Actually I figured this out yesterday evening, and sent in a tip but I guess
>it got lost in the ether or maybe it bounced, so I'll resend.
>
>It's actually embarrassingly easy... :)
>
><tip type="Referencing XML namespace attributes using XSLT and XPath"
>author="Dave Cantrell">
>If you want to access the namespace node of an element in an XML file, such
>as the following:
>
>	<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>version="1.0">
>	...
>	</xsl:stylesheet>
>
>You can use an XPath axis like so:
>
>	namespace::*
>
>In XSLT it could look something like this:
>
>	<xsl:template match="/xsl:stylesheet">
>		<xsl:for-each select="namespace::*">
>			<p>
>				Prefix: <xsl:value-of
>select="{local-name()}"/>
>				<br/>
>				URI: <xsl:value-of select="{.}"/>
>			</p>
>		</xsl:for-each>
>	</xsl:template>
></tip>



More information about the thelist mailing list