# HG changeset patch # User cmlenz # Date 1190065881 0 # Node ID 8bcd86cd6c1055868a6c52cfa8e6a2b477c11955 # Parent 93a19f09eebe06b7e049e5482a5b2a07c44fb773 Fix for descendant-or-self XPath patterns when namespaces are involved. diff --git a/genshi/path.py b/genshi/path.py --- a/genshi/path.py +++ b/genshi/path.py @@ -43,7 +43,8 @@ import re from genshi.core import Stream, Attrs, Namespace, QName -from genshi.core import START, END, TEXT, COMMENT, PI +from genshi.core import START, END, TEXT, START_NS, END_NS, COMMENT, PI, \ + START_CDATA, END_CDATA __all__ = ['Path', 'PathSyntaxError'] __docformat__ = 'restructuredtext en' @@ -195,6 +196,9 @@ continue elif kind is START: cursors.append(cursors and cursors[-1] or 0) + elif kind is START_NS or kind is END_NS \ + or kind is START_CDATA or kind is END_CDATA: + continue if updateonly or retval or not cursors: continue @@ -272,6 +276,8 @@ if not matched or last_step or not ( axis is SELF or axis is DESCENDANT_OR_SELF): break + if ctxtnode and axis is DESCENDANT_OR_SELF: + ctxtnode = False if (retval or not matched) and kind is START and \ not (axis is DESCENDANT or axis is DESCENDANT_OR_SELF): diff --git a/genshi/tests/path.py b/genshi/tests/path.py --- a/genshi/tests/path.py +++ b/genshi/tests/path.py @@ -76,7 +76,7 @@ path = Path('//*') self.assertEqual('', repr(path)) - self.assertEqual('', path.select(xml).render()) + self.assertEqual('', path.select(xml).render()) def test_1step_attribute(self): path = Path('@foo')