I have an xsd file which the SAXParser is to parse and use it to validate some xml files.

I used the setEntityResolver and parse methods of the SAXParser and a custom class called MyEntityResolver. But errors appeared when the code is run.

The class where the SAXParser and the custom class is used is shown below:

Code:
import org.apache.xerces.parsers.DOMParser;
import java.io.*;
import org.w3c.dom.Document;
import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.SAXRecognizedException;

public class SchemaTest{
    public boolean validateSchema(String xmlFilePath, String xsdFilePath)
    {
         try{
            SAXParser parser = new SAXParser();
            ..........
           parser.setEntityResolver(new MyEntityResolver(xsdFilePath));
           parser.parse(xmlFilePath);
         }
         catch(SAXParseException e)
         { ..... }
       
   }
}
The custom class MyEntityResolver is listed below:

Code:
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class MyEntityResolver implements EntityResolver{
   private static String dtd = null;
   
   public MyEntityResolver(String dtd){
          this.dtd = dtd;
   }

   public InputSource resolveEntity(String arg0,String arg1) throws
   SAXException, IOException {
         return new org.xml.sax.InputSource(dtd);
   }

}
The SAXParseException was caught when the code runs. Is there something wrong with the code above or does the fault lie with the xsd/xml file?