[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] preceding-sibling after sort gives unexpected result


Subject: RE: [xsl] preceding-sibling after sort gives unexpected result
From: "Kaine Varley" <kaine.varley@xxxxxxxxxxxx>
Date: Fri, 12 Sep 2003 10:34:20 +0100

Michael, J. Pietschmann and Dimitre,

Thanks for your valuable advice. I have found that the following modified
stylesheet, with MS extension function, resolved my problem:

Stylesheet:
-----------
<xsl:template match="root">
   <results>
      <xsl:apply-templates select="parent" />
   </results>
</xsl:template>


<xsl:template match="parent">
   <xsl:variable name="sorted-children">
      <xsl:for-each select="child">
         <xsl:sort select="." data-type="number" order="descending" />
         <xsl:copy-of select="." />
      </xsl:for-each>
   </xsl:variable>

   <xsl:apply-templates select="msxsl:node-set($sorted-children)/child" />

</xsl:template>


<xsl:template match="child">
   <result number="{position()}">
      <current-child-name>
         <xsl:value-of select="@name" />
      </current-child-name>
      <current-child-value>
         <xsl:value-of select="." />
      </current-child-value>
      <preceding-sibling-name>
         <xsl:value-of select="preceding-sibling::child[1]/@name" />
      </preceding-sibling-name>
   </result>
</xsl:template>


Thanks again for all your help.


Kaine


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



Current Thread