XSLT processing error: global variables not seen in predicates

Bug #372153 reported by Yuri Baranov
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libxslt (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: libxslt1.1

It seems that xslt processing engine could not see global variables inside xsl predicates' conditions.
(See attached file xsltprocbug1.xsl)

Running
$xsltproc xsltprocbug1.xsl xsltprocbug1.xsl
gives the following output:
-----cut-----
XPath error : Undefined variable
compilation error: file xsltprocbug1.xsl line 4 element template
Failed to compile predicate
-----cut-----

Line 4 just references a global variable, defined earlier inside a predicate
4: <xsl:template match="*[.=$hello]">

Similar behavior occurs when I am using libxslt from my own application.

NB: When using global variable outside the predicate, like in <xsl:value-of select="$hello" />, the processor gives no complaints.

Other XSLT processors,e.g. xalan do process this example template without reporting any errors.

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 9.04
Package: libxslt1.1 1.1.24-2ubuntu2
ProcEnviron:
 LANGUAGE=en_US:en
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: libxslt
Uname: Linux 2.6.28-11-generic i686

Revision history for this message
Yuri Baranov (baranov) wrote :
Revision history for this message
Jurjen Oskam (jurjeno) wrote :

According to http://bugzilla.gnome.org/show_bug.cgi?id=303289 the behaviour you see is correct, because the standard doesn't allow for variables in the match attribute.

(Note that I'm an xml/xslt newbie, and I may very well be wrong. The description of the bug is awfully similar though.)

Revision history for this message
Yuri Baranov (baranov) wrote :

Thank you, Jurjen!
This is quite an unituitive feature of XSLT - forbidding any variable reference in match attribute.
I should have looked up the specification myself, sorry!

Obviously, xalan & some other processors silently extend the specification, while xsltproc/libxslt sticks to it.

It would be nice, if xslt could emit a more user-friendly message, though. Something like
'variable references are prohibited in match attributes' rather than 'undefined varibale',
which leads to misunderstanding.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.