Subject: RE: [xsl] Continuously add to a parameter at each call From: "Emil Soosaithasan" <emils@xxxxxxxxxxxxxxxx> Date: Thu, 10 Nov 2005 10:21:24 -0500 |
Michael, That was a great solution, worked like a magic after a few minor modifications and the processing time has been reduced soooooo much Thanks again for your help -----Original Message----- From: Haarman, Michael [mailto:mhaarman@xxxxxxxxx] Sent: Wednesday, November 09, 2005 6:14 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: RE: [xsl] Continuously add to a parameter at each call Emil, > <Tasks> > <Task><Name>Hardware</Name><OutlineLevel>1</OutlineLevel><WBS> > 1</WBS></T > ask> > <Task><Name>Bringup</Name><WBS>1.1</WBS><Cost>12</Cost></Task> > <Task><Name>Testing</Name><WBS>1.2</WBS><Cost>22</Cost></Task> > <Task><Name>Software</Name><OutlineLevel>1</OutlineLevel><WBS> > 2</WBS></T > ask> > <Task><Name>Development</Name><WBS>2.1</WBS><Cost>1</Cost></Task> > <Task><Name>Test</Name><WBS>2.2</WBS><Cost>3</Cost></Task> > </Task> For a document like the snip above, something like the following gets very close to what you want. Things to note: a) the top-level xsl:key instruction is standard means of grouping, b) the *use* attr of key takes a XPath expression evaluating to a string c) sum takes a node-set, which is the return type of key() function <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:key name="tasks" match="*/Task" use="substring(WBS, 1, 1)"/> <xsl:template match="/"> <totals> <xsl:for-each select="*/Task[OutlineLevel = '1']"> <p> <xsl:value-of select="Name"/> total: <xsl:value-of select="sum(key('tasks', WBS)/Cost)"/> </p> </xsl:for-each> </totals> </xsl:template> </xsl:stylesheet> A plain English paraphrase of the select expression of the for-each is obvious. The select expression that does the work means:
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Continuously add to a par, Haarman, Michael | Thread | [xsl] Free XSLT designer tool, srdjan |
Re: [xsl] changing source-tree, David Carlisle | Date | Re: [xsl] Text to come after a bloc, JBryant |
Month |