XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
shiva kumarSubject: To find totalamount
Author: shiva kumar
Date: 10 Nov 2006 01:40 AM
Hi,
I need to find out the total sum of all the line items(price * PriceUnit) from the below xml file. that is my total amount is 125 from the below xml. I need to get it done this thru xsl. I tried with following-sibling::. But i couldnt find out.

<TPartner>
<LineItem>
<RequestedPrice>
<Price>10</Price>
<PriceUnit>1</PriceUnit>
</RequestedPrice>
</LineItem>
<LineItem>
<RequestedPrice>
<Price>20</Price>
<PriceUnit>2</PriceUnit>
</RequestedPrice>
</LineItem>
<LineItem>
<RequestedPrice>
<Price>25</Price>
<PriceUnit>3</PriceUnit>
</RequestedPrice>
</LineItem>
</TPartner>


Is there Anyone can help me on this ?

thanks,
shiv

Postnext
Ivan PedruzziSubject: To find totalamount
Author: Ivan Pedruzzi
Date: 10 Nov 2006 09:25 PM
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates select="TPartner/LineItem[1]"/>
</xsl:template>

<xsl:template match="LineItem">
<xsl:param name="total" select="0"/>
<xsl:variable name="i" select="following-sibling::LineItem[1]"/>
<xsl:variable name="t" select="$total + (RequestedPrice/Price * RequestedPrice/PriceUnit)"/>
<xsl:apply-templates select="$i">
<xsl:with-param name="total" select="$t"/>
</xsl:apply-templates>
<xsl:if test="not($i)">
<xsl:value-of select="$t"/>
</xsl:if>
</xsl:template>

</xsl:stylesheet>


Ivan Pedruzzi
Stylus Studio Team
http://www.stylusstudio.com/xml_download.html

Postnext
shiva kumarSubject: To find totalamount
Author: shiva kumar
Date: 13 Nov 2006 03:35 AM
Hi Ivan,

Great..The above code is working..Thanks a alot for ur immediate response.

Cheers,
Shiv

Postnext
shiva kumarSubject: To Display current date in specified format
Author: shiva kumar
Date: 14 Nov 2006 12:48 AM
Hi,

I want to display current date & time in the format "yyyyMMddhhmmss" using xsl. can u suggest how to accomplish this, without using any extension functions or java in xsl.

Cheers,
Shiv

Posttop
Ivan PedruzziSubject: To Display current date in specified format
Author: Ivan Pedruzzi
Date: 14 Nov 2006 08:10 AM

XSLT 2.0
http://www.w3.org/TR/xslt20/#format-date

XSLT 1.0
http://www.exslt.org/date/functions/format-date/date.format-date.template.xsl.html


Ivan Pedruzzi
Stylus Studio Team

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.