Re: Sort, group, flatten, consecutive data
2005-06-28 14:40:09
Hi, Robert,
Welcome to the XSL list.
Just the keywords in your subject line tell me that your post is on-topic,
so you needn't apologize.
Grouping is one of those things that really depends on what are trying to
achieve, so please post the XML you'd like your XSL to produce. With only
the input to play with, I'd have to guess, which may just waste time and
not give you what you need. Just offhand, I'd say you'll need to use keys
or walk up and down the ancestor axis to get where you're going, but it's
hard to be specific without seeing the desired output.
Also, as a small favor, could you use less indentation? I'm getting nasty
wrapping when I view your source XML (partly because the mail client I
have to use is dumb as a post). A couple spaces rather than a couple tabs
would be much nicer.
Thanks.
Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)
"Midnit" <midnit(_at_)shadowcouncil(_dot_)com>
06/28/2005 04:01 PM
Please respond to
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
cc
Subject
[xsl] Sort, group, flatten, consecutive data
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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
Previous by Date: |
Sort, group, flatten, consecutive data, Midnit |
Next by Date: |
Re: Sort, group, flatten, consecutive data, JBryant |
Previous by Thread: |
Sort, group, flatten, consecutive data, Midnit |
Next by Thread: |
Re: Sort, group, flatten, consecutive data, JBryant |
Indexes: |
[Date]
[Thread]
[Top]
[All Lists] |
|
|