|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
RE: last() and distinct-values 2.0
Subject: RE: last() and distinct-values 2.0
From: Jurn Ho <jurn@xxxxxxxxxxxxxxxx>
Date: Wed, 27 Oct 2004 13:30:09 +1000
|
Hi Michael,
Thanks for that. I tried your suggested workaround and everything is great.
I was playing with namespaces before because I was wondering why the
distinct-nodes function wasn't found (I realise now it only existed in a
draft 2.0 spec).
glad I could help bug hunting.
cya,
Jurn
At 08:58 AM 27/10/2004, Michael Kay wrote:
I have now solved this bug: it's rather subtle. I won't be publishing a
source fix because it's too extensive. As a circumvention, it will probably
work if you put the results of distinct-values() in a variable.
Details of the bug are at
http://sourceforge.net/tracker/index.php?func=detail&aid=1054919&group_id=29
872&atid=397617
Sorry about the inconvenience.
Michael Kay
> -----Original Message-----
> From: Jurn Ho [mailto:jurn@xxxxxxxxxxxxxxxx]
> Sent: 26 October 2004 03:09
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: last() and distinct-values 2.0
>
> Hi,
>
> I'm trying to change our stylesheets over to 2.0 and saxon 8, but am
> getting confused about the behaviour of the last() function.
> My test case is below, it has a variable called $languages, with many
> <lang> elements.
> I wanted to get the 3 distinct languages from there.
> If I comment out the last() function, it works as I expect,
> but when I add
> the last() function inside the for-each loop I get it
> returning '2', and
> only get 1 iteration from the loop.
> I expect the last() function to return 3.
>
> Any suggestions/hints would be welcome
>
> thanks,
> Jurn
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fn="http://www.w3.org/2003/11/xpath-functions">
> <xsl:template match="/">
> <xsl:variable name="languages">
> <lang>English</lang>
> <lang>English</lang>
> <lang>Chinese</lang>
> <lang>French</lang>
> <lang>French</lang>
> <lang>Chinese</lang>
> <lang>French</lang>
> <lang>Chinese</lang>
> </xsl:variable>
> <xsl:for-each select="fn:distinct-values($languages/lang)">
> <xsl:value-of select="position()"/>,
> <xsl:value-of select="."/>,
> <xsl:value-of select="last()"/>
> --
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>

|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
| RSS 2.0 |
|
| Atom 0.3 |
|
|