xsl-list
[Top] [All Lists]

Re: matching attribute values with namespaces

2005-07-12 14:12:42

the namespace axis is your friend:

<xsl:stylesheet
   version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";


<xsl:variable name="ns" select="document/namespace::*"/>

<xsl:template match="document">
<xsl:for-each select="$ns">
"<xsl:value-of select="name()"/>" is <xsl:value-of select="."/>
</xsl:for-each>
<xsl:apply-templates select="/*/*"/>
</xsl:template>

<xsl:template match="entry">
zzz[<xsl:value-of select="."/>]
</xsl:template>

<xsl:template
match="entry[substring-before(@type,':')=name(/document/namespace::*[.='http://somewhere.com/'])]">
ABC![<xsl:value-of select="."/>]
</xsl:template>


</xsl:stylesheet>


$ saxon ns.xml ns.xsl
<?xml version="1.0" encoding="utf-8"?>
"xml" is http://www.w3.org/XML/1998/namespace
"providerns1" is http://somewhere.com/
"providerns2" is http://sometimes.com/
ABC![test]

ABC![test]

zzz[test]

zzz[test]

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>