[xsl] variable in xpath

Subject: [xsl] variable in xpath
From: "Kalyan Kumar Mudumbai" <kalyan_tech@xxxxxxxxxxxxxx>
Date: 15 Nov 2002 05:33:36 -0000
I have two xml files with exactly similar hierarchy, but for a few different element nodes. Something like the following:

File1.xml
<element>
   <child>
      <a>
      <b>
   </child>
</element>

File2.xml
<element>
   <child>
     <a>
      <adesc>
     </a>
   </child>
</element>

I have a variable $path that holds an element's (in File1) xpath as if it was assinged by one the following:

<xsl:variable name="path" select="'element/child/a'"/>

How do I obtain and copy the node <adesc> of File2 using the above $path variable? Something like the below one:

<xsl:template match="node()">
   <xsl:copy-of select="document(File2.xml)/$path.."/>
</xsl:template>

Output has to be smth like this:
<element>
   <child>
     <a>
      <adesc>
     </a>
     <b>
   </child>
</element>

Thanks,
Kalyan

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


Current Thread