GNOME Bugzilla – Bug 538905
windows version only: strange error trasforming with libxml2 2.6.32+
Last modified: 2021-07-05 11:00:32 UTC
When i transform (xsltproc) this banal xml --- begin "a.xml" --- <?xml version="1.0"?> <root/> --- end "a.xml" --- with this simple xslt --- begin "b.xslt" --- <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="root"> <xsl:variable name="new_element_name" select="'new_root'"/> <xsl:element name="{$new_element_name}"/> </xsl:template> <xsl:template match="no_element"> <xsl:if test="1"> <xsl:element name="no_new_element"> <xsl:if test="0"/></xsl:element> </xsl:if> </xsl:template> </xsl:stylesheet> --- end "b.xslt" --- and i use the latest windows (Zlatkovic) versions of libxml2 (2.6.32+) and libxslt/xsltproc (1.1.23+), i obtain the following error --- begin output with libxslt2 2.6.32+ --- runtime error: file b.xslt line 7 element element Variable 'new_element_name' has not been declared. xmlXPathCompiledEval: evaluation failed runtime error: file b.xslt line 7 element element xsl:element: The attribute 'name' is missing. no result for a.xml --- end output with libxslt2 2.6.32+ --- Apparently this problem is a 'libxml2' problem because when i use the preceding windows version (2.6.30), the problem disappear. On the contrary, i obtain the same error, with libxml2 2.6.32+, even with libxslt/xsltproc 1.1.22, 1.1.19, 1.1.17, 1.1.16 and 1.1.15+. --- begin output with libxslt2 2.6.30 --- <?xml version="1.0"?> <new_root/> --- end output with libxslt2 2.6.32+ --- The eccentric part of this problem is that it disapper even if you delete or modify (the indentation spaces are significant) the unused (?) "no_element" template. I add the verbose outputs ("xsltproc --verbose b.xslt a.xml") --- begin verbose output with libxslt2 2.6.32+ --- creating dictionary for stylesheet reusing dictionary from b.xslt for stylesheet xsltParseStylesheetProcess : found stylesheet xsltPrecomputeStylesheet: removing ignorable blank node xsltCompilePattern : parsing 'root' xsltCompilePattern : parsed root, default priority 0.000000 added pattern : 'root' priority 0.000000 xsltCompilePattern : parsing 'no_element' xsltCompilePattern : parsed no_element, default priority 0.000000 added pattern : 'no_element' priority 0.000000 parsed 2 templates Resolving attribute sets references Creating sub-dictionary from stylesheet for transformation Registered 0 modules reusing transformation dict for output Registering global variables Registering global variables from b.xslt xsltProcessOneNode: no template found for / xsltProcessOneNode: applying template 'root' for root Registering variable 'new_element_name' Building variable new_element_name select 'new_root' Evaluating variable 'new_element_name' Object is a string : new_root Lookup variable 'new_element_name' global variable not found new_element_name variable not found 'new_element_name' runtime error: file b.xslt line 7 element element Variable 'new_element_name' has not been declared. xmlXPathCompiledEval: evaluation failed xsltEvalXPathString: returns (null) xsltEvalAttrValueTemplate: {$new_element_name} returns (null) runtime error: file b.xslt line 7 element element xsl:element: The attribute 'name' is missing. freeing transformation dictionary no result for a.xml freeing dictionary from stylesheet --- end verbose output with libxslt2 2.6.32+ --- --- begin verbose output with libxslt2 2.6.30 --- creating dictionary for stylesheet reusing dictionary from b.xslt for stylesheet xsltParseStylesheetProcess : found stylesheet xsltPrecomputeStylesheet: removing ignorable blank node xsltCompilePattern : parsing 'root' xsltCompilePattern : parsed root, default priority 0.000000 added pattern : 'root' priority 0.000000 xsltCompilePattern : parsing 'no_element' xsltCompilePattern : parsed no_element, default priority 0.000000 added pattern : 'no_element' priority 0.000000 parsed 2 templates Resolving attribute sets references Creating sub-dictionary from stylesheet for transformation Registered 0 modules reusing transformation dict for output Registering global variables Registering global variables from b.xslt xsltProcessOneNode: no template found for / xsltProcessOneNode: applying template 'root' for root Registering variable 'new_element_name' Building variable new_element_name select 'new_root' Evaluating variable 'new_element_name' Object is a string : new_root Lookup variable 'new_element_name' xsltEvalXPathString: returns new_root xsltEvalAttrValueTemplate: {$new_element_name} returns new_root freeing transformation dictionary <?xml version="1.0"?> <new_root/> freeing dictionary from stylesheet --- end verbose output with libxslt2 2.6.30 ---
Created attachment 112962 [details] the xml file (a.xml)
Created attachment 112963 [details] the xslt file (b.xslt)
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.