Java tutorial
//package com.java2s; import java.net.URL; import javax.xml.transform.dom.DOMSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; import org.w3c.dom.Document; public class Main { public static void validate(Document doc, URL xsdLocation) throws Exception { SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); Schema schema = factory.newSchema(xsdLocation); Validator validator = schema.newValidator(); validator.validate(new DOMSource(doc)); } }