The only problem is, its giving me false positives: its validating XML instances that should absolutely be failing.I've tested it out on 3 schemas: 1 schema it worked beautifully with, and now its misbehaving with the last two (false positives).There are lots of tutorials online on doing this, but I was not able to find a way that satisfies all my constraints, which are as follows: -I don't know the scheme beforehand, I have a bunch of XML and XSD files and every XML contains information about the XSD it should conform to -The validatior should alter the stream the handler gets and insert the default values for optional attributes from the XSD if necessary -The current custom handler should be used I'm fairly new to this topic, so I can't preclude that I've stumbled over the solution without beeing aware of it, but I'm currently completely confused on how to do this. Here is a minimum SSCCE, which should show the problem and related parts: package parser Test; import The Input Source object is created with an Input Stream object created from the example XML schema document,
In this section we shall validate the example XML document with XML schema document catalog.xsd, with the SAXParser class. Create a SAXParser object and set the validation mode of the SAXParser object to SCHEMA_VALIDATION, as shown in the following listing: Validates the complete XML document with an XML schema if the parser is able to find a schema.
Configure Java APIs (SAX, DOM, dom4j, XOM) using JAXP 1.3 to validate XML Documents with DTD and Schema(s).
Many Java XML APIs provide mechanisms to validate XML documents, the JAXP API can be used for most of these XML APIs but subtle configuration differences exists.
Here is the body of the schema = get Schema As String(); target Xml = "ijeioj489fu4u8"; SAXParser Factory o SAXParser Factory = SAXParser Instance(); SAXParser o SAXParser = null; o SAXParser Namespace Aware(true); try catch(Exception o Exception) Javadoc WARNING: If an application does not register an Error Handler, XML parsing errors will go unreported, except that SAXParse Exceptions will be thrown for fatal errors.
In order to detect validity errors, an Error Handler that does something with error() calls must be registered.