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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.