[xsl] Working with QNames in strings in XSLT 2.0

Subject: [xsl] Working with QNames in strings in XSLT 2.0
From: Ian Stokes-Rees <ijstokes@xxxxxxxxxxxx>
Date: Tue, 09 Sep 2008 00:35:14 -0400
Hi,

I'm trying to work with the XSLT 2.0 functions for manipulating QNames, but am at a loss for how to check QName strings in XSLT. I am using Saxon-B 9.1.0.

I will have input documents of the form:

customer1.xml:
<foo xmlns:a="urn:item-namespace-1.0" mode="a:blip" value="ping"/>

customer2.xml:
<foo xmlns:b="urn:item-namespace-1.0" mode="b:blip" value="pong"/>

I want to write a template which will match the <foo> elements with @mode attributes set to the QName of {'urn:item-namespace-1.0','blip'}, however using a NS prefix taken from the document. I can't figure out how to do this. My best guess (which doesn't work) is:

<xsl:template match="foo[resolve-QName(@mode,.) = QName('urn:item-namespace-1.0','blip')]">
<bar value="{./@value}">found element foo with right mode</bar>
</xsl:template>


I've searched the archives, the FAQ, the XSD and XSLT specs, and some other XSLT 2.0 function references but to no avail. Any suggestions warmly welcomed.

Ian

--
Ian.Stokes-Rees@xxxxxxxxxxxx +1 (617) 418-4168
SP Metric Limited, Technology Consulting

Current Thread