|
BOOK: XSLT Programmer's Reference, 2nd Edition | This is the forum to discuss the Wrox book XSLT: Programmer's Reference, 2nd Edition by Michael Kay; ISBN: 9780764543814 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: XSLT Programmer's Reference, 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
November 19th, 2007, 09:18 AM
|
Authorized User
|
|
Join Date: Oct 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Group Within another Group, xslt1.0
Hi Guys,
I am using Meunchian method for grouping, but am failing to group by three columns...
Please suggest me with some solution...
Thanks and regards,
Jhansi
Thanks and Regards,
Jhansi
__________________
Thanks and Regards,
Jhansi
|
November 19th, 2007, 09:29 AM
|
|
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
You need to provide a clearer description of your problem. The subject line suggests it is about nested grouping, the message itself suggests it is about compound grouping keys. The best way to describe your problem is to show its input and desired output.
You also need to show your attempt at a solution. Without this, we can't tell you why it's failing. Showing us your code is the best way for us to see what you already know and what you still need to learn.
All grouping problems, of course, are much easier in XSLT 2.0, so before embarking on a 1.0 solution it's useful to explain why 2.0 isn't an option.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
November 20th, 2007, 05:09 AM
|
Authorized User
|
|
Join Date: Oct 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The Xml is coming some what following manner
<NewDataSet>
- <Customers>
<CompanyName>Cactus Comidas para llevar</CompanyName>
<Country>Argentina</Country>
<City>Buenos Aires</City>
<CustomerID>CACTU</CustomerID>
</Customers>
- <Customers>
<CompanyName>Océano Atlántico Ltda.</CompanyName>
<Country>Argentina</Country>
<City>Buenos Aires</City>
<CustomerID>OCEAN</CustomerID>
</Customers>
- <Customers>
<CompanyName>Rancho grande</CompanyName>
<Country>Argentina</Country>
<City>Buenos Aires</City>
<CustomerID>RANCH</CustomerID>
</Customers>
- <Customers>
<CompanyName>Piccolo und mehr</CompanyName>
<Country>Austria</Country>
<City>Salzburg</City>
<CustomerID>PICCO</CustomerID>
</Customers>
- <Customers>
<CompanyName>Ernst Handel</CompanyName>
<Country>Austria</Country>
<City>Graz</City>
<CustomerID>ERNSH</CustomerID>
</Customers>
- <Customers>
I want the report in the following format
germany-----//Country
Aachen----//City
Drachenblut Delikatessen---//Company
DRACD---//Customers
Company2
customers..
customers..
.
.
.
Berlin
Alfreds Futterkiste
ALFKI
.
.
FRANCE
Paris
Spécialités du monde
SPECD
.
.
.
.
Like wise I want multi level grouping using XSLT1.0
Following is the XSL code
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:key name="group_by_CountryCity" match="Customers" use="concat(Country,City)" />
<xsl:template match="NewDataSet">
<HTML>
<HEAD>
<STYLE>
.HDR { background-color:bisque;font-weight:bold }
TR.clsOdd { background-Color: beige; } TR.clsEven { background-color: #cccccc; }
</STYLE>
</HEAD>
<BODY>
<TABLE BORDER="1">
<TD CLASS="HDR">City</TD>
<TD CLASS="HDR">Country</TD>
<TD CLASS="HDR">Company Name</TD>
<TD CLASS="HDR">Customer</TD>
<xsl:for-each select="Customers[count(. | key('group_by_CountryCity', concat(Country,City))[1]) = 1]">
<TR>
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<xsl:attribute name="class">clsOdd</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">clsEven</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<TD> <xsl:value-of select="Country" /></TD>
<TD>
<xsl:value-of select="City" />
</TD>
<TD>
<TABLE BORDER="1">
<xsl:for-each select="key('group_by_CountryCity', concat(Country,City))">
<TR >
<TD>
<xsl:value-of select="CompanyName" />
</TD>
<TD><xsl:value-of select="CustomerID"/></TD>
</TR>
</xsl:for-each>
</TABLE>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
I have tried with meunchian grouping method but its only working with two level with concat,
but I m not able to implement it. if something can be done using axes then also please suggest.
Thanks and Regards,
Jhansi
|
November 20th, 2007, 12:26 PM
|
|
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Have you tried the approach suggested by Jeni at
http://www.biglist.com/lists/xsl-lis.../msg00070.html
I know it's a bit of a skimpy presentation, but it's more detailed than I've got time for - I'm afraid that grouping using XSLT 1.0 is something that doesn't get me excited.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
November 22nd, 2007, 01:24 AM
|
Authorized User
|
|
Join Date: Oct 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank u... It worked.....
Thanks and Regards,
Jhansi
|
|
|