Subject: RE: [xsl] Sort, group, flatten, consecutive data From: "Aron Bock" <aronbock@xxxxxxxxxxx> Date: Sat, 02 Jul 2005 02:45:44 +0000 |
<data> <a n="1" v="1"/> <a n="2" v="1"/> <a n="4" v="2"/> <a n="3" v="1"/> </data>
<xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/>
<xsl:template match="/"> <xsl:variable name="sortedNodes"> <xsl:for-each select="data/a"> <xsl:sort data-type="number" order="ascending" select="@v"/> <xsl:sort data-type="number" order="ascending" select="@n"/> <xsl:copy-of select="."/> </xsl:for-each> </xsl:variable>
<xsl:template name="write-row"> <xsl:param name="node" select="/.."/> <xsl:param name="n-start"/> <xsl:param name="v"/>
<xsl:choose> <xsl:when test="not($node/following-sibling::a[1])"> <row start="{$n-start}" end="{$node/@n}" v="{$v}"/> </xsl:when> <xsl:when test="$v != $node/following-sibling::a[1]/@v"> <row start="{$n-start}" end="{$node/@n}" v="{$v}"/>
<?xml version="1.0" encoding="UTF-8"?> <data> <row v="1" end="3" start="1"/> <row v="2" end="4" start="4"/> </data>
From: "Midnit" <midnit@xxxxxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: [xsl] Sort, group, flatten, consecutive data Date: Tue, 28 Jun 2005 17:01:18 -0400
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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: [exslt] Re: Re: [xsl] Imp, Dimitre Novatchev | Thread | [xsl] inserting structure, Manfred Staudinger |
[xsl] Re: [exslt] Re: Re: [xsl] Imp, Dimitre Novatchev | Date | [xsl] inserting structure, Manfred Staudinger |
Month |