[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Working with QNames in strings in XSLT 2.0

Subject: Re: Working with QNames in strings in XSLT 2.0
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 9 Sep 2008 09:02:36 +0100
Re:  Working with QNames in strings in XSLT 2.0
> 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>


match="*[namespace-uri-from-QName(resolve-QName(@mode, .)) eq
'urn:item-namespace-1.0']"

will compare the namespaces regardless of prefix

alternatively, get all of the in-scope-prefixes(), loop through them
and get the namespace-uri-for-prefix() to find the one bound to that
namespace, then just check the value of @mode (eg name() eq
'b:blip')... but I'm not sure you need to worry about the actual
prefix in this case?

cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.