[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Sort, group, flatten, consecutive data

Subject: Sort, group, flatten, consecutive data
From: "Midnit" <midnit@xxxxxxxxxxxxxxxxx>
Date: Tue, 28 Jun 2005 17:01:18 -0400
midnit
This is my first post here; I apologize if it's inappropriate.

I'm attempting to flatten and consolidate this XML document. In short I
would sort by DETAIL_ID and PRODUCTIONDAY, then group up based on the RATE,
outputting BEGINDAY and ENDDAY to represent the date range the RATE covered.
Though not shown in this example of data, there will be a record for every
day in the month so sorting by PRODUCTIONDAY will always produce consecutive
rows. I have no problem flattening the data but the attempts I've made at
grouping the data have failed miserably. All the examples I have found use
preceding-sibling and following-sibling which doesn't apply for my data, at
least that's my assumption. I have also tried using keys but I have run into
similar problems.

I am using XSLT 1.0.

Any suggestions would be greatly appreciated. What is the equiv of
following-sibling for my DETAIL_ID's?

<?xml version='1.0'?>
<BUSINESSASSOCIATE>
	<ID>116</ID>
	<SUPPLYCONTRACTS>
		<CONTRACT number='555'>
			<ID>351</ID>
			<DAYS>
				<DATE>
					<DAY>3/5/2004</DAY>
					<VERSIONS>
						<VERSION>
							<DETAILS>
								<DETAIL>
	
<DETAIL_ID>570</DETAIL_ID>
	
<PRODUCTIONDAY>5</PRODUCTIONDAY>
	
<PRODUCTIONDATE>3/5/2004</PRODUCTIONDATE>
	
<RESERVATION>
	
<RATE>0.01</RATE>
	
</RESERVATION>
								</DETAIL>
							</DETAILS>
						</VERSION>
					</VERSIONS>
				</DATE>
				<DATE>
					<DAY>3/4/2004</DAY>
					<VERSIONS>
						<VERSION>
							<DETAILS>
								<DETAIL>
	
<DETAIL_ID>570</DETAIL_ID>
	
<PRODUCTIONDAY>4</PRODUCTIONDAY>
	
<PRODUCTIONDATE>3/4/2004</PRODUCTIONDATE>
	
<RESERVATION>
	
<RATE>0.01</RATE>
	
</RESERVATION>
								</DETAIL>
							</DETAILS>
						</VERSION>
					</VERSIONS>
					</DATE>
				<DATE>
					<DAY>3/3/2004</DAY>
					<VERSIONS>
						<VERSION>
							<DETAILS>
								<DETAIL>
	
<DETAIL_ID>570</DETAIL_ID>
	
<PRODUCTIONDAY>3</PRODUCTIONDAY>
	
<PRODUCTIONDATE>3/3/2004</PRODUCTIONDATE>
	
<RESERVATION>
	
<RATE>0.01</RATE>
	
</RESERVATION>
								</DETAIL>
							</DETAILS>
						</VERSION>
					</VERSIONS>
				</DATE>
				<DATE>
					<DAY>3/2/2004</DAY>
					<VERSIONS>
						<VERSION>
							<DETAILS>
								<DETAIL>
	
<DETAIL_ID>570</DETAIL_ID>
	
<PRODUCTIONDAY>2</PRODUCTIONDAY>
	
<PRODUCTIONDATE>3/2/2004</PRODUCTIONDATE>
	
<RESERVATION>
	
<RATE>0.02</RATE>
	
</RESERVATION>
								</DETAIL>
							</DETAILS>
						</VERSION>
					</VERSIONS>
				</DATE>
				<DATE>
					<DAY>3/1/2004</DAY>
					<VERSIONS>
						<VERSION>
							<DETAILS>
								<DETAIL>
	
<DETAIL_ID>570</DETAIL_ID>
	
<PRODUCTIONDAY>1</PRODUCTIONDAY>
	
<PRODUCTIONDATE>3/1/2004</PRODUCTIONDATE>
	
<RESERVATION>
	
<RATE>0.02</RATE>
	
</RESERVATION>
								</DETAIL>
							</DETAILS>
						</VERSION>
					</VERSIONS>
				</DATE>
			</DAYS>
		</CONTRACT>
	</SUPPLYCONTRACTS>
</BUSINESSASSOCIATE>

Rough example of output:

<ROWS>
	<ROW CONTRACT_ID="351" CONTRACT_NUMBER="555" DETAIL_ID="570"
BEGINDAY="3/1/2004" ENDDAY="3/2/2004" RATE="0.02"/>
	<ROW CONTRACT_ID="351" CONTRACT_NUMBER="555" DETAIL_ID="570"
BEGINDAY="3/3/2004" ENDDAY="3/5/2004" RATE="0.01"/>
</ROWS>

-Robert

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.