Hi, Stephane.
"Stephane Dion" <[EMAIL PROTECTED]> wrote on 2005-10-20 09:51:08 AM:
> I?m trying to sort each block of NetPrice element by the attribute
> NetAmount. In each ProductOption, I have multiple NetPrice element
>
> Check my example below.
Focusing on the first template in your sample:
> <xsl:template
>
match="/GetProductOptionsResponse/DetailedProduct/ProductOptionGroup/ProductOption">
> <xsl:copy>
> <xsl:apply-templates>
> <xsl:sort data-type="number"
> select="NetPrice/@netAmount"
> order="ascending"/>
> </xsl:apply-templates>
> </xsl:copy>
> </xsl:template>
Each node selected for the xsl:apply-templates instruction, is used as the
context node to evaluate the select expression in the xsl:sort. With your
input document, the xsl:apply-templates selects the NetPrice children of
ProductOption. Each NetPrice node becomes the context node for evaluating
the expression NetPrice/@netAmount in the xsl:sort, which results in an
empty node set, because no NetPrice element has a NetPrice element as a
child.
If you change the xsl:sort to the following, it should work:
<xsl:sort data-type="number"
select="@netAmount"
order="ascending"/>
I hope that helps.
As an aside, I noticed that the elements in your input document have a
non-null namespace, but you didn't use that in the match pattern for the
first template. I also noticed that you're not copying any attributes.
I'm guessing that both of those problems arose when you produced your
example stylesheet, and the original stylesheet handles those things
correctly, but I thought I'd point them out anyway just in case.
Thanks,
Henry
------------------------------------------------------------------
Henry Zongaro Xalan development
IBM SWS Toronto Lab T/L 969-6044; Phone +1 905 413-6044
mailto:[EMAIL PROTECTED]