This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Getting the Keys right for 2nd level grouping
- From: "KUMAR NINGASHETTY" <kningashetty at deltafunding dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 23 Jul 2002 12:01:06 -0400
- Subject: [xsl] Getting the Keys right for 2nd level grouping
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi everybody ...
I didnt really verify if this was discussed earlier coz i am in a hurry .But I am half way through solving a problem and some small
hint will do .
Here is my XSL with first level grouping extracting distinct regions and i am having problems grouping users with Region Nodeset.
Any help appreciated .
Following is XSL (presently pulling distinct regions ) .. an Examle XML and expected result .
Note : I applied Keys to do 2nd level for users but i was able to pull out only 1 row in each region where as
there are many userid's as shown below.
_______________My XSL _____________________
<xsl:key name="distinct-region" match="*" use="@reg"/>
<xsl:template match="/">
<xsl:for-each select="rep/uwr/los[@reg][generate-id()=generate-id(key('distinct-region', @reg))]">
<xsl:value-of select="@reg"/>
</xsl:for-each>
</xsl:template>
_________________XML______________________________
<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>
____________Expected Result__________________________
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
- Kumar
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list