How to use the Stax2 authentication API for a W3 scheme

I am using com.ctc.wstx.stax.WstxOutputFactory to generate XML. I am running wstx-asl-3.2.4

I need to start checking the generated XML for a W3 schema.

When I create an instance of org.codehaus.stax2.validation.XMLValidationSchemaFactory , like this

private final static XMLValidationSchemaFactory xsdFact= XMLValidationSchemaFactory.newInstance(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA);

I get an error

javax.xml.stream.FactoryConfigurationError: there is no XMLValidationSchemaFactory implementation class specified or available (via the system property 'org.codehaus.stax2.validation.XMLValidationSchemaFactory.w3c' or the service definition in the META-INF / services / org.codehaus.stax2 section .validation.XMLValidationSchemaFactory.w3c ') at org.codehaus.stax2.validation.XMLValidationSchemaFactory.newInstance (XMLValidationSchemaFactory.java:208) at org.codehaus.stax2.validation.XMLvationationchechefactationFactoryFactoryFormation

I see that woodstox only comes with a DTD parser. I found this article which contains useless instructions

  • Get an instance of XMLValidationSchemaFactory that knows how to parse the schemas of the type you need (RelaxNG == rng for this example).

Sun Multi-Schema XML Validator, , XMLSchemaValidation factory.

, com.sun.msv.reader.xmlschema.XMLSchemaReader XMLValidationSchemaFactory .

: , w3c- factory, ?

, XML , .

?

+3
1

Woodstox 4.0.8, W3CSchemaFactory .

+3

Source: https://habr.com/ru/post/1758366/


All Articles