Project

Profile

Help

trying to use local copy of XSD schema for XSLT 3 (which does an import for W3C schemas) causes java.net.MalformedURLException (Accessing an URL protocol that was not enabled ..)

Added by Martin Honnen over 1 year ago

I have now tried to run some schema based validation tasks through SaxonC 11.99 EE, trying to run some Python code attempting to validate a local XSLT file against a local copy of the schema for XSLT 3.0 stylesheets (which does some imports for W3C schemas which I hoped and think in previous SaxonJ versions the XML resolver would simply take from its cached copies) results in an warning I don't know how to fix:

java.net.MalformedURLException (Accessing an URL protocol that was not enabled.
  The URL protocol http is supported but not enabled by default. It must be enabled by
  adding the --enable-url-protocols=http option to the native-image command.

Here is the Python code:

from saxonc import *

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

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

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

    validator = proc.new_schema_validator()

    validator.register_schema(xsd_file = schema_for_xslt30)

    print(validator.get_error_message())

    validation_result = validator.validate_to_node(file_name = sample_xslt)

    if (validator.exception_occurred):
        print(validator.get_error_message())
    else:
        print(validation_result)

Complete output is e.g.

SaxonC-EE 12.0 from Saxonica
Warning at xs:import on line 103 column 81 of schema-for-xslt30.xsd:
   Imported schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd cannot be
  located: java.net.MalformedURLException (Accessing an URL protocol that was not enabled.
  The URL protocol http is supported but not enabled by default. It must be enabled by
  adding the --enable-url-protocols=http option to the native-image command.)
Error on line 986 of schema-for-xslt30.xsd:
   The element {xs:schema} is referenced, but is not defined in the XML Schema namespace
Error on line 7 column 19 of processorTestHTML5Xslt3InitialTempl.xsl:
  XQDY0084  Cannot validate <Q{.../Transform}stylesheet>: no element declaration available
Error on line 103 column 18 of processorTestHTML5Xslt3InitialTempl.xsl:
  XQDY0084  One validation error was reported: Cannot validate <Q{.../Transform}stylesheet>:
  no element declaration available
Errors were found in the schema
One validation error was reported: Cannot validate <Q{.../Transform}stylesheet>: no element declaration available

I attach the sample schema (it is from the XSLT 3 spec) and the sample XSLT 3.0 stylesheet:


    (1-2/2)

    Please register to reply