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
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>

 
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.