xdv

Comment 1 for bug 657968

Revision history for this message
Laurence Rowe (lrowe) wrote :

xsl:template match is more restrictive than plain xpath: http://www.w3.org/TR/xslt#Patterns
"The syntax for patterns is a subset of the syntax for expressions. In particular, location paths that meet certain restrictions can be used as patterns."
"A Pattern is a set of location path patterns separated by |. A location path pattern is a location path whose steps all use only the child or attribute axes. Although patterns must not use the descendant-or-self axis, patterns may use the // operator as well as the / operator."

A minimal test case here would be "body a":

>>> from lxml import etree, cssselect
>>> match = cssselect.css_to_xpath('body a', '//')
>>> match
u'//body/descendant::a'
>>> doc = etree.XML('''<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match=""/></xsl:stylesheet>''')
>>> template = doc.getchildren()[0]
>>> template.set('match', match)
>>> etree.XSLT(doc)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "xslt.pxi", line 399, in lxml.etree.XSLT.__init__ (src/lxml/lxml.etree.c:108752)
XSLTParseError: xsltCompilePattern : failed to compile '//body/descendant::a'

I guess we should probably file this as a bug report against lxml.

Laurence