Sorting Problem

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?
 
L

Lenonardo

Amendment - I pasted the incorrect syntax as I have been trying so many
options. The previously pasted syntax still does not work - but the
actual syntax I am querying does NOT use the ancestor:: axis - and start
with /TABLE/DATA/DIMN/... - exactly as in the definition of $VAL.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top