Feature #5967
open
allow to set language version 4.0 for XPath evaluation
Description
SaxonJ EE supports setting the XPath language version to 4.0 (for the currently experimental XPath 4.0 support); it appears that SaxonC so far only allows that for XQuery (where a lang
argument has been added to the API) but it so far lacks such an API for XPath evaluation.
It seems desirable to also allow pure XPath 4.0 evaluation with SaxonC.
- Status changed from New to In Progress
Thanks for reporting this omission. Looking into it now.
The setLanguageVersion
method is available on the XPathProcessor for the C++ and PHP APIs but is missing from the Python API.
As a workaround in Python API user can set the language as follows:
xpath_processor.set_property("lang:", "4.0")
- Status changed from In Progress to Resolved
The set_language_version method has now been added to the PyXPathProcessor class. Available in the next maintenance release.
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in version set to 12.2
Bug fix applied in the SaxonC 12.2 maintenance release.
I find this is not working in SaxonC EE 12.4.2, code like
from saxoncee import PySaxonProcessor, PySaxonApiError
with PySaxonProcessor(license=True) as saxon_proc:
print(saxon_proc.version)
xpath_proc = saxon_proc.new_xpath_processor()
xpath_proc.set_language_version('4.0')
try:
print(xpath_proc.evaluate('(1 to 5)=!>fn{. + .}()'))
except PySaxonApiError as e:
print(e)
try:
print(xpath_proc.evaluate('parse-html("<p>Test.<p>Test")'))
except PySaxonApiError as e:
print(e)
gives
SaxonC-EE 12.4.2 from Saxonica
XPST0003: The parser is not configured to allow use of XPath 4.0 syntax. Line number: -1
XPST0017: Cannot find a 1-argument function named Q{http://www.w3.org/2005/xpath-functions}parse-html(). Line number: -1
as does the workaround:
from saxoncee import PySaxonProcessor, PySaxonApiError
with PySaxonProcessor(license=True) as saxon_proc:
print(saxon_proc.version)
xpath_proc = saxon_proc.new_xpath_processor()
xpath_proc.set_property('lang:', '4.0')
try:
print(xpath_proc.evaluate('(1 to 5)=!>fn{. + .}()'))
except PySaxonApiError as e:
print(e)
try:
print(xpath_proc.evaluate('parse-html("<p>Test.<p>Test")'))
except PySaxonApiError as e:
print(e)
I haven't been able to identify so far whether this is a regression or whether it never worked for the Python XPath API.
Yes that is the problem.
And because of comment #7 the following hack/workaround works for me:
xpath_proc.set_property('lang:', '4.0')
xpath_proc.set_property('lang', '4.0')
Oh, yes, that is smart thinking.
Nevertheless I hope you reopen this bug and fix it for the next maintenance release.
- Status changed from Closed to In Progress
- Fixed in version deleted (
12.2)
Reopening this bug issue.
Please register to edit this issue
Also available in: Atom
PDF