Re: 2 unique lists

Subject: Re: 2 unique lists
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 07 Aug 2000 23:06:58 +0100
Matt,

>> <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',.)[../@name = current()/@name][1])]">
>>     <xsl:value-of select="."/>
>>     <xsl:if test="not(position()=last())">, </xsl:if>
>>   </xsl:for-each>
>> </xsl:template>
>
>This one didn't seem to work, It threw a SAXException with the message:
>
>* XSL Error: pattern = 'date[generate-id(.) = 
>*		generate-id(key('thedate',.)[../@name = current()/@name][1])]'
>* The current() function is not allowed in a match pattern!, 
>*		source tree node: date
>( indentation and *'s added by me )

That's odd.  It works fine in SAXON 5.4.  What processor are you using?
Looks like a bug: the 'select' attribute on xsl:for-each doesn't take a
match pattern.

You could set a variable to hold the name instead of accessing it within
the XPath (in fact that's what I'd do because for some obscure reason I
don't like using current()):

 <xsl:key name="thedate" match="date" use="."/>
 
 <xsl:template match="person">
   <xsl:variable name="name" select="@name" />
   <xsl:value-of select="$name"/><xsl:text>: </xsl:text>
   <xsl:for-each select="date[generate-id(.) =
 generate-id(key('thedate',.)[../@name = $name][1])]">
     <xsl:value-of select="."/>
     <xsl:if test="not(position()=last())">, </xsl:if>
   </xsl:for-each>
 </xsl:template>

That *should* work.

Hope it does,

Jeni

Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx


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


Current Thread