Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Multiple matches against keys?

From: "Vasu Durgavarjhula" <vasud@------------->
To:
Date: 9/2/2004 2:37:00 AM
You could use the distinct function if libxslt supports it to first get the
list of distinct context elements sorted on the context element and then for
each context element, do what you are doing.

<!- iterate over each distinct context in sorted order ->
<xsl:for-each select="distinct(//context)">
 <xsl:sort select="."/>

   <xsl:variable name="contextVal" select="."/>
   <li>
    CONTEXT: <xsl:value-of select="$contextVal"/>: (<xsl:value-of
	select="count(key('tasks-by-context',$contextVal))"/> tasks)
   </li>
   <ul>
    <xsl:for-each select="key('tasks-by-context', $contextVal)">
     <li>
       Task : <xsl:value-of select="subject"/>
     </li>
    </xsl:for-each>
   </ul>

</xsl:for-each>

-Vasu

-----Original Message-----
From: Ramon M. Felciano @ Yahoo [mailto:felciano@xxxxxxxxx]
Sent: Wednesday, September 01, 2004 7:15 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Multiple matches against keys?


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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent