xsl-list
[Top] [All Lists]

RE: last() and distinct-values 2.0

2004-10-26 01:39:46
You appear to have found a Saxon bug. I'll look into it.

Note that there is no need to use a namespace with the distinct-values()
function in XSLT, any more than you need a namespace with position() and
last() - and it's better not to use the namespace, because it is still
changing in each draft.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Jurn Ho [mailto:jurn(_at_)magicmonster(_dot_)com] 
Sent: 26 October 2004 03:09
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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>


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





<Prev in Thread] Current Thread [Next in Thread>