Project

Profile

Help

Bug #4845

PySchemaValidator.validation_report always None, and clears all errors

Added by Craeg Strong about 2 months ago. Updated about 2 months ago.

Status:
AwaitingInfo
Priority:
Normal
Category:
Python
Start date:
2020-11-29
Due date:
% Done:

0%

Estimated time:
Found in version:
1.2.1
Fixed in version:

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

History

#1 Updated by Michael Kay about 2 months ago

  • Project changed from Saxon to Saxon/C
  • Category changed from Schema conformance to Python
  • Assignee set to O'Neil Delpratt

#2 Updated by O'Neil Delpratt about 2 months ago

  • Description updated (diff)

#3 Updated by O'Neil Delpratt about 2 months ago

  • 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.

Please register to edit this issue

Also available in: Atom PDF