GNOME Bugzilla – Bug 533334
Wrong conflict resolution for template rules
Last modified: 2021-07-05 11:00:16 UTC
Please describe the problem: xsltproc produces wrong output due to the wrong conflict resolution for template rules. Steps to reproduce: 1. Take the following Stylesheet --- <?xml version="1.0" encoding="UTF-8"?> <!-- transformation of the calloutlist element --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="text()"> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> --- 2. Take the following XML file --- <?xml version="1.0" encoding="UTF-8"?> <winelist> <wine grape="Chardonnay"> <winery>Benziger</winery> <product>Carneros</product> </wine> </winelist> --- 3. Run xsltproc with them. Actual results: xsltproc's output is: --- <?xml version="1.0"?> <winelist> <wine> <winery/> <product/> </wine> </winelist> --- Expected results: The following output is expected: --- <?xml version="1.0" encoding="UTF-8"?><winelist> <wine> <winery>Benziger</winery> <product>Carneros</product> </wine> </winelist> --- Does this happen every time? yes Other information: I uesed libxslt 1.1.23. The described behavior of the xsltproc violates the conflict resolution rule described in the last paragraph of the Chapter 5.5 in the XSL Transformations W3C Specification. Just to be safe I tested the same Stylesheet and XML file with xalanj and 4xslt. All of them produce the expected output.
I confirm this bug. In accordance to "Conflict Resolution for Template Rules" http://www.w3.org/TR/xslt11/#conflict The text() pattern and the node() pattern are the same weight (priority is 0.5), and — "It is an error if this leaves more than one matching template rule, an XSLT processor may signal the error; if it does not signal the error, it must recover by choosing, from amongst the matching template rules that are left, the one that occurs last in the stylesheet" So, XSLT proccesr must either signal error or use a template that occurs last in the stylesheet.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxslt/-/issues/ Thank you for your understanding and your help.