After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 318005 - Can't resolve global parameters as XPath variable references
Can't resolve global parameters as XPath variable references
Status: VERIFIED NOTABUG
Product: libxslt
Classification: Platform
Component: general
1.1.15
Other Linux
: Normal major
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2005-10-05 11:20 UTC by Mikhail Zabaluev
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The stylesheet (981 bytes, text/xml)
2005-10-05 11:22 UTC, Mikhail Zabaluev
Details
The source file (5.22 KB, text/xml)
2005-10-05 11:23 UTC, Mikhail Zabaluev
Details
Stripped down stylesheet (240 bytes, text/xml)
2005-11-24 22:33 UTC, Mikhail Zabaluev
Details
Stripped down source file (38 bytes, text/xml)
2005-11-24 22:33 UTC, Mikhail Zabaluev
Details

Description Mikhail Zabaluev 2005-10-05 11:20:48 UTC
A command over the attached stylesheet and source file produces errors:

$ xsltproc --output rcp.list --stringparam eclipse-home /usr/lib/eclipse
--stringparam os linux --stringparam ws gtk --stringparam arch x86
eclipse-list-feature-plugins.xsl feature.xml
XPath error : Undefined variable
compilation error: file /home/mhz/RPM/SOURCES/eclipse-list-feature-plugins.xsl
line 24 element template
Failed to compile predicate
XPath error : Undefined variable
compilation error: file /home/mhz/RPM/SOURCES/eclipse-list-feature-plugins.xsl
line 24 element template
Failed to compile predicate
XPath error : Undefined variable
compilation error: file /home/mhz/RPM/SOURCES/eclipse-list-feature-plugins.xsl
line 24 element template
Failed to compile predicate
Comment 1 Mikhail Zabaluev 2005-10-05 11:22:02 UTC
Created attachment 53051 [details]
The stylesheet
Comment 2 Mikhail Zabaluev 2005-10-05 11:23:26 UTC
Created attachment 53052 [details]
The source file
Comment 3 Mikhail Zabaluev 2005-11-24 22:33:08 UTC
Created attachment 55202 [details]
Stripped down stylesheet
Comment 4 Mikhail Zabaluev 2005-11-24 22:33:52 UTC
Created attachment 55203 [details]
Stripped down source file
Comment 5 Mikhail Zabaluev 2005-11-24 22:41:03 UTC
Maybe I forgot to mention that xsltproc worked on these same stylesheets before
1.1.15.
Comment 6 Mikhail Zabaluev 2005-11-24 22:43:33 UTC
Here's the output -v gets on the minimal files:

creating dictionary for stylesheet
reusing dictionary from libxslt-faulty-xpath.xsl for stylesheet
Added namespace: xsl mapped to http://www.w3.org/1999/XSL/Transform
xsltParseStylesheetProcess : found stylesheet
xsltPrecomputeStylesheet: removing ignorable blank node
Registering global variable a
Defining global variable a
xsltCompilePattern : parsing 'foo[. = $a]'
XPath error : Undefined variable
compilation error: file libxslt-faulty-xpath.xsl line 7 element template
Failed to compile predicate
xsltCompilePattern : parsed foo[. = $a], default priority 0.500000
added pattern : 'foo[. = $a]' priority 0.500000
parsed 1 templates
freeing dictionary from stylesheet
Comment 7 Daniel Veillard 2005-12-10 16:59:16 UTC
<xsl:template match="foo[. = $a]">

It's forbidden to reference variables in a match pattern.
Libxslt used to not check this, it rightly raise an error now.

  Not a bug,

Daniel
Comment 8 haui 2007-06-03 13:55:46 UTC
Hi Daniel,

can you please explain, why you think that's forbidden to reference a variable from a match pattern? From the pattern rule

  http://www.w3.org/TR/xslt#NT-Pattern

it's easy to derive the pattern "foo[. = $a]" of this example, as can be seen below. I can't find any hint in the spec that otherwise forbids variable references in patterns. And, by the way, the current Xalan transformer (2.7.0) does things "right" with vars in pattern. 

Of cause, only globally defined vars and params are visible for the match, but those are, as the spec explicitly says in "11.4 Top-level Variables and Parameters": "A top-level variable-binding element declares a global variable that is visible everywhere."


Derivation of the "problematic" pattern:

Pattern
LocationPathPattern
RelativePathPattern
StepPattern
ChildOrAttributeAxisSpecifier NodeTest Predicate*
'child::foo' Predicate
'child::foo[' PredicateExpr ']'
'child::foo[' Expr ']'
'child::foo[' Expr ']'
'child::foo[' OrExpr ']'
'child::foo[' AndExpr ']'
'child::foo[' EqualityExpr ']'
'child::foo[' EqualityExpr '=' RelationalExpr ']'
'child::foo[' RelationalExpr '=' RelationalExpr ']'
'child::foo[' AdditiveExpr '=' AdditiveExpr ']'
'child::foo[' MultiplicativeExpr '=' MultiplicativeExpr ']'
'child::foo[' UnaryExpr '=' UnaryExpr ']'
'child::foo[' UnionExpr '=' UnionExpr ']'
'child::foo[' PathExpr '=' PathExpr ']'
'child::foo[' PathExpr '=' PathExpr ']'
'child::foo[' LocationPath '=' FilterExpr ']'
'child::foo[' RelativeLocationPath '=' VariableReference ']'
'child::foo[' Step '=' VariableReference ']'
...
'child::foo[ . = $a ]'
Comment 9 William M. Brack 2007-06-03 17:18:20 UTC
Reference XSLT spec 5.3 [Defining Template Rules]
"A template rule is specified with the xsl:template element. The match
attribute is a Pattern that identifies the source node or nodes to which the
rule applies. The match attribute is required unless the xsl:template element
has a name attribute (see [6 Named Templates]). It is an error for the value of
the match attribute to contain a VariableReference. "

Also see http://bugzilla.gnome.org/show_bug.cgi?id=441115
Comment 10 haui 2007-06-03 17:50:48 UTC
Thank's for the clarification. This side note is hard to find - I even would opt against implementing it... :-)

Bernhard