GNOME Bugzilla – Bug 131971
predicate selection of union gives alternatingly wrong results
Last modified: 2009-08-15 18:40:50 UTC
I discovered this (potential) bug while using slides-3.3 stylesheets for docbook-slides. I was able to do a workaround in the xpath statement which caused the problem, and have isolated the case in an example document and stylesheet. Here is the document text: <?xml version="1.0" encoding="utf-8"?> <document name="doc"> <group name="group"> <page name="1"/> <page name="2"/> <page name="3"/> <page name="4"/> </group> </document> Here is my "stylesheet": <?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:apply-templates select="//page"/> </xsl:template> <xsl:template match="page"> current page : <xsl:value-of select="@name"/> -------------------- dump union : "<xsl:for-each select="(preceding-sibling::page[1]|parent::group[1]|/document)"> <xsl:value-of select="name()"/>,</xsl:for-each>" union-last : <xsl:value-of select="name( (preceding-sibling::page[1]|parent::group[1]|/document)[last()] )"/> union-last (without /root) : <xsl:value-of select="name( (preceding-sibling::page[1]|parent::group[1])[last()] )"/> preceeding-sibling <xsl:value-of select="name(preceding-sibling::page[1])"/> parent-group <xsl:value-of select="name(parent::group[1])"/> root <xsl:value-of select="name(/document)"/> ----------------------- </xsl:template> </xsl:stylesheet> The union-last output demonstrates the problem witnessed in slides. The union-last (without /root) shows my workaround Hopefully its all pretty obvious. Ian
This was caused by an error within libxml2/xpath.c, when the last() function was used in the predicate of a union (XPath context was not being saved during union evaluation). The corrected source is in CVS, and I have also taken the liberty of including your test files as a part of the libxslt regression tests (tests/general/bug-141). Thank you for your report, as well as your excellent analysis and isolation of a rather complicated problem. Bill
This should be closed by release of libxslt-1.1.5, thanks, Daniel