Commits

cmlenz  committed 1f6cb67

Report error when position predicates are used in XPath expressions (which is NYI).

  • Participants
  • Parent commits 9c023c3
  • Branches trunk

Comments (0)

Files changed (2)

File markup/path.py

         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,

File markup/tests/path.py

         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>')