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
Steve TrythallSubject: Is this possible with XSLT? HELP!!
Author: Steve Trythall
Date: 24 Aug 2004 08:42 AM

I am really struggling to see how to do this with XSLT.
Do I need to resort to Java or is there a neat XPATH & XSLT
mechanism for this?

I have a document with a list of parts followed by a list of assemblies
that the parts potential may be in. The assemblies hold a ref to the parts.
For example, 3 wires, 2 in an assembly, 1 not:

<parts>
<wire id="1" name="WIRE1">
<property name="PartNumber" val="PartABC"/>
</wire>
<wire id="2" name="WIRE2">
<property name="PartNumber" val="PartABC"/>
</wire>
<wire id="3" name="WIRE3">
<property name="PartNumber" val="PartABC"/>
</wire>
<assembly name="my-assembly">
<assemblyelement ref="1"/>
<assemblyelement ref="2"/>
</assembly>
</parts>

I need to create a bill of materials that lists the occurences of the
parts either within assemblies or on their own. For example:

<BOM>
<wire partnumber="PartABC" quantity="1"/>
<assembly>
<wire partnumber="PartABC" quantity="2"/>
</assembly>
</BOM>

I can count the total number of wires with a particular part number, eg
count(//property[@name='PartNumber'and @val='PartABC']). However, I need
to do this in the context of an assembly.

Suggestions will be heartily recommended!

Steve

Postnext
Ivan PedruzziSubject: Is this possible with XSLT? HELP!!
Author: Ivan Pedruzzi
Date: 25 Aug 2004 02:33 AM
Hi Steve,

This was an interesting multi-level grouping problem.
I put together a solution that I hope you will find useful and generic enough to be extendable.

Ivan


Documentwire.xsl


Documentwire.xml

Posttop
Steve TrythallSubject: Is this possible with XSLT? HELP!!
Author: Steve Trythall
Date: 01 Sep 2004 10:10 AM

Ivan,
you are an XSLT god!! Thanks for this - stepping through its execution
taught me loads about doing multi-level grouping.

There was a problem with stylesheet. You weren't able to correctly count
the wires which weren't in an assembly. However, I copied the technique
you used for assemblies and that worked a treat.

Hearty thanks!

Steve

 
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.