This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: 2 unique lists


> 
> 	 and from this I want two unique lists of dates, thus 
> 
> 	 person1: Feb2000, Mar2000, Apr2000.
> 	 person2: Feb2000, Mar2000, Apr2000.
> 
> 	 Here is the first stylesheet, using preceding:
> 
> <xsl:template match="person">
>   <xsl:value-of select="@name"/><xsl:text>: </xsl:text>
>   <xsl:for-each select="date[ not( . = preceding::date )]">
>     <xsl:value-of select="."/>
>     <xsl:if test="not(position()=last())">, </xsl:if>
>   </xsl:for-each>
> </xsl:template>
> 
> which produces: 
> 				person1: feb2000, mar2000, Apr2000
>         person2: 

you want preceding-sibling::date

> 
> 
> I also tried the key method:
> <xsl:key name="thedate" match="date" use="."/>
> 
> <xsl:template match="person">
>   <xsl:value-of select="@name"/><xsl:text>: </xsl:text>
>   <xsl:for-each select="date[generate-id(.) = 
> generate-id(key('thedate',.)[1])]">
>     <xsl:value-of select="."/>
>     <xsl:if test="not(position()=last())">, </xsl:if>
>   </xsl:for-each>
> </xsl:template>
> 
> which produced the same result.

You need the key value to idendify not only the date, but also the parent
element. So try <xsl:key name="thedate" match="date"
use="concat(generate-id(..), .)"/>

Mike Kay
 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]