title: How should I use Stax2 Validation API against a W3 Schema
body: <p>I am using <strong>com.ctc.wstx.stax.WstxOutputFactory</strong> to generate XML.
  I am running wstx-asl-3.2.4</p>
  
  <p>I need to start validating the generated XML against a W3 Schema.</p>
  
  <p>When I create an instance of <strong>org.codehaus.stax2.validation.XMLValidationSchemaFactory</strong> like this</p>
  
  <p><code>
  private final static XMLValidationSchemaFactory xsdFact=
      XMLValidationSchemaFactory.newInstance(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA);
  </code></p>
  
  <p>I get the error</p>
  
  <blockquote>
    <p>javax.xml.stream.FactoryConfigurationError: No XMLValidationSchemaFactory implementation class specified or accessible (via system property 'org.codehaus.stax2.validation.XMLValidationSchemaFactory.w3c', or service definition under 'META-INF/services/org.codehaus.stax2.validation.XMLValidationSchemaFactory.w3c')
        at org.codehaus.stax2.validation.XMLValidationSchemaFactory.newInstance(XMLValidationSchemaFactory.java:208)
        at org.codehaus.stax2.validation.XMLValidationSchemaFactory.newInstance(XMLValidationSchemaFactory.java:98)</p>
  </blockquote>
  
  <p>I can see that woodstox is bundled with a DTD parser only.
  I found <a href="http://www.cowtowncoder.com/blog/archives/2006/08/entry_15.html" rel="nofollow noreferrer">this article</a>
  which contains the unhelpful instruction</p>
  
  <blockquote>
    <ol>
    <li>Get an instance of XMLValidationSchemaFactory that knows how to parse schemas of the type you need (RelaxNG == rng for this example). </li>
    </ol>
  </blockquote>
  
  <p>I have been looking at the <a href="https://msv.dev.java.net/" rel="nofollow noreferrer">Sun Multi-Schema XML Validator</a> which is supposed to contain the bits necessary to bolt on to the XMLSchemaValidation factory.</p>
  
  <p>It looks like I might be able to use <strong>com.sun.msv.reader.xmlschema.XMLSchemaReader</strong>
  to write my own instance of XMLValidationSchemaFactory and get it to work this way.</p>
  
  <p>My question is; do I really have to do this, or is there a pre-existing w3c schema factory that I have failed to find?</p>
  
  <p>Perhaps it would be simpler just to validate the XML <em>after</em> I have generated it.</p>
  
  <p>What are the views on this ?</p>