Hi

Im using Xerces 2.8.0.
Because of compatibility issues I need to validate my xml by schemas via DocumentBuilder.parse()
My root schema imports other schemas in multiple levels.
2 of the schemas import each other, so there is a circular dependency between them.

My problem is this: how do I load these schemas from jar resources?

If I do this:

        InputStream schemaStream = XmlUtil.class.getResourceAsStream("/root.xsd");
        documentBuilderFactory.setAttribute (SCHEMA_SOURCE, schemaStream);

only the root.xsd is loaded from the classpath (the jar). The others are only found if I add them to the runtime dir.
It seems like Xerces don't look in classpath when parsing the schemaLocation hint on <import> ?

If I add all my schemas to the SCHEMA_SOURCE attribute:

       documentBuilderFactory.setAttribute(SCHEMA_SOURCE, new InputStream[]{schemaStream1, schemaStream2});

then it fails because of the circular import? (the circular import is not a problem when schemas is loaded as local files)

I know these problems disappear if I use the jaxp.validation api, but thats not an option.

Am I doing something wrong here?

Kind regards
Simon Vogensen
Lake IT

Reply via email to