Create Woodstox's XMLValidationSchema from multiple resource files

120 views Asked by At

I have a main file.xsd that has an import with a schema location that points to file1.xsd like this:

<xs:import namespace="urn:file1" schemaLocation="file1.xsd"/>

I run this on a Docker container and it complains about not finding file1.xsd in container home folder:

InputStream resourceStream = this.getClass().getClassLoader()
    .getResourceAsStream("file.xsd");

XMLValidationSchemaFactory schemaFactory = XMLValidationSchemaFactory
    .newInstance(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA);

XMLValidationSchema validationSchema = schemaFactory.createSchema(resourceStream);

How can I link these two xsd resources in same XMLValidationSchema which is the mandatory type I have to obtain? (modifying the docker-compose/explicitly copying the file1.xsd in container is not an option although it works that way)

1

There are 1 answers

0
StaxMan On

Woodstox does not have resolver for automatically reading schema from document content so you need to use the approach you have (but create InputStream in a way that works).

The only resources that are automatically resolved are external DTD subsets as specified by XML specification.

This is not to say that a handler could not be implemented and added to Woodstox (I am sure some users would find it useful), just that there isn't one currently.