Kylo
Kylo

Reputation: 109

Complex xml validation

I have a problem with validating xml file. In my xml file the xsi:schemaLocation="" is poiting to the xsd file. Unfortunately this xsd file has loads of schema dependencies. They all point o some websites. Because of this the validation is failing. All tools and libraries fail, forex xmlSpy. When I point xsi:schemaLocation="" in xml file o local xsd (with all dependencies being local) validation works fine.

My question is relating to the javax.xml.validation can I tell it to ignore the xml xsi:schemaLocation="" inside my xml file or change it while doing validation. On production there will be hundreds of file to validated so I want to point the xsi:schemaLocation="" to local xsd using avax.xml.validation without changing the xml file ?

Any ideas how to do it ?

Upvotes: 1

Views: 236

Answers (1)

Andreas
Andreas

Reputation: 159086

Create an implementation of LSResourceResolver, and make it the resolver for the SchemaFactory used to load the Schema.

You can then load external XSD files from a local file store, to ensure that the files can be found.

It also improves performance.

Upvotes: 1

Related Questions