xsl-list
[Top] [All Lists]

[xsl] RE: Sort on multiple key

2008-05-24 10:37:26
Jan, I believe that preceding:: applies to document order, not sort order, so 
this isn't going to work. If you need to group things by keys, and you're stuck 
w/ XSLT 1.0, look up Jeni Tennison's helpful page on Muenchian groupings.

-----Original Message-----
From: Hesselberth, Jan 
[mailto:Jan(_dot_)Hesselberth(_at_)northernrock(_dot_)co(_dot_)uk]
Sent: Tuesday, May 20, 2008 6:15 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Sort on multiple key

I have the xml below which needs to be sorted into key1 key2 order.
I can sort it in key1 order ok but can't get the key2 order. I tried
this but it doesn't work.
I then need to be able to process the sorted xml by element.
Can you tell me where I'm going wrong please.
Regards
        Jan Hesselberth

<xsl:for-each select="SummaryNo/element/key1">
        <xsl:sort select="." order="ascending" data-type="text"/>
        <xsl:for-each select="ancestor::SummaryNo/key2">
                <xsl:sort select="." order="ascending"
data-type="text"/>
                <xsl:for-each select="preceding::element">




<SummaryNo id="123456789">
        <key2>12345K00348</key2>
        <customerName>Investments Limited</customerName>
        <element id="4">
                <key1>2008-04-16</key1>
                <rolloverResult>
                        <errorDescription>calculateInterestCharge
failed</errorDescription>
                </rolloverResult>
        </element>
        <element id="5">
                <key1>2008-04-16</key1>
                <rolloverResult>
                        <errorDescription>calculateInterestCharge
failed</errorDescription>
                </rolloverResult>
        </element>
        <element id="6">
                <key1>2008-04-18</key1>
                <rolloverResult>
                        <errorDescription>calculateInterestCharge
failed</errorDescription>
                </rolloverResult>
        </element>
</SummaryNo>
<SummaryNo id="234567890">
        <key2>56789D00172</key2>
        <customerName>Freds Developments Limited</customerName>
        <element id="4">
                <key1>2008-04-17</key1>
                <rolloverResult>
                        <errorDescription>calculateInterestCharge
failed</errorDescription>
                </rolloverResult>
        </element>
        <element id="5">
                <key1>2008-04-16</key1>
                <rolloverResult>
                        <errorDescription>calculateInterestCharge
failed</errorDescription>
                </rolloverResult>
        </element>
</SummaryNo>
<SummaryNo id="145678999">
        <key2>44551J00106</key2>
        <customerName>Housing Trust Limited</customerName>
        <element id="1">
                <key1>2008-04-16</key1>
                <rolloverResult>
                        <errorDescription>calculateInterestCharge
failed</errorDescription>
                </rolloverResult>
        </element>
        <element id="2">
                <key1>2008-04-15</key1>
                <rolloverResult>
                        <errorDescription>calculateInterestCharge
failed</errorDescription>
                </rolloverResult>
        </element>
        <element id="3">
                <key1>2008-04-17</key1>
                <rolloverResult>
                        <errorDescription>calculateInterestCharge
failed</errorDescription>
                </rolloverResult>
        </element>
</SummaryNo>




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

<Prev in Thread] Current Thread [Next in Thread>