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

Re: Working with QNames in values

Subject: Re: Working with QNames in values
From: Simon Fell <xml@xxxxxxxxxxxxxxxx>
Date: Sat, 03 Mar 2001 11:06:57 -0800
Re:  Working with QNames in values
Hi Jeni,

Thanks, that's a big help. Schematron doesn't appear to like using
variables, so i ended up with (from a foo/bar/@type context)

../namespace::*[local-name()=substring-before(current(),':')]

Thanks again.
Simon
www.pocketsoap.com

On Sat, 3 Mar 2001 08:42:14 +0000, in xml you wrote:

>Hi Simon,
>
>> I'm working with WSDL, which uses QNames in attribute values, but i'm
>> having a hard time resolving the namespace-uri's from these, e.g.
>>
>> <foo xmlns:xsd="http://...">
>> <bar type="xsd:string" />
>> </foo>
>>
>> In my XSLT (or more correctly, my schematron based schema), i want to
>> be able to resolve the namespace uri of the xsd:string QName. I was
>> hoping that the namspace-uri function would do it, but that returns
>> the namespace uri of the attribute, not the value.
>
>Hey, a use for namespace nodes!  I knew there had to be some point to
>them :)
>
>So, you get the type that you're after with:
>
>  foo/bar/@type
>
>Now, the part before the colon within that type is the prefix that's
>being used in the source document for some namespace.  So get that
>prefix:
>
>  <xsl:variable name="prefix"
>                select="substring-before(foo/bar/@type, ':')" />
>
>Now, to find out what namespace URI that prefix is associated with,
>you need to find the namespace node on the element that the value
>comes from which has the same name as that prefix.  So look at
>foo/bar, and find its namespace nodes:
>
>  foo/bar/namespace::*
>
>and then filter that to find the namespace node that is named after
>that prefix (I'm using local-name() here because the MSXML
>implementation wrongly gives the full name() as 'xmlns:xsd'):
>
>  foo/bar/namespace::*[local-name() = $prefix]
>
>The string value of that namespace is the namespace URI for the
>namespace, so getting the string value of the above will get you the
>namespace URI you're after.
>
>[Note: The namespace-uri() function gets you the namespace of the
>element/attribute - in the example above it resolves to the empty
>string because they're not in a namespace.]
>
>I hope that helps,
>
>Jeni
>
>---
>Jeni Tennison
>http://www.jenitennison.com/
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.