[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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) ../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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Working with QNames in va, Jeni Tennison | Thread | Re: [xsl] Working with QNames in va, Curt Arnold |
[xsl] Fw: repeat: XSLT 2.0 Req: Ser, Curt Arnold | Date | Re: [xsl] RDDL as a delivery vehicl, Steve Muench |
Month |