|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Multiply Element Values
Objective:
--------
To create a table and perform some calculations using xsl.
Product qty price
cost
Web Development 2 440 880
Standardisation 7 20 140
----
TOTAL 1020
====
Task Breakdown:
-------------
* need to multiply qty and price
* for each item in the table
* display the result in the table
* output of each line multiplied needs to be a number
* add all costs to get a total
FILE: DTD
---------
....
&Template.xml
...
<Components>
<Product ref='itm1_Desc'>Web Development</Product>
<Product ref='itm1_Qty'>2</Product>
<Product ref='itm1_Price'>440</Product>
<Product ref='itm2_Desc'>Standardisation</Product>
<Product ref='itm2_Qty'>7</Product>
<Product ref='itm2_Price'>20</Product>
</Components>
....
FILE: Template.xml
----------------
.......
<Table>
<TableRow>
<TableData><Components ref='itm1_Desc'/></TableData>
<TableData><Components ref='itm1_Qty'/></TableData>
<TableData><Components ref='itm1_Price'/></TableData>
<TableData><Components ref='itm2_Desc'/></TableData>
<TableData><Components ref='itm2_Qty'/></TableData>
<TableData><Components ref='itm2_Price'/></TableData>
</TableRow>
</Table>
........
FILE: Transform.xsl
----------------
.....
<xsl:template match="Components">
<xsl:apply-templates select='/ProjectPlan/Components
/Product[@ref=current()/@ref]'/>
</xsl:template>
.......
***** QUERY *****
----------------
* I am able to display the uncalculated fields of this data.
* I would appreciate assistance with a template that
will multiple the qty and price and store the result.
Rough idea:
<xsl:template match="Product/ref[@Qty=current()/@Qty]"/>
<xsl:for-each select="Product/ref">
<xsl:value-of select="@Qty * @Price"/>
<xsl:number> </xsl:number>
</xsl:for-each>
</xsl:template>
* I need to perform the calculation and store the
output into a variable I can use and display, is
this possible?
* And could you hint at the possibility of then using
this output to perform another calculation using
the sum(nodeset) function. If there is some further
reading material that you could direct me to I would
be much appreciative.
Kind Regards
Rhonda
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








