Re: [xsl] XSL Trnasfromation - Is it possible to do a bottom up transformation?

Subject: Re: [xsl] XSL Trnasfromation - Is it possible to do a bottom up transformation?
From: "Raghu Narayan Koratagere" <raghu.k.n@xxxxxxxxx>
Date: Mon, 19 Nov 2007 15:12:06 +0530
The problem is here you are transforming top down. If my inference is
right, then you are saying P1's Unit price is Sum(P2-UnitPrice,
P4-UnitPrice, P5-UnitPrice).

The problem is you need to calculate UnitPrice P2, P4 and P5 in first
place before this can be applied?

    => P2
    => P4
    => P5

Hope the issue is clear. I will try to get some sample data and post
the actual source tree.

> > 3. If the itemTypeCode of the current Item is '3' then unitPrice is
> > Sum of unitPrice of only the first level child elements
> >
> <xsl:template match="unitPrice[../itemTypeCode = '3']">
>     <xsl:copy><xsl:value-of select="sum(../unitPrice[1] div
> ../quantity[1])" /></xsl:copy>
> </xsl:template>
> Unfortunately, it is quite unclear from your (not-well-formed!!) source
> sample code what you mean by "child element". Please provide a working
> set of source xml, and show us the XSLT that you currently have with the
> part that's troubling you. In lieu of this, please make clear what
> "recursive" means to you. Usually, a recursive template approach is
> rather trivial in XSLT, but obviously, it is rather non-trivial to
> invent what you might mean by "recursive" as it may have many meanings.
> If you need to calculate the sum of all unitPrice from a certain level,
> arbitrarily deep, then you should use the following statement, assuming
> your context node is on the right (parent) level:
> sum(.//unitPrice)
> HTH,
> Cheers,
> -- Abel Braaksma

Current Thread