GNOME Bugzilla – Bug 308441
namespaced parameters become unregistered
Last modified: 2006-07-14 16:25:03 UTC
Consider XSLT code with the namespaced parameter "p:param": [code] <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:p="p:p:p"> <xsl:template match="/"> <x> <xsl:apply-templates select="*"> <xsl:with-param name="p:param" select="'value'"/> </xsl:apply-templates> </x> </xsl:template> <xsl:template match="*"> <xsl:param name="p:param"/> <z p="{$p:param}"/> </xsl:template> </xsl:stylesheet> [/code] I use xsltproc built from CVS, 20 June: [screen] $ ~/p/libxml/bin/xsltproc -V Using libxml 20619-CVS2464, libxslt 10114-CVS1014 and libexslt 812-CVS1014 xsltproc was compiled against libxml 20619, libxslt 10114 and libexslt 812 libxslt 10114 was compiled against libxml 20619 libexslt 812 was compiled against libxml 20619 [/screen] It incorrectly issues a warning and generates the following: [screen] $ ~/p/libxml/bin/xsltproc test.xsl test.xsl runtime error: file test.xsl line 13 element z unregistered variable param xmlXPathCompiledEval: evaluation failed <?xml version="1.0"?> <x xmlns:p="p:p:p"><z p="runtime error"/></x> [/screen] xsltproc 1.0.32 and Saxon produce the correct result: [screen] $ xsltproc test.xsl test.xsl <?xml version="1.0"?> <x xmlns:p="p:p:p"><z p="value"/></x> [/screen]
This is a bug. @name of xsl:param is a QName. In "2.4 Qualified Names" it reads: "a variable or a parameter (see [11 Variables and Parameters]) is specified as a QName. If it has a prefix, then the prefix is expanded into a URI reference using the namespace declarations in effect on the attribute in which the name occurs." Does someone know if Libxslt does not support resolution to qualified names (prefixed)? Or is this an edge-case phenomenon? Is this related to the Libxml2/XPath side or Libxslt?
The the namespace name string is missed to be dicted in the following functions: xsltWithParamComp() - xsl:with-param xsltCallTemplateComp() - xsl:call-template xsltParamComp() - xsl:param Thus the pointer comparison of namespaces names in xsltStackLookup() (variables.c) fails to recognize the parameter. Since the namespace name coming from the XPath variable lookup will never be from a dict (it's the ns->href of a namespace declaration), there will always be some speed penalty for namespaced vars/params, since this namespace name is dicted at lookup time.
Fixed in CVS HEAD. Thanks for the report!