GNOME Bugzilla – Bug 171488
position()=last() not working as expected on v10112
Last modified: 2009-08-15 18:40:50 UTC
Please describe the problem: position()=last() not working as expected when using Mac OS X binary distribution of libxslt v10112 and libxml v20615 or Windows binary distribution of libxslt (same libxslt version, different libxml--20617). for comparison, position()=last() detection is working as expected when using other xslt processors including sablotron, xalan, and saxon. Steps to reproduce: 1.Given the following input file: <orderedlist numeration="arabic" spacing="normal" inheritnum="ignore" continuation="restarts"><listitem><para>test</para></listitem> <listitem><para>test</para></listitem> <listitem><para>test</para></listitem></orderedlist> and following xsl:template <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" /> <!--match first element of last item of any orderedlist--> <xsl:template match="orderedlist/listitem[position()!=1][position()=last()]/* [1]"><xsl:text>First element of last item of orderedlist</xsl:text><xsl:copy><xsl:apply-templates select="@*|node ()"/></xsl:copy> </xsl:template> </xsl:template> </xsl:stylesheet> I expect to get: <?xml version="1.0"?> test test First para of last item of orderedlist<para>test</para> But the template does not match at all so i just get test test test 2. As a point of contrast, the pattern above In contrast does work as i expected in sablotron, xalan, and saxon. If i remove the "/*[1]" from the template, i.e. change <xsl:template match="orderedlist/listitem[position()!=1][position()=last()]/* [1]"> to <xsl:template match="orderedlist/listitem[position()!=1][position()=last()]"> the pattern matches, though it is now a different pattern and does not insert the marker where i want it to be. Actual results: The output is: test test test Expected results: output should be: test test First para of last item of orderedlist<para>test</para> Other xlst processors are outputting that. Does this happen every time? Yes Other information: Yes, thanks for the help you are providing to me and all other comers! It is very much appreciated.
Okay, fixed in CVS, as far as I can tell this bug has been there forever ! I added your test to libxslt regression suite, thanks a lot, Daniel
This should be closed by release of libxslt-1.1.15 thanks, Daniel