changeset 164:1f6cb675a66c trunk

Report error when position predicates are used in XPath expressions (which is NYI).
author cmlenz
date Wed, 16 Aug 2006 23:06:32 +0000
parents 9c023c395e44
children 54a4be707664
files markup/path.py markup/tests/path.py
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/markup/path.py
+++ b/markup/path.py
@@ -359,6 +359,8 @@
         assert self.cur_token == '['
         self.next_token()
         expr = self._or_expr()
+        if isinstance(expr, NumberLiteral):
+            raise PathSyntaxError('Position predicates not yet supported')
         if self.cur_token != ']':
             raise PathSyntaxError('Expected "]" to close predicate, '
                                   'but found "%s"' % self.cur_token,
--- a/markup/tests/path.py
+++ b/markup/tests/path.py
@@ -27,6 +27,9 @@
         self.assertRaises(PathSyntaxError, Path, '..')
         self.assertRaises(PathSyntaxError, Path, 'parent::ma')
 
+    def test_error_position_predicate(self):
+        self.assertRaises(PathSyntaxError, Path, 'item[0]')
+
     def test_1step(self):
         xml = XML('<root><elem/></root>')
 
Copyright (C) 2012-2017 Edgewall Software