| Subject: [xsl] XSLT/XPath help to resolve definition references in a WSDL XML fi	le From: thomas.cherel@xxxxxxxxxxxxxxxxxxxxx Date: Wed, 4 Sep 2002 10:24:44 -0400 | 
I need some help on pure XSLT/XPath syntax/capabilities.
Let's say that I have an XML document looking like that:
<root>
  <A name="a1"><B .../></A>
  <A name="a2"><B .../></A>
  <A name="a3"><B .../></A>
  <C aRef="ns1:a1"/>
  <C aRef="ns2:a2"/>
</root>
I want to be able to select all the B element which are under the A elements
referenced by the C element (the A elements for which a C/@aRef attribute
value, minus the prefix, is equal to the A/@name attribute).
Someone (David Bertoni) from the Apache xalan-c mailing suggested the
solution presented below, but also suggested that I ask the question in this
mailing to look for a potential better way of doing that (especially since
it is using a xalan extension function).
To give a little bit of context, I am trying to write a style sheet to
analyze a WSDL document. Such document contains quite a lot of construct
like the one presented above.
Any help will be appreciated. Thanks.
Thomas
  <?xml version="1.0"?>
   <xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0"
     exclude-result-prefixes="xalan"
     xmlns:xalan="http://xml.apache.org/xalan">
   <xsl:template match="root">
     <out>
       <xsl:variable name="local-C">
           <xsl:apply-templates mode="localName-C" select="C" />
       </xsl:variable>
       <xsl:variable name="aRef" select="xalan:nodeset($local-C)/C/@aRef"/>
       <xsl:copy-of select="B[parent::A/@name = $aRef]"/>
     </out>
   </xsl:template>
   <xsl:template match="C" mode="localName-C">
     <C aRef="{substring-after(@aRef, ':')}">
     </C>
   </xsl:template>
   </xsl:stylesheet>
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] Ann: Updated world-wide XSLT/, G. Ken Holman | Thread | Re: [xsl] XSLT/XPath help to resolv, David Carlisle | 
| [xsl] Ann: Updated world-wide XSLT/, G. Ken Holman | Date | RE: [xsl] Please help with Grouping, Khan, Amir | 
| Month |