SelectorSyntaxError elements with name E in any namespace *|E
Jack Bates <89pk5c <at> nottheoilrig.com>
2012-08-06 06:19:46 GMT
Hi, I love lxml, thanks for the hard work
I just tried "sel = CSSSelector('*|Content')" with the latest lxml
release (2.3.5) and got the exception at the bottom of this message
I checked the CSS specification and it discusses selectors of this
format [1][2]
> ns|E
> elements with name E in namespace ns
> *|E
> elements with name E in any namespace, including those without a namespace
> |E
> elements with name E without a namespace
> E
> if no default namespace has been declared for selectors, this is equivalent to *|E. Otherwise it is
equivalent to ns|E where ns is the default namespace.
I also checked the lxml bug tracker but didn't find this issue of
elements in any namespace mentioned
Is this something that could be supported by lxml? Should I open an
issue in the bug tracker for it?
Also, I found this thread on the mailing list which discusses support
for elements in any namespace [3] and proposes a patch
[1] http://www.w3.org/TR/css3-selectors/#typenmsp
[2] http://www.w3.org/TR/css3-namespace/#css-qnames
[3] http://thread.gmane.org/gmane.comp.python.lxml.devel/4937
> Traceback (most recent call last):
> File "example.py", line 35, in <module>
> sel = CSSSelector('*|Content')
> File "/home/nottheoilrig/lxml-2.3.5/src/lxml/cssselect.py", line 51, in __init__
> path = css_to_xpath(css)
> File "/home/nottheoilrig/lxml-2.3.5/src/lxml/cssselect.py", line 537, in css_to_xpath
> css_expr = parse(css_expr)
> File "/home/nottheoilrig/lxml-2.3.5/src/lxml/cssselect.py", line 662, in parse
> return parse_selector_group(stream)
> File "/home/nottheoilrig/lxml-2.3.5/src/lxml/cssselect.py", line 677, in parse_selector_group
> result.append(parse_selector(stream))
> File "/home/nottheoilrig/lxml-2.3.5/src/lxml/cssselect.py", line 688, in parse_selector
> result = parse_simple_selector(stream)
> File "/home/nottheoilrig/lxml-2.3.5/src/lxml/cssselect.py", line 724, in parse_simple_selector
> "Expected symbol, got '%s'" % next)
> lxml.cssselect.SelectorSyntaxError: Expected symbol, got '*' at [Token(u'*', 0), Token(u'|', 1),
Symbol(u'Content', 2)] -> None
_________________________________________________________________
Mailing list for the lxml Python XML toolkit - http://lxml.de/
lxml <at> lxml.de
https://mailman-mail5.webfaction.com/listinfo/lxml