user1746050
user1746050

Reputation: 2575

refer context of another xml in an existing xml context path

ep is a xml file and /R/Rt/W/AL is a node from another xml file. Is there any way I can get out of the ep context and reference the /R/Rt/W/AL node in the template below?

  <xsl:template match="ep"> 
    <xsl:copy> 
      <xsl:attribute name="attribute_name"> 
        <xsl:value-of select="/R/Rt/W/AL"/> 
      </xsl:attribute>  
      <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy> 
  </xsl:template> 

Upvotes: 0

Views: 53

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167691

You can for instance load the second document into a global variable with

<xsl:variable name="doc2" select="document('file2.xml')"/>

and then use <xsl:value-of select="$doc2/R/Rt/W/AL"/>. If you only need to access the data in the second document once then can of course do that directly with <xsl:value-of select="document('file2.xml')/R/Rt/W/AL"/>.

Upvotes: 1

Related Questions