Validating xml documentbuilderfactory

After creating an XSD Schema instance from the XSD schema file, we are ready to create a Validator instance from the schema instance.The default is false, but in most situations you should set this to true, especially if you’re just reading the document and are not going to write it back out again.CDATA sections should not be treated differently than any other text.

I real life application, you will use this information for some real purpose rather than printing it on console and leave.An XML document is considered ‘well-formed’ if it follows the normal rules of XML. In the example below we look at validating an XML document while using DOM, SAX and St AX. On the other hand, an XML is considered valid if it follows the rules specified in the DTD or XSD. * @return Document * @throws Exception Thrown if other (NON-VALIDATION) errors occurred. */ protected static Document get Document(final String XMLPath, final String XSDPath) /** * Validate xml with xsd by dom. * Any validation errors are sent to Std Err, not thrown as an exception. * @param schema Stream Array The schema as array of stream sources used to validate the specified file.