Can XMLCatalog be used for schema imports?

Posted by jon077 on Stack Overflow See other posts from Stack Overflow or by jon077
Published on 2009-06-11T14:19:51Z Indexed on 2010/05/02 9:07 UTC
Read the original article Hit count: 378

Filed under:
|
|
|

Can you use XMLCatalog to resolve xsds in schema import statements? If so, what is the preferred/best practice? I want to package the xsds in a jar, so using a relative schemaLocation has not worked.

So far I am trying to do something like:

SchemaFactory factory = SchemaFactory
        .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
XMLCatalogResolver catalogResolver = new XMLCatalogResolver(
        new String[]{"/path/to/catalog.xml"});
factory.setResourceResolver(catalogResolver);

Schema schema = factory.newSchema(new StreamSource(ClassLoader
        .getSystemResourceAsStream("config.xsd")));

Without much luck.

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml