GNOME Bugzilla – Bug 441115
Regression: <template match="...[@attr=$var]">
Last modified: 2007-05-25 17:42:17 UTC
Please describe the problem: libxslt fails to compile a stylesheet that contains a template whose pattern references a variable Steps to reproduce: xsltproc test.xsl test.xml Here's test.xsl: <?xml version="1.0"?> <stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform"> <output method="xml" encoding="UTF-8"/> <variable name="var" select="'val'"/> <template match="element[@attr=$var]">OK</template> </stylesheet> The input test.xml is simply: <?xml version="1.0" encoding="UTF-8"?> <element attr="val"/> Actual results: XPath error : Undefined variable compilation error: file test.xsl line 5 element template Failed to compile predicate Expected results: Should output "OK". According to the XSLT 1.0 Spec, variable references are allowed within a pattern: Pattern -> RelativePathPattern -> StepPattern -> Predicate -> PredicateExpr -> Expr -> OrExpr -> AndExpr -> EqualityExpr -> RelationalExpr -> AdditiveExpr -> MultiplicativeExpr -> UnaryExpr -> UnionExpr -> PathExpr -> FilterExpr -> PrimaryExpr -> VariableReference Does this happen every time? Yes Other information: xsltproc --version says: Using libxml 20627, libxslt 10120 and libexslt 813 xsltproc was compiled against libxml 20627, libxslt 10119 and libexslt 813 libxslt 10120 was compiled against libxml 20627 libexslt 813 was compiled against libxml 20627 This test case worked on libxslt 1.1.12, so the regression was introduced sometime between 1.1.12 and 1.1.19. I suspect that it was broken by Changeset 1330: http://svn.gnome.org/viewcvs/libxslt?view=revision&revision=1330
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. "