I too faced the same problem. Instead of using Crimson parser i used Xerces parser to parse the document. Xerces parser gives us a feature
parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false); This feature restric the parser not to connect to any site
during parsing. I dont know any similar kind of feature available in crimson parser or any other anternative are available.
 
 
 
 
public class MySAXDocumentFactory extends SAXDocumentFactory
{
 
    public MySAXDocumentFactory(DOMImplementation impl,
                              String parser)
    {
        super(impl,parser);
    }
    protected Document createDocument(String ns, String root, String uri,
                                      InputSource is)
       throws IOException
   {
      document = implementation.createDocument(ns, root, null);
      try
      {
              XMLReader parser  =
                  XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");

              parser.setContentHandler(this);
              parser.setDTDHandler(this);
              parser.setEntityResolver(this);
              parser.setErrorHandler(this);
 
              parser.setFeature("http://xml.org/sax/features/namespaces", true);
              parser.setFeature("
http://xml.org/sax/features/namespace-prefixes", true);
              parser.setFeature("
http://xml.org/sax/features/validation", false);
              parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
              parser.parse(is);
 
     } catch (SAXException e)
       {
              System.out.println("The Excep is " + e );
 
             Exception ex = e.getException();
             if (ex != null && ex instanceof InterruptedIOException)
              {
                  throw (InterruptedIOException)ex;
             }
             throw new IOException(e.getMessage());
       }
 
   return document;
   }
 
}
 
Regards
Bala
 -----Original Message-----
From: Nuno Faria [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 19, 2002 4:46 AM
To: Batik Users
Subject: XML/SVG crimson parser...

Hi ppl,
 
First i have to apologize for this "not so batik subject" but i think that someone here can help me.
So, i download crimson XML parser (from http://xml.apache.org/dist/crimson/) in order to parse XML/SVG files and i use an example DOMEcho.java that cames with the distribution and it works fine but only when i'm online (it goes get the DTD to w3c).
How can i do an offline parser?
 
Once again sorry about this matter and thanks if anyone can help me.
 
Nuno Andr� Faria
Departamento de Inform�tica,
Universidade do Minho
Brag, Portugal


"THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE ADDRESSEE and may contain confidential and privileged information.

If the reader of this message is not the intended recipient,

you are notified that any dissemination, distribution or copy of this

communication is strictly Prohibited.

If you have received this message by error, please notify us

immediately, return the original mail to the sender and delete the

message from your system."


Reply via email to