Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 8th, 2005, 11:33 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Advanced Grouping Using the Muenchian Method

Hello all,

I've read this article http://www.jenitennison.com/xslt/grouping/muenchian.xml about the Muenchian Grouping method. However, I'm having a little problem while using the described method. I have an xml file, see below (sorry for the amount of XML!), and an XSLT file (which can be provided if you are interest, but the most important part is typed below) I'd like to use the XML to group by the 'Group' element, but I cannot use the new XSLT 2.0 for grouping.
Using the XML below, I'd like to create 3 different (unique) groups. However, while using this XSL:

Code:
    <xsl:key name="acts-by-group" match="Act" use="Sample/Analysis/Group" />
    <xsl:template match="Result">
        <xsl:for-each select="Act[count(. | key('acts-by-group', Sample/Analysis/Group)[1]) = 1]">
            <xsl:sort select="Sample/Analysis/Group" />
My sorting only works on the first Group in the nested Analysis. I'd like to have it to work on all of them (Group A, Group B (twice) and Group C, creating three unique groups). The resulting HTML should look something like the HTML below.

Any help would be greatly appreciated, cause it's really giving me a headache!! :)

Greetings,

Erik Pragt

-=-=-=-=-=-=-
    XML
-=-=-=-=-=-=-
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="simpleXSL.xsl"?>
<Result>
    <Act>
        <Header>
            <ActivityTime>2005-04-02T13:15:54</ActivityTime>
        </Header>
        <Sample>
            <Name>BL</Name>
            <Analysis>
              <Description>Bezinking 1</Description>
              <AnalysisResult>
                <Value>1</Value>
              </AnalysisResult>
              <Group>Group A</Group>
            </Analysis>
            <Analysis>
              <Description>CRP 1</Description>
              <AnalysisResult>
                <Value>40</Value>
              </AnalysisResult>
              <Group>Group B</Group>
            </Analysis>        
        </Sample>
    </Act>

    <Act>
        <Header>
            <ActivityTime>2004-04-02T11:23:01</ActivityTime>
      </Header>    
        <Sample>
            <Name>BL</Name>
            <Analysis>
              <Description>Bezinking 2</Description>
              <AnalysisResult>
                <Value>10</Value>
              </AnalysisResult>
              <Group>Group B</Group>
            </Analysis>
            <Analysis>
              <Description>CRP 2</Description>
              <AnalysisResult>
                <Value>240</Value>
              </AnalysisResult>
              <Group>Group C</Group>
            </Analysis>            
        </Sample>
    </Act>    
</Result>
-=-=-=-=-=-=-=
     HTML
-=-=-=-=-=-=-=-
Code:
<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Simple xml test</title>
  </head>
  <body>
    <p>
          Patient informatie etc
        </p>
    <table border="1">
      <tr>
        <td>
              Test
            </td><td>
              Materiaal
            </td><td>02-04-2005 13:15</td><td>02-04-2004 11:23</td>
      </tr>
      <tr>
        <td colspan="4">Group A</td>
      </tr>
      <tr>
        <td>Bezinking 2</td><td>BL</td><td>&nbsp;</td><td>1</td>
      </tr>
      <tr>
        <td colspan="4">Group B</td>
      </tr>
      <tr>
        <td>Bezinking 1</td><td>BL</td><td>1</td><td>&nbsp;</td>
      </tr>
      <tr>
        <td>CRP 1</td><td>BL</td><td>40</td><td>&nbsp;</td>
      </tr>
      <tr>
        <td>Bezinking 2</td><td>BL</td><td>1</td><td>&nbsp;</td>
      </tr>
      <br>
      <tr>
        <td colspan="4">Group C</td>
      </tr>
      <tr>
        <td>Bezinking 2</td><td>BL</td><td>&nbsp;</td><td>1</td>
      </tr>
      <br>
    </table>
  </body>
</html>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
help with Muenchian method grouping and html table mickhughes XSLT 3 May 1st, 2008 06:24 AM
help with Muenchian method grouping... agentdz015 XSLT 1 April 7th, 2008 04:53 PM
Muenchian grouping amhicraig XSLT 1 December 5th, 2007 06:43 PM
Muenchian Grouping Chamkaur XSLT 1 June 21st, 2006 10:51 AM
Grouping XML by Muenchian Method - Urgent :-( xrow XSLT 5 September 28th, 2004 04:07 AM



All times are GMT -4. The time now is 05:59 PM.


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