Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] problem with Aelfred parser

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Alex Ivanov <alexivanov AT cra.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] problem with Aelfred parser
  • Date: Fri, 2 Sep 2005 09:07:17 -0400

Hi,

I'm using a default XML reader to set an entity resolver for a DTD. First, I
wrote a library to read an XML file. I tested it and it worked fine.
It turned out it was using Crimson parser as a default. Then I used the same
library in my application. It threw an exception saying that
it couldn't resolve dtd. I checked in the debugger and it turned out that
picked up an Aelfred parser somewhere on the classpath. I inserted
a print statement to check if it was calling it at all and it wasn't.
However, when I set a Xerces parser explicitly in my code everything worked
fine both in the library and in the application. It leads me to believe that
Aelfred parser is not adding the DTD handler properly.


xmlReader=XMLReaderFactory.createXMLReader(); //works in the library,
doesn't work in the application
//xmlReader =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
//works in both


// set resolver for DTD
xmlReader.setEntityResolver(docHandler);
xmlReader.setErrorHandler(docHandler);


private final DocHandler docHandler = new DocHandler();

private final class DocHandler extends DefaultHandler
{
public InputSource resolveEntity(String publicId, String systemId)
{

System.out.println("**************************************************"+syst
emId);

InputStream input = locateDtd(systemId);
InputSource source = null;
if (input != null)
source = new InputSource(input);
else
System.out
.println("Could not find DTD file: " + systemId/*
.substring(systemId.lastIndexOf('/')+1) */);

return source;
}


Thanks

Alex




Archive powered by MHonArc 2.6.24.

Top of Page