xsl-list
[Top] [All Lists]

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

2007-11-19 00:13:04
Note:
The below question was earlier posted under the subject "XSL support
of Bottom up transformations? ", reposting with more details as I had
only digest subscription earlier and could not reply to the digest.

Requirement in Abstract:
A recursive product tree is to be tansformed. The product at the top
level element whose value is a derived value which is based similarly
caluclated element value. Hence the issue of bottom nodes need to be
calculated before the top nodes.

The source XML document is an Order Detail tree (Contains
details of 1 order). There can be multiple Order line and each line
represent an Product. The Item line itself is recursive in the sense
that one product can be made up of multiple lines.

Each line is defined as below:
=====================
<orderline>
       <linenum>1</linenum>
       <productName>15' Monitor</productName>
       <netPrice>100</netPrice>
       <itemTypeCode>1</itemTypeCode>
       <untiPrice>  To be caluclated </unitPrice>
       <orderline></orderline>
                       <orderline></orderline>
                               <orderline></orderline>
       <orderline></orderline>
       <orderline></orderline>
</orderline>

I need to calculate a new element called unitPrice based on the below logic:

1. If the itemTypeCode of the current Item is '1' then unitPrice is netPrice
2. If the itemTypeCode of the current Item is '2' then unitPrice is
sum of all the (unitPrice/quantity) of all the child lines
3. If the itemTypeCode of the current Item is '3' then unitPrice is
Sum of unitPrice of only the first level child elements

The above defn should be applied at all levels where unitPrice is
calculated. And this is where I say I need to calculate the bottom
value first and then arrive at parent's value.

These transformations are required along with other simple
transformations on other attributes.

Pls. let me know what is he best way out here.

Thanks,
Raghu

--~------------------------------------------------------------------
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>
--~--