Project

Profile

Help

another error message in the context of validation: Exception from catalog resolver resolverURI()

Added by Martin Honnen about 1 year ago

Trying to use schema based validation (this time with an edited copy of the XSLT 3.0 schema which uses https links instead of http links for the imported schemata) I have run into another error message I am not sure is a quirk/bug in SaxonC 11.99 or needs a fix in my code (note that the tests are done on Windows but the file path is adapted to use / and not \ which so far, for XSLT, seemed to enable SaxonC 11.99 to read the Windows files, not sure why it doesn't work with the schema):

Here is the Python code

from saxonc import *

sample_dir = r'C:/Users/marti/OneDrive/Documents/xslt'

sample_xslt = r'processorTestHTML5Xslt3InitialTempl.xsl' #r'C:/Users/marti/OneDrive/Documents/xslt/processorTestHTML5Xslt3InitialTempl.xsl'

schema_for_xslt30 = r'schema-for-xslt30-with-https-imports.xsd' #r'schema-for-xslt30.xsd' #r'C:/Users/marti/OneDrive/Documents/xslt/schema-for-xslt30.xsd'

with PySaxonProcessor(license=True) as proc:
    print(proc.version)

    proc.set_cwd(sample_dir)

    validator = proc.new_schema_validator()

    validator.set_cwd(sample_dir)

    validator.register_schema(xsd_file = schema_for_xslt30)

    if validator.exception_occurred:
        print('Error registering schema', validator.get_error_message())
    else:
        validation_result = validator.validate_to_node(file_name = sample_xslt)

        if (validator.exception_occurred):
            print('Validation error', validator.get_error_message())
        else:
            print(validation_result)

Error output

SaxonC-EE 12.0 from Saxonica
Error registering schema Exception from catalog resolver resolverURI()

Files attached:


Replies (4)

Please register to reply

RE: another error message in the context of validation: Exception from catalog resolver resolverURI() - Added by Martin Honnen about 1 year ago

I am still failing to get schema based validation with the Python API and SaxonC 11.4 or 11.99 EE to work.

Are there any samples registering a schema from file for Python? Are there any unit tests xsd_file and register_schema with Python?

So far I have found a C++ sample which kind of runs with 11.4 EE although the output doesn't seem to make sense, https://saxonica.plan.io/projects/saxonmirrorhe/repository/he/revisions/he_mirror_saxon_11_4/entry/src/main/c/samples/cppTests/testValidator.cpp#L91 finds errorrs but the outputs cout<<endl<<"Error: Doc reported as valid!"<<endl;, I guess that should be cout<<endl<<"Error: Doc reported as invalid!"<<endl;.

RE: another error message in the context of validation: Exception from catalog resolver resolverURI() - Added by Martin Honnen about 1 year ago

If I have the schema in the working directory it is found. However, if I have it in a different directory and do

    proc.set_cwd(sample_dir)

(where I have e.g. initialized sample_dir = r'C:/Users/marti/OneDrive/Documents/xslt') I can test/debug

print('cwd', proc.cwd)

to show the value I get (i.e. the output is cwd C:/Users/marti/OneDrive/Documents/xslt) but an attempt to register a schema I have in that directory with e.g. validator.register_schema(xsd_file = schema_for_xslt30) (where I have initialized e.g. schema_for_xslt30 = r'schema-for-xslt30.xsd') gives an error java.io.FileNotFoundException: C:\Users\marti\PycharmProjects\SaxonC1199EELocalWheelTest1\schema-for-xslt30.xsd (where C:\Users\marti\PycharmProjects\SaxonC1199EELocalWheelTest1 is the working directory of the Python code).

Looking for an explanation I tried to look at the SaxonC sources, only 11 is online, it does in https://saxonica.plan.io/projects/saxonmirrorhe/repository/he/revisions/he_mirror_saxon_11_4/entry/src/main/c/Saxon.C.API/SchemaValidator.cpp#L88 setProperty("resources", proc->getResourcesDirectory());.

What is the resources directory? Is that also used for resolving file names like xsd_file?

RE: another error message in the context of validation: Exception from catalog resolver resolverURI() - Added by Martin Honnen about 1 year ago

Only if I pass absolute file paths to both register_schema(xsd_file = and validator.validate_to_node(file_name =, I get through schema validation for files in a directory other than the Python working directory.

    (1-4/4)

    Please register to reply