L
Lenonardo
I need to sort an XML subtree using a value in a different matching subtree
in the same document.
The XSLT syntax I am using is (indented so that sort select and VAL
definition line up:
<xsl:for-each select='LABITEM0'>
<xsl:sort select='ancestor::TABLE/DATA/DIMN[@idx=current()/
@dimn_idx]/DIMN[@idx=$RANKCOL_IDX]/CELL/ITEM[contains($FIGTYPE,@class)][1]'
order='descending' data-type='number'/>
<xsl:variable name='VAL' select='/TABLE/DATA/DIMN[@idx=current()/
@dimn_idx]/DIMN[@idx=$RANKCOL_IDX]/CELL/ITEM[contains($FIGTYPE,@class)]
[1]'/>
<xsl:copy>
<xsl:copy-of select='@*'/>
<xsl:attribute name='ORD'><xsl:value-of select='position
()'/></xsl:attribute>
<xsl:attribute name='VAL'><xsl:value-of select='$VAL'/>
</xsl:attribute>
<xsl:copy-of select='*'/>
</xsl:copy>
</xsl:for-each>
This works fine using another XSLT processor (xsltproc)
BUT IS RETURNED UNSORTED (i.e. in original document order) using
XslTransform (and also msxml (4.0) from the command line).
The VAL attribute is correctly set - so I am pointing to the right values.
I've tried other sorts that do not use a path starting at the document root
and they seem to work OK.
Can anyone tell me why this isn't working - or suggest a sort select syntax
that would work?
in the same document.
The XSLT syntax I am using is (indented so that sort select and VAL
definition line up:
<xsl:for-each select='LABITEM0'>
<xsl:sort select='ancestor::TABLE/DATA/DIMN[@idx=current()/
@dimn_idx]/DIMN[@idx=$RANKCOL_IDX]/CELL/ITEM[contains($FIGTYPE,@class)][1]'
order='descending' data-type='number'/>
<xsl:variable name='VAL' select='/TABLE/DATA/DIMN[@idx=current()/
@dimn_idx]/DIMN[@idx=$RANKCOL_IDX]/CELL/ITEM[contains($FIGTYPE,@class)]
[1]'/>
<xsl:copy>
<xsl:copy-of select='@*'/>
<xsl:attribute name='ORD'><xsl:value-of select='position
()'/></xsl:attribute>
<xsl:attribute name='VAL'><xsl:value-of select='$VAL'/>
</xsl:attribute>
<xsl:copy-of select='*'/>
</xsl:copy>
</xsl:for-each>
This works fine using another XSLT processor (xsltproc)
BUT IS RETURNED UNSORTED (i.e. in original document order) using
XslTransform (and also msxml (4.0) from the command line).
The VAL attribute is correctly set - so I am pointing to the right values.
I've tried other sorts that do not use a path starting at the document root
and they seem to work OK.
Can anyone tell me why this isn't working - or suggest a sort select syntax
that would work?