Bug #4845
closed
PySchemaValidator.validation_report always None, and clears all errors
Description
It appears that accessing the validation report clears errors and always returns None
Given that schema_filepath points to a valid XSD, and test_filepath points to an XML with exactly one validation error against that XSD:
saxon_proc = saxonc.PySaxonProcessor(license=True)
validator = saxon_proc.new_schema_validator()
assert validator is not None
validator.register_schema(xsd_file=str(schema_filepath))
# print(f'validating {test_filepath} with {schema_filepath}')
validator.validate(file_name=str(test_filepath))
print(v.exception_count())
print(v.exception_occurred())
print(v.validation_report)
print(v.exception_count())
print(v.exception_occurred())
Returns this:
1
True
None
0
False
- Project changed from Saxon to SaxonC
- Category changed from Schema conformance to Python
- Assignee set to O'Neil Delpratt
- Description updated (diff)
- Status changed from New to AwaitingInfo
- Found in version set to 1.2.1
Hi,
The validation_report
returning None
probably means for some reason it has not found any validation errors, or fails before gets to that stage. Given that there is some exception thrown means that maybe the schema file has failed to compile or not been found. Or maybe the issue is with the source document not being found. Due to how JNI works the exceptions will be cleared once you call validation_report
.
To better investigate what is happening please can you include the function get_error_message(0)
to your code before calling validation_report
so we can actually see the exception message,
For example:
print(v.get_error_message(0))
Another thing to check is that you are in the working directory you expect. You can always set the cwd
on the SaxonProcessor object:
saxonproc2.set_cwd('/fullpath')
Replace the word /fullpath
with you directory on your system.
- Status changed from AwaitingInfo to Rejected
Please register to edit this issue
Also available in: Atom
PDF