GNOME Bugzilla – Bug 581310
Entities that expand to <xsl:text>...</xsl:text> don't work
Last modified: 2021-07-05 10:59:16 UTC
I'm using the following xsl as a test file: <!DOCTYPE xsl:stylesheet [ <!ENTITY CR "
" > <!ENTITY tCR "<xsl:text>&CR;</xsl:text>" > ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="test"> <testOut> The Spanish word for "Spain" is: "Espana".&tCR; <xsl:apply-templates/> </testOut> </xsl:template> </xsl:stylesheet> It contains a carriage return entity and another entity with the tag xsl:text. When using xsltproc to compile the following xml test file: <?xml version="1.0" ?> <test></test> It doesn't take the tCR entity into account. And actually it prints a warning for every entities that are using <xsl:text> as: namespace error : Namespace prefix xsl on text is not defined <xsl:text>&CR;</xsl:text> ^ I have only tested with version 1.1.24.
yes that's a libxml2 problem. Basically the entities are parsed out of the context and the namespace declaration for the xsl prefix doesn't exist. Namespace and entities do not mix well Please note the following: <!DOCTYPE foo [ <!ENTITY CR "
" > <!ENTITY tCR "<xsl:text>&CR;</xsl:text>" > ]> <foo> <test xmlns:xsl="bar">&tCR;</test> <test xmlns:xsl="foo">&tCR;</test> </foo> Here the namespace for the 2 entities replacement should be different. libxml2 was designed for XML edititing, including entities content. At the time of XML-1.0 when it was designed namespaces didn't exist, and the content model for en entity replacement tree would be the same wherever in the tree. Namespace broke that, after the design. Best solution is to never allow indeterminims when defining entities in your case it's trivial, just put the namespace definition in your entity: <!ENTITY tCR "<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >&CR;</xsl:text>" I don't think I will rewrite the entity layer of libxml2 to cope with this, so it's unlikely to get fixed anytime soon. Daniel
Thanks for the valuable information!
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.