Re: [xsl] Working with QNames in values

Subject: Re: [xsl] Working with QNames in values
From: Simon Fell <xml@xxxxxxxxxxxxxxxx>
Date: Sat, 03 Mar 2001 11:06:57 -0800
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)


Thanks again.

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
>  <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 Tennison

 XSL-List info and archive:

Current Thread