Subject: Re: [xsl] Yet another grouping question From: "M. David Peterson" <m.david@xxxxxxxxxx> Date: Thu, 16 Sep 2004 01:27:04 -0700 |
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="indexItem" mode="level-two"> <secondary name="{@secondary}" /> </xsl:template>
<?xml version="1.0" encoding="UTF-8"?> <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"> <secondary name=""/> </primary> </index>
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Checking from browser, Josh Canfield | Thread | RE: [xsl] Yet another grouping ques, Andrew Welch |
Re: [xsl] Yet another grouping ques, cking | Date | [xsl] Checking from browser, Francisco Perez |
Month |