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

Re: 2 unique lists

Subject: Re: 2 unique lists
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 07 Aug 2000 23:06:58 +0100
Re: 2 unique lists
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

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.