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
Jon SonstengSubject: 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.

Jon


Documentenghrs_forum.xml
Sample XML data

DocumentUntitled_CR_TEST.xsl
Sample XSL data

Postnext
James DurningSubject: 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'])"/>

2nd part:
<xsl:for-each select="item[attrs/attr[@name='hrs_body'] > 0]">
<xsl:value-of select="attrs/attr[@name="FILE_ID"]"/>
</xsl:for-each>

Posttop
Jon SonstengSubject: sum and group attrs, list only records with values
Author: Jon Sonsteng
Date: 07 Sep 2006 10:38 AM
Thank you so much, James! I knew there would be an easier way to sum up the hours. Simplicity @ it's best always works. Thanks again.

 
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.