xsl-list
[Top] [All Lists]

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

2007-11-19 02:42:40
Abel,
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?


P1
    => P2
        =>P3
    => 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--