Subject: Re: [xsl] XPATH Conditional Values and Sums From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Tue, 10 Aug 2004 21:31:07 +0200 |
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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XPATH Conditional Values , Puneet Railan | Thread | [xsl] format-date and xsd:date, Bruce D'Arcus |
RE: [xsl] Another tokenize() questi, Michael Kay | Date | Re: [xsl] FO: padding within list p, J.Pietschmann |
Month |