This will start creating DOM objects as it parses the document - wasteful if you aren't going to use them. You should not use the DOMParser to validate a document (unless your goal is to create a document object model anyway).
XSD files are "XML Schemas" that describe the structure of a XML document.
This article explained about the XML document, XSD schema, and how to validate XML document against XSD schema using Microsoft .
Spring apparently also can intercept the URL requests to serve local files for validations.
You can probably do that with JDK API for Xml validation, if you use SAX-based writer: if so, just link in validator by calling 'Validator.validate(source, result)', where source comes from your writer, and result is where output needs to go.
Alternatively if you use Stax for writing content (or a library that uses or can use stax), Woodstox can also directly support validation when using XMLStream Writer.
W3C_XML_SCHEMA_NS_URI); try catch (SAXException e) catch (IOException e) but you could just as easily validate against a local file.