[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Yet another grouping question

Subject: Yet another grouping question
From: Shawn McKenzie <smckenzie23@xxxxxxxxx>
Date: Wed, 15 Sep 2004 21:26:31 -0700
shawn mckenzie
So I've gone through the 'XSLT Questions and Answers' and Jeni's site
and it is still not clear to me why my Muenchien grouping isn't
working. Specificaly, the step related to limiting responses to the
first in the group.

Imagine I have an XML file like this:

<indexRoot>
  <indexItem primary="ide" secondary="object repository"/>
  <indexItem primary="ide" secondary="Project Manager"/>
  <indexItem primary="ide" secondary="Code Editor"/>
  <indexItem primary="projects" secondary="type of"/>
  <indexItem primary="projects" secondary="additional projects"/>
  <indexItem primary="unmanaged code"/>
</indexRoot>


I would like to group it something like:


      <index>
           <primary name="ide">
                 <secondary name="object repository"/>
                 <secondary name="Project Manager"/>
                 <secondary name="Code Editor"/>
           </primary>
           <primary name="projects">
                 <secondary name="type of"/>
                 <secondary name="additional projects"/>
           </primary>
           <primary name="unmanaged code"/>
      </index>

I have defined a key like this:

 <xsl:key name="index-by-primary" match="indexItem" use="@secondary" />

When I try to get the first with something like:

 <xsl:for-each select="indexItem[count(. | key('index-by-primary',
@primary)[1]) = 1]">
    <xsl:message>
       <xsl:value-of select="@primary"/>, <xsl:value-of select="@secondary"/>
    </xsl:message>
  </xsl:for-each>

I get a message for every indexItem, not just the first of each unique
@secondary.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.