In DOM or SAX parsers in Java it is possible to define the XML Schema to use by calling methods DocumentBuilderFactory.setSchema(..) or SAXParserFactory.setSchema(...).
How can I do the similar thing (enable XML Schema validation) when using StAX parser? Actually I am creating the parser as follows:
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
XMLStreamReader reader = factory.createXMLStreamReader(docIs);
parseDoc(reader); // own method which reads data from XML
and I would like to know when the XML document does not match schema or is invalid XML document.