[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPATH Conditional Values and Sums

Subject: Re: XPATH Conditional Values and Sums
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Tue, 10 Aug 2004 21:31:07 +0200
xpath conditional
Puneet Railan wrote:
[snip sample]
The parameter being passed in is specified via the other XSLT generated
by MapForce (which allows me to create some mappings and generate XSLT
automatically).  I'm basically trying to use this as a sort of
plug-in/mapforce library file to do transformations.  Basically, what I
want done with that sample code up there (and using some of the code
below) is to sum (roll-up) everything in the Data elements by the SSL
name attribute.  I'm sorry if that wasn't clear in the first place.

The following will almost literally do what you describe: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="/*"> <xsl:for-each select="SSL/@name"> <xsl:call-template name="GetSum"> <xsl:with-param name="filter1" select="."/> </xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template name="GetSum"> <xsl:param name="filter1" select="."/> <xsl:value-of select="sum(//SSL[@name=$filter1]//Data)"> </xsl:template> </xsl:stylesheet>

I suspect your actual requirements are a bit more complicated,
but it may serve as a start. If performance becomes a problem,
use a key for selecting the SSL elements.

J.Pietschmann

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.