Re: [xsl] Searching in Sub-children from an Array

Subject: Re: [xsl] Searching in Sub-children from an Array
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 7 Dec 2006 12:31:27 GMT
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
  <xsl:key name="step" match="fruit_adjustment/color" use="../Steps"/>

  <xsl:template match="*">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="fruit_adjustment"/>
  
  <xsl:template match="color">
    <xsl:copy-of select="(key('step',string-join(ancestor-or-self::*[@ID]/@ID,',')),.)[1]"/>
  </xsl:template>

</xsl:stylesheet>




David



$ saxon8 fruit.xml fruit.xsl 
<?xml version="1.0" encoding="UTF-8"?><tree>
        <fruit ID="111">
                <mango ID="333">
                        <color>green</color>
                </mango>
                <orange ID="222">
                        <color>orange</color>
                </orange>
        </fruit>

</tree>

Current Thread