This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Acheiving ..2nd level grouping but with differentnode structure ..
- From: "KUMAR NINGASHETTY" <kningashetty at deltafunding dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 24 Jul 2002 13:39:45 -0400
- Subject: Re: [xsl] Acheiving ..2nd level grouping but with differentnode structure ..
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Jenni
Thank you so much for the solution while i was away.... I think there is one more problem in this ..correct me if i am wrong ..
It can only pull data from a <uwr> nodeset only and not from <arr> .
I had done something similar to group by regions and when i had used concatenation it was pulling only one set ..No doubt it
groups by Regions and Users within regions .But how will i display matching users belonging to <ARR> nodeset along the same
lines as the same users found in <UWR> node set ..Please advise ..
I have writting the following XSL with your solution and needs a way to get users from other sibling Nodeset like <ARR>
_______________________XSL________________________________________________
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:key name="distinct-region" match="*" use="@reg"/>
<xsl:key name="distinct-reg-user" match="*" use="concat(@userid, '+', @reg)"/>
<xsl:key name="distinct-user" match="*" use="@userid"/>
<xsl:template match="/">
<HTML><BODY>
<table>
<xsl:for-each select="/*/los[@reg][generate-id()=generate-id(key('distinct-region', @reg))]">
<tr>
<td><xsl:value-of select="@reg"/> </td>
<table>
<xsl:for-each select="key('distinct-region', @reg)[generate-id()=generate-id(key('distinct-reg-user',concat(@userid, '+', @reg)))]">
<tr>
<td> <xsl:value-of select="review[@type='N']"/></td>
<td> <xsl:value-of select="review[@type='Y']"/></td>
<!-- So From here how do i get same 'users' from <ARR> which is a sibling of this -->
</tr>
</xsl:for-each>
</table>
</tr>
</xsl:for-each>
</table>
</BODY></HTML>
</xsl:template>
</xsl:stylesheet>
XML_________AND EXPECTED RESULT ARE BELOW FOR UR REFERENCE__________
<rep>
<uwr>
<los userid="1014" reg="Region 4">
<review type="N"><![CDATA[11]]></review>
<review type="Y"><![CDATA[16]]></review>
</los>
<los userid="1017" reg="Region 4">
<review type="N"><![CDATA[7]]></review>
<review type="Y"><![CDATA[17]]></review>
</los>
<los userid="1025" reg="Region 2">
<review type="N"><![CDATA[13]]></review>
<review type="Y"><![CDATA[12]]></review>
</los>
</uwr>
<arr>
<los userid="1014" reg="Region 4">
<review type="N"><![CDATA[15]]></review>
<review type="Y"><![CDATA[19]]></review>
</los>
<los userid="1017" reg="Region 4">
<review type="N"><![CDATA[20]]></review>
<review type="Y"><![CDATA[22]]></review>
</los>
<los userid="1025" reg="Region 2">
<review type="N"><![CDATA[23]]></review>
<review type="Y"><![CDATA[25]]></review>
</los>
</arr>
</rep>
____________________________________
Region 4
Userid UWR(n) UWR(Y) ARR(N) ARR(Y)
1014 11 16 15 19
1017 7 17 20 22
Region 2
Userid UWR(n) UWR(Y) ARR(N) ARR(Y)
1025 13 12 23 25
Thanks for your time
- kumar
>>> jeni@jenitennison.com 07/24/02 09:19AM >>>
Hi Kumar,
> Here is my XSL with first level grouping extracting distinct regions
> and i am having problems grouping users within Region .
The secret of 2nd level grouping with the Muenchian method is to
create keys that combine the two things that you want to group by.
Your first level key is:
<xsl:key name="distinct-region" match="*" use="@reg"/>
(Though I think it would be better as:
<xsl:key name="distinct-region" match="los" use="@reg"/>
since that would limit it to only holding los elements.)
So your second level key should be something along the lines of:
<xsl:key name="distinct-region-and-user" match="los"
use="concat(@reg, '+', @user)" />
Then, given that you've found a region ($reg), you can get all the
unique users in that region with:
key('distinct-region', $reg)
[generate-id() =
generate-id(key('distinct-region-and-user',
concat($reg, '+', @user)))]
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list