private static boolean verifyXML(String fileName){
  SchemaFactory sf=SchemaFactory.newInstance(W3C_XML_SCHEMA);
  Source xsdFile=new StreamSource(new File(XSD_FILE_PATH));
  Source xmlFile=new StreamSource(new File(fileName));
  boolean validXML=false;
  try {
    Schema schema=sf.newSchema(xsdFile);
    Validator validator=schema.newValidator();
    try {
      validator.validate(xmlFile);
      validXML=true;
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    if (!validXML) {
      new IOException("File isn't  valid against the xsd");
    }
  }
 catch (  SAXException e) {
    e.printStackTrace();
  }
  return validXML;
}

private static boolean verifyXML ( String fileName ) { SchemaFactory sf = SchemaFactory . newInstance ( W3C_XML_SCHEMA ) ; Source xsdFile = new StreamSource ( new File ( XSD_FILE_PATH ) ) ; Source xmlFile = new StreamSource ( new File ( fileName ) ) ; boolean validXML = false ; try { Schema schema = sf . newSchema ( xsdFile ) ; Validator validator = schema . newValidator ( ) ; try { validator . validate ( xmlFile ) ; validXML = true ; } catch ( IOException e ) { e . printStackTrace ( ) ; } if ( ! validXML ) { new IOException ( "File isn't  valid against the xsd" ) ; } } catch ( SAXException e ) { e . printStackTrace ( ) ; } return validXML ; }
checks whether the given xml is valid against the xsd for the new data format .
