src/main/java/de/alpharogroup/xsd/schema/ValidatorExtensions.java
public static boolean validateSchema(final String SchemaUrl, final String XmlDocumentUrl)
		throws SAXException, ParserConfigurationException, IOException
	{
		System.setProperty(DOCUMENT_BUILDER_FACTORY_KEY, DOCUMENT_BUILDER_FACTORY_VALUE);
		final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setNamespaceAware(true);
		factory.setValidating(true);
		factory.setAttribute(SCHEMA_LANGUAGE_KEY, HTTP_WWW_W3_ORG_2001_XML_SCHEMA);
		factory.setAttribute(SCHEMA_SOURCE_KEY, SchemaUrl);
		final DocumentBuilder builder = factory.newDocumentBuilder();
		final ValidatorHandler handler = new ValidatorHandler();
		builder.setErrorHandler(handler);
		builder.parse(XmlDocumentUrl);
		if (handler.isValid())
		{
			return false;
		}
		return true;
	}
public static boolean validateSchema(final String SchemaUrl, final String XmlDocumentUrl)
		throws SAXException, ParserConfigurationException, IOException
	{
		System.setProperty(DOCUMENT_BUILDER_FACTORY_KEY, DOCUMENT_BUILDER_FACTORY_VALUE);
		final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setNamespaceAware(true);
		factory.setValidating(true);
		factory.setAttribute(SCHEMA_LANGUAGE_KEY, HTTP_WWW_W3_ORG_2001_XML_SCHEMA);
		factory.setAttribute(SCHEMA_SOURCE_KEY, SchemaUrl);
		final DocumentBuilder builder = factory.newDocumentBuilder();
		final ValidatorHandler handler = new ValidatorHandler();
		builder.setErrorHandler(handler);
		builder.parse(XmlDocumentUrl);
		if (handler.isValid())
		{
			return false;
		}
		return true;
	}
public static boolean validateSchema ( final String SchemaUrl , final String XmlDocumentUrl ) throws SAXException , ParserConfigurationException , IOException { System . setProperty ( DOCUMENT_BUILDER_FACTORY_KEY , DOCUMENT_BUILDER_FACTORY_VALUE ) ; final DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; factory . setValidating ( true ) ; factory . setAttribute ( SCHEMA_LANGUAGE_KEY , HTTP_WWW_W3_ORG_2001_XML_SCHEMA ) ; factory . setAttribute ( SCHEMA_SOURCE_KEY , SchemaUrl ) ; final DocumentBuilder builder = factory . newDocumentBuilder ( ) ; final ValidatorHandler handler = new ValidatorHandler ( ) ; builder . setErrorHandler ( handler ) ; builder . parse ( XmlDocumentUrl ) ; if ( handler . isValid ( ) ) { return false ; } return true ; }
Validate given xml schema.

@param SchemaUrl
the schema url
@param XmlDocumentUrl
the xml document url
@return true if the given xml is valid otherwise false
@throws SAXException
If a SAX error occurs during parsing.
@throws ParserConfigurationException
if a DocumentBuilder cannot be created which satisfies the configuration
requested.
@throws IOException
Signals that an I/O exception has occurred.
Validate given xml schema .