You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XPath 2/3 expression min(.//row/count(entry)) doesn't parse with XPath3Parser: elementpath.exceptions.ElementPathTypeError: 'entry' proxy function at line 1, column 18: [err:XPST0017] unknown function 'entry'
#78
Open
martin-honnen opened this issue
Oct 20, 2024
· 1 comment
I find that the XPath 2 and 3 expression min(.//row/count(entry)) doesn't parse with the XPath3Parser (it parses with the XPath2 default parser), the error I get is elementpath.exceptions.ElementPathTypeError: 'entry' proxy function at line 1, column 18: [err:XPST0017] unknown function 'entry'.
The first select using the default XPath 2 parser works fine and the output of the subsequent print is 1, but the following code fails with
Traceback (most recent call last):
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\elementpath-test1.py", line 45, in <module>
results = select(root, 'min(.//row/count(entry))', parser=XPath3Parser)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\xpath_selectors.py", line 53, in select
root_token = _parser.parse(path)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\xpath2\xpath2_parser.py", line 510, in parse
root_token = super(XPath1Parser, self).parse(source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\tdop.py", line 497, in parse
root_token = self.expression()
^^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\tdop.py", line 622, in expression
left = self.token.nud()
^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\xpath_tokens.py", line 1454, in nud
self._items[k:] = self.parser.expression(5),
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\tdop.py", line 625, in expression
left = self.token.led(left)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\xpath1\_xpath1_operators.py", line 718, in led_child_or_descendant_path
self[:] = left, self.parser.expression(75)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\tdop.py", line 622, in expression
left = self.token.nud()
^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\xpath_tokens.py", line 1454, in nud
self._items[k:] = self.parser.expression(5),
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\tdop.py", line 622, in expression
left = self.token.nud()
^^^^^^^^^^^^^^^^
File "C:\Users\marti\PycharmProjects\Pyschematron-test1\.venv\Lib\site-packages\elementpath\xpath_tokens.py", line 1204, in nud
raise self.error('XPST0017', msg) from None
elementpath.exceptions.ElementPathTypeError: 'entry' proxy function at line 1, column 18: [err:XPST0017] unknown function 'entry'
The text was updated successfully, but these errors were encountered:
- Fix for issue #78
- Fix proxy() class method to use a different class name from
the original token
- Remove useless MutableSequence.register(): tokens are already
MutableSequence instances
Hi,
this is a problem of names collisions, that is implicit in XPath. The version 4.6.0 should fix this and other ambiguities, also with operators.
thank you
I find that the XPath 2 and 3 expression
min(.//row/count(entry))
doesn't parse with the XPath3Parser (it parses with the XPath2 default parser), the error I get iselementpath.exceptions.ElementPathTypeError: 'entry' proxy function at line 1, column 18: [err:XPST0017] unknown function 'entry'
.Example Python code:
The first
select
using the default XPath 2 parser works fine and the output of the subsequent print is1
, but the following code fails withThe text was updated successfully, but these errors were encountered: