Can someone kindly tell me how do i use an Entity Resolver interface. I tried using it, but i got an Exception -
org.xml.sax.SAXParseException: File "file:///C:/samples/book.dtd" not found.
My current working directory is C:/samples
and The DOCTYPE Statement in the xml file is
<!DOCTYPE main SYSTEM "book.dtd">
I want to place the book.xml and book.dtd files in some other directory.
the following is the code implemnting the resolveEntity method.
public InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws SAXException, IOException
{
if (systemId.equals("book.dtd"))
{
try
{
return new InputSource(
file:///Some directory/book.xml");
}
catch(Exception e)
{
System.out.println("EXCEPTION = "+e);
return null;
}
}
else
{
return null;
}
}
Where have i gone wrong??