Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

loading an XML file

0 views
Skip to first unread message

arvi...@yahoo.com

unread,
Jul 23, 2005, 2:57:34 AM7/23/05
to
Hi all,

I have a XML file with DOCTYPE reference to a public DTD as shown
below:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>load</servlet-name>
<servlet-class>nct.front.LoadServlet</servlet-class>
</servlet>
<servlet>
</web-app>

I try to load this file with the code below:

DocumentBuilder webDocB = null;
Document webXMLDoc = null;

DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setExpandEntityReferences(false);

try {
webDocB = dbf.newDocumentBuilder();
webDocB.setEntityResolver(null);
System.out.println(webDocB.isValidating());
} catch (ParserConfigurationException e) {
e.printStackTrace();
return;
} catch (FactoryConfigurationError e) {
e.printStackTrace();
return;
}

try {
File f = new File(absWebXMLPath);
webXMLDoc = webDocB.parse(f);
} catch (SAXException e1) {
e1.printStackTrace();
return;
} catch (IOException e1) {
e1.printStackTrace();
return;
}


But my code always fails at
webXMLDoc = webDocB.parse(f);

I have set the validating flag of DocumentBuilderFactory to "false" and
marked the XML document as "standalone".

it still failed.

I tried with removing the DOCTYPE in XML file and it worked.

The exception that I get is as below:

java.io.IOException
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at
org.apache.crimson.parser.Parser2.externalParameterEntity(Parser2.java:3064)
at
org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1347)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:656)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at
org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:151)
at
nct.config.tomcat.ServerConfig.configureWebXML(ServerConfig.java:174)
at nct.config.tomcat.InstallMain.main(InstallMain.java:20)


Any help will be deeply appreciated.

regards,

ASD

0 new messages