AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

loading an XML file

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
arvindsd@yahoo.com
Guest





PostPosted: Sat Jul 23, 2005 6:57 am    Post subject: loading an XML file Reply with quote



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

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.