
Torsten Rehn wrote:
On Mon, 2007-04-23 at 08:24 +0200, Stefan Behnel wrote:
You should pass the namespace-prefix mapping to lxml. See the docs on this topic:
Ah, looking at the development version's page obviously helps ;)
etree.XPathSyntaxError: error in xpath expression As expected. Undefined prefixes are invalid.
But it is valid XPath 1.0, isn't it? I'm just a little confused by the term "XPath Syntax Error". As far as I understand the issue, the problem is not with the syntax but with lxml (or whatever lies beneath) not supporting some of it (which is ok with the W3C recommendation).
I think it is indeed confusing we call it an XPath Syntax Error. The xpath expression is indeed correct, we just haven't supplied it with enough information. I wonder if there's a way we can detect this specific problem and raise something like an XPathNamespaceError instead? I think this one bites people quite frequently, as people often forget that the prefixes in XPath are not looked up in the document but is independent, just like the prefixes between documents are independent. Regards, Martijn