GNOME Bugzilla – Bug 341870
In scope ns of literal result elements are not always copied to the result
Last modified: 2021-07-05 10:59:45 UTC
In scope namespaces of literal result elements are not always copied to the result. XSLT 1.0 (7.1.1): "The created element node will also have a copy of the namespace nodes that were present on the element node in the stylesheet tree with the exception of..." The current implementation does not keep track of in-scope namespaces of all literal result elements. It seems that a fix for this was already tried: the "inheritedNs" field on a xsltTemplate inserts namespace nodes which were declared in the descendant-or-self axis of an xsl:template. But this does not cover all the cases we need to consider. In the following examples, the result element "bar" needs to have the namespace "urn:test:foo" in scope. Example A --------- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="urn:test:foo"> <xsl:output indent="yes"/> <xsl:template match="/"> <xsl:element name="foo"> <bar/> </xsl:element> </xsl:template> </xsl:stylesheet> Result of Libxslt (error): <?xml version="1.0"?> <foo> <bar/> </foo> Expected result: <?xml version="1.0"?> <foo> <bar xmlns:foo="urn:test:foo"/> </foo> Example B --------- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="urn:test:foo"> <xsl:output indent="yes"/> <xsl:variable name="bar"> <bar/> </xsl:variable> <xsl:template match="/"> <xsl:copy-of select="$bar"/> </xsl:template> </xsl:stylesheet> Result of Libxslt (error): <?xml version="1.0"?> <bar/> Expected result: <?xml version="1.0"?> <bar xmlns:foo="urn:test:foo"/>
Correction: the text "descendant-or-self axis of an xsl:template" should read: "ancestor-or-self axis of an xsl:template"
*** Bug 538941 has been marked as a duplicate of this bug. ***
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.