Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: XSLT Programmer's Reference, 2nd Edition
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 19th, 2007, 08:18 AM
Authorized User
 
Join Date: Oct 2007
Location: Hyderabad, Andhra Pradesh, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
  #2 (permalink)  
Old November 19th, 2007, 08:29 AM
mhkay's Avatar
Wrox Author
Points: 17,770, Level: 58
Points: 17,770, Level: 58 Points: 17,770, Level: 58 Points: 17,770, Level: 58
Activity: 62%
Activity: 62% Activity: 62% Activity: 62%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,838
Thanks: 0
Thanked 267 Times in 262 Posts
Default

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
  #3 (permalink)  
Old November 20th, 2007, 04:09 AM
Authorized User
 
Join Date: Oct 2007
Location: Hyderabad, Andhra Pradesh, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
  #4 (permalink)  
Old November 20th, 2007, 11:26 AM
mhkay's Avatar
Wrox Author
Points: 17,770, Level: 58
Points: 17,770, Level: 58 Points: 17,770, Level: 58 Points: 17,770, Level: 58
Activity: 62%
Activity: 62% Activity: 62% Activity: 62%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,838
Thanks: 0
Thanked 267 Times in 262 Posts
Default

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
  #5 (permalink)  
Old November 22nd, 2007, 12:24 AM
Authorized User
 
Join Date: Oct 2007
Location: Hyderabad, Andhra Pradesh, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank u... It worked.....

Thanks and Regards,
Jhansi
Closed Thread


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Restart new group number in Group Footer sukarso Crystal Reports 2 October 13th, 2006 12:11 PM
Group BY edwarjw Crystal Reports 0 June 13th, 2006 01:17 PM
Group by , Sub Group by and Sum mateenmohd SQL Server 2000 1 March 29th, 2005 08:51 AM
Group edramail Crystal Reports 0 May 18th, 2004 05:51 AM
GROUP BY... then sub group? mr.smith Classic ASP Basics 8 November 26th, 2003 08:40 PM



All times are GMT -4. The time now is 02:05 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.