Subject:sum and group attrs, list only records with values Author:Jon Sonsteng Date:06 Sep 2006 09:31 AM
Using Stylus Studio Release 3 XML Professional; Rookie XML / XSLT user.
I have an XML document that lists items with 111 attributes; I have whittled it down to only the attributes pertinent to this discussion.
The XML doc lists engineering change requests (CR) with estimated engineering hours for each engineering group. The full report will have anywhere between 20 and 200 engineering CRs, each with 8 group hours attributes and 1 total of engineering hours.
What I need out of this document is a report that sums every group hour, then for each summed group hour with value > 0 list each CR that has value > 0 for that group.
Using JavaScript I have been able to sum the group hours and display a table with the totals (have not had time to explore summing in XSLT yet). I am having a real tough time getting the second part done; the “list each CR that has value > 0 for that group” section.
The root element is an ID number that is meaningless to me, so I use the FILE_ID attribute for identifying the CR.
I have attached what I have been working on for example, along with my trimmed version of the XML file for reference. Please do take into consideration that I am just learning this language, and have been thrust into generating this report.
Any and all suggestions gratefully attempted. Thanks in advance.
Subject:sum and group attrs, list only records with values Author:James Durning Date:06 Sep 2006 04:29 PM
I suggest something like the following.
Sum all the attr elements that belong to Body Eng Hours:
Replace
[i]document.writeln(totalBody);[/i]
with
<xsl:value-of select="sum(//item/attrs/attr[@name='hrs_body'])"/>