Cannot compile descendant XPath expression generated by CSS selector
Bug #657968 reported by
Martin Aspeli
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Fix Released
|
Medium
|
Unassigned | ||
xdv |
New
|
Undecided
|
Unassigned |
Bug Description
Using this rule:
<drop css:content=
I get this error:
XSLTParseError: xsltCompilePattern : failed to compile '//dl[contains(
This expression would work:
//dl[contains(
To post a comment you must log in.
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 css_to_ xpath(' body a', '//') descendant: :a' '''<xsl: stylesheet version="1.0" xmlns:xsl="http:// www.w3. org/1999/ XSL/Transform"><xsl:template match=" "/></xsl: stylesheet> ''') ()[0] set('match' , match) XSLT.__ init__ (src/lxml/ lxml.etree. c:108752) descendant: :a'
>>> match = cssselect.
>>> match
u'//body/
>>> doc = etree.XML(
>>> template = doc.getchildren
>>> template.
>>> etree.XSLT(doc)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "xslt.pxi", line 399, in lxml.etree.
XSLTParseError: xsltCompilePattern : failed to compile '//body/
I guess we should probably file this as a bug report against lxml.
Laurence