public static SAXParser newSAXParser(String schemaLanguage,boolean namespaceAware,boolean validating,Source... schemas) throws SAXException, ParserConfigurationException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setValidating(validating);
  factory.setNamespaceAware(namespaceAware);
  if (schemas.length != 0) {
    SchemaFactory schemaFactory=SchemaFactory.newInstance(schemaLanguage);
    factory.setSchema(schemaFactory.newSchema(schemas));
  }
  SAXParser saxParser=factory.newSAXParser();
  if (schemas.length == 0) {
    saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",schemaLanguage);
  }
  return saxParser;
}

public static SAXParser newSAXParser ( String schemaLanguage , boolean namespaceAware , boolean validating , Source ... schemas ) throws SAXException , ParserConfigurationException { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; factory . setValidating ( validating ) ; factory . setNamespaceAware ( namespaceAware ) ; if ( schemas . length != 0 ) { SchemaFactory schemaFactory = SchemaFactory . newInstance ( schemaLanguage ) ; factory . setSchema ( schemaFactory . newSchema ( schemas ) ) ; } SAXParser saxParser = factory . newSAXParser ( ) ; if ( schemas . length == 0 ) { saxParser . setProperty ( "http://java.sun.com/xml/jaxp/properties/schemaLanguage" , schemaLanguage ) ; } return saxParser ; }
factory method to create a saxparser configured to validate according to a particular schema language and optionally providing the schema sources to validate with .
