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

Re: Multiple matches against keys?

Subject: Re: Multiple matches against keys?
From: "Ramon M. Felciano @ Yahoo" <felciano@xxxxxxxxx>
Date: Wed, 01 Sep 2004 19:14:33 -0700
multiple yahoo
Kevin Jones wrote:

So it looks like my key definition is no longer picking up "call" as a
valid key item. I'm actually not sure whether I'm using the <xsl:key>
tag correctly here -- will it match and index a single <task> node
multiple times if it contains multiple tags?




I think your problem is that you are passing a nodeset to the key call so that it retruns results from different 'context' sets. This means you can't use the count(.|key(...)[1])=1 trick to isolate the first from a particular 'context'. One way to fix is is to loop both over the 'task' and then the child 'context' elements and apply the same test. Something like this should work,


<xsl:for-each select="/tasks/task">
<xsl:sort select="subject"/>
<xsl:for-each select="context">
 <xsl:if test="count((..|key('tasks-by-context',.)[1]))=1">
  <li>
   CONTEXT: <xsl:value-of select="."/>: (<xsl:value-of
	select="count(key('tasks-by-context',.))"/> tasks)
  </li>
  <ul>
   <xsl:for-each select="key('tasks-by-context', .)">
    <li>
      Task : <xsl:value-of select="subject"/>
    </li>
   </xsl:for-each>
  </ul>
 </xsl:if>
</xsl:for-each>
</xsl:for-each>

Kev.

Hi Kev --

This is almost right -- it gives me the right grouping, but the sort order is wrong. How can I get that outer loop to sort the contexts alphabetically? Do I need to make the outer loop iterate over the sorted contexts first?

Thanks!

Ramon

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.