Re: [xsl] Selecting the value from diff i/p XML

Subject: Re: [xsl] Selecting the value from diff i/p XML
From: Syd Bauman <Syd_Bauman@xxxxxxxxx>
Date: Wed, 15 Sep 2010 19:08:34 -0400
I'm not 100% sure I understand what OP wants, but the following XSLT
1.0 program generates what I think is the desired output, albeit
probably a lot less efficiently than could be done with clever keys.

Note that I couldn't bring myself to have attributes named id= that
are not xsd:ID, so I renamed it to record=.

<?xml version="1.0" encoding="UTF-8"?>
<!-- read in Root2 as input, and correlate the record= -->
<!-- of each <data> with the corresponding record= of -->
<!-- an <item> in Root1, and spit out the value= of -->
<!-- the first match -->
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:template match="/">
    <wrapper>
      <xsl:apply-templates select="root2/data"/>
    </wrapper>
  </xsl:template>

  <xsl:template match="data">
    <out>
      <xsl:value-of select="@record"/>
      <xsl:text>=</xsl:text>
      <xsl:value-of select="document('./Root1.xml')/root1/item[@record=current()/@record]/@value"/>
    </out>
  </xsl:template>

</xsl:stylesheet>

Current Thread