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
david knightSubject: selecting data into node set between two values
Author: david knight
Date: 30 Nov 2007 11:17 AM
Sorry if this is an extremely simple question, but I'm about as new to XML/XSL as you can be. I have the following XML, and need to select the data into chunks based upon a "change item" node having an "action_name" of "Create Order". So, in this data, there would be three chunks: one before the first create order, one between the two create orders and then the remaining data. I just can't figure out how to match it.

<?xml version="1.0" encoding="UTF-8" ?>
<transaction>
<change_history>
<change_item action_var_name="_open_quote_process" action_name="Open Quote" />
<change_item action_var_name="save_quote" action_name="Save" change_date="2007-11-29 15:38:35">
<discount_line document_number="2" old_value="10.0" new_value="0.0" />
<discount_line document_number="6" old_value="10.0" new_value="0.0" />
</change_item>
<change_item action_var_name="_update_line_items" action_name="Update Price" change_date="2007-11-29 15:38:41">
<marginPercentage document_number="6" old_value="15.6" new_value="24.0" />
</change_item>
<change_item action_var_name="submit_quote" action_name="Finalize Quote" change_date="2007-11-29 15:38:46">
<status_quote document_number="1" old_value="Pending" new_value="Submitted" />
<submittedDate_quote document_number="1" old_value="" new_value="2007-11-29 15:38:45" />
<expirationDate_quote document_number="1" old_value="" new_value="2007-12-29 15:38:45" />
<quoteType_quote document_number="1" old_value="Draft" new_value="Final" />
</change_item>
<change_item action_var_name="createOrder_quote" action_name="Create Order" change_date="2007-11-29 15:38:49" >
<status_quote document_number="1" old_value="Submitted" new_value="Creating Order" />
<submittedDate_quote document_number="1" old_value="2007-11-29 15:38:45" new_value="2007-11-29 00:00:00" />
<expirationDate_quote document_number="1" old_value="2007-12-29 15:38:45" new_value="2007-12-29 00:00:00" />
</change_item>
<change_item action_var_name="_open_quote_process" action_name="Open Quote" change_date="2007-11-29 15:44:38" />
<change_item action_var_name="submitOrder_quote" action_name="Submit Order" change_date="2007-11-29 15:45:07">
<status_quote document_number="1" old_value="Creating Order" new_value="Order Submitted" />
<poNumber_quote document_number="1" old_value="" new_value="12345652" />
<poDate_quote document_number="1" old_value="" new_value="2007-11-29 00:00:00" />
</change_item>
<change_item action_var_name="_open_quote_process" action_name="Open Quote" change_date="2007-11-29 15:46:32" />
<change_item action_var_name="revise_quote" action_name="Revise" change_date="2007-11-29 15:46:36">
<revisionNumber_quote document_number="1" old_value="2" new_value="3" />
<status_quote document_number="1" old_value="Order Submitted" new_value="Pending" />
<submittedDate_quote document_number="1" old_value="2007-11-29 00:00:00" new_value="" />
</change_item>
<change_item action_var_name="_open_quote_process" action_name="Open Quote" change_date="2007-11-29 15:47:53" />
<change_item action_var_name="revise_quote" action_name="Revise" change_date="2007-11-29 15:47:56" user_login="superuser">
<revisionNumber_quote document_number="1" old_value="3" new_value="4" />
</change_item>
<change_item action_var_name="submit_quote" action_name="Finalize Quote" change_date="2007-11-29 15:48:08">
<status_quote document_number="1" old_value="Pending" new_value="Submitted" />
<submittedDate_quote document_number="1" old_value="" new_value="2007-11-29 15:48:07" />
<expirationDate_quote document_number="1" old_value="2007-12-29 00:00:00" new_value="2007-12-29 15:48:07" />
</change_item>
<change_item action_var_name="createOrder_quote" action_name="Create Order" change_date="2007-11-29 15:48:10">
<status_quote document_number="1" old_value="Submitted" new_value="Creating Order" />
<submittedDate_quote document_number="1" old_value="2007-11-29 15:48:07" new_value="2007-11-29 00:00:00" />
<expirationDate_quote document_number="1" old_value="2007-12-29 15:48:07" new_value="2007-12-29 00:00:00" />
</change_item>
<change_item action_var_name="submitOrder_quote" action_name="Submit Order" change_date="2007-11-29 15:48:12" >
<status_quote document_number="1" old_value="Creating Order" new_value="Order Submitted" />
</change_item>
</change_history>
</transaction>

Posttop
James DurningSubject: selecting data into node set between two values
Author: James Durning
Date: 03 Dec 2007 09:45 AM
One way is to use generate-id.
Another way is to use key.
I like the key method personally:
<xsl:key name="CreateIndex" match="change_item_action" use="generate-id(preceding-sibling::change_item_action[
@action_name='Create Order'][1])"/>

1st chunk:
<xsl:for-each select="key('CreateIndex', '')">
...
</xsl:for-each>

Subsequent chunks
<xsl:for-each select="change_item_action[
@action_name='Create Order']>
<Chunk>
<xsl:for-each select="key('CreateIndex', generate-id())"/>
</Chunk>
</xsl:for-each>

   
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.