"Mike King" <> writes:
...
> The test-a element always has one
> result element, so I don't have to worry about concatenation.
But you selected more than one such element and concatenated the result.
you get the concatenation of all the id values of result elements below
the first unit, so "01" in your sample input.
> I was hoping
> $my-sort would contain a sequence of text nodes, which would allow me to
> order following test-a elements based on the first unit's test-a elements.
It contains a root node with child a single text node, but even if it
did contain a sequence of text nodes (which is never possible in XPath
1, adjacent text nodes that share a parent atre always merged)
your Xpath of
msxsl:node-set($my-sort)/*[....
would select nothing as msxsl:node-set($my-sort)/* selects al the element
children (and text nodes are not elements).
I think that for each unit you just want to iterate through the first
one and select children with ids in that order. You don't need
xx:node-set for that:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns

sl="http://www.w3.org/1999/XSL/Transform"
>
<xsl

utput method="text" />
<xsl:variable name="order" select="data/unit[1]/test-a/result"/>
<xsl:template match="unit">
unit [<xsl:value-of select="@sn"/>]
<xsl:variable name="u" select="."/>
<xsl:for-each select="$order/@id">
<xsl:apply-templates select="$u/test-a/result[@id=current()]"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
produces
unit [5]
56
unit [6]
78
on your sample input.
David