From f00732ede5d29502d59157702ca75d446b782b5b Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Mon, 5 Aug 2019 11:37:59 +0200 Subject: [PATCH] Fix XPath2Parser.parse() method - In case of schema binding the static context evaluation uses the XPathToken.select() method because a context with a tree of nodes is provided. --- elementpath/xpath2_parser.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/elementpath/xpath2_parser.py b/elementpath/xpath2_parser.py index 5127b3d..185fcc0 100644 --- a/elementpath/xpath2_parser.py +++ b/elementpath/xpath2_parser.py @@ -331,11 +331,17 @@ class XPath2Parser(XPath1Parser): def parse(self, source): root_token = super(XPath1Parser, self).parse(source) - context = None if self.schema is None else self.schema.get_context() - try: - root_token.evaluate(context) # Static context evaluation - except MissingContextError: - pass + + if self.schema is None: + try: + root_token.evaluate() # Static context evaluation + except MissingContextError: + pass + else: + # Static context evaluation with a dynamic schema context + for _ in root_token.select(context=self.schema.get_context()): + pass + return root_token