[jdom-interest] Newbie can't parse document!
Alex Colic
alex.colic at pop-ware.com
Wed Mar 7 09:09:19 PST 2001
Hi,
I set validation off as you suggested but I still get the exception. I take
the dtd tag out of the xml file and everything works.
I have set validation off by (false) in the builder constructor and by
calling builder.setValidation(false).
I can distribute the file without the dtd tag but this does not seem like a
solution.
Alex
----- Original Message -----
From: "Jochen Strunk" <strunk at signal7.de>
To: "Alex Colic" <alex.colic at pop-ware.com>
Cc: <jdom-interest at jdom.org>
Sent: Wednesday, March 07, 2001 11:59 AM
Subject: Re: [jdom-interest] Newbie can't parse document!
> Hi,
>
> Try to set validation off ( builder.setValidation(false) ).
> From the stack trace it looks like the parser is trying to find the
> web-app dtd which is usually referenced in web.xml.
>
> hope this helps,
> jochen
>
>
> At 11:15 07.03.2001 -0500, you wrote:
> >Hi, I am new to using JDOM. I think I have done everything correctly to
> >create a SAXBuilder but I am getting an exception. I created a
> >FileInputStream and passing a File object, the same that I am passing to
> >the SAXBuilder, I can read and print the file to the screen.
> >
> >My code is as follows:
> >
> > String
directory="C:\\JBuilder4\\Projects\\pwWorkRequest\\src\\WEB-INF\\";
> > String file="web.xml";
> >
> > File f=new File(directory + file);
> > FileInputStream fis=new FileInputStream(f);
> > int n;
> > while ((n=fis.available()) >0)
> > {
> > byte[] b=new byte[n];
> > int results=fis.read(b);
> > if(results==-1) break;
> > String s=new String(b);
> > System.out.print(s);
> > }
> >
> >This works OK.
> >
> >But this causes an exception:
> >
> > SAXBuilder builder=new SAXBuilder(false);
> > Document doc=builder.build(f);
> >
> >The exception message is:
> >
> >java.sun.com: java.sun.com
> >
> >The printstack trace:
> >
> >org.jdom.JDOMException: java.sun.com: java.sun.com
> >at org.jdom.input.SAXBuilder.build(SAXBuilder.java:320)
> >at org.jdom.input.SAXBuilder.build(SAXBuilder.java:373)
> >at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
> >at test.main(test.java:52)
> >
> >Root cause: java.net.UnknownHostException: java.sun.com
> >at java.net.InetAddress.getAllByName0(InetAddress.java:571)
> >at java.net.InetAddress.getAllByName0(InetAddress.java:540)
> >at java.net.InetAddress.getByName(InetAddress.java:449)
> >at java.net.Socket.<init>(Socket.java:100)
> >at sun.net.NetworkClient.doConnect(NetworkClient.java:50)
> >at sun.net.www.http.HttpClient.openServer(HttpClient.java:331)
> >at sun.net.www.http.HttpClient.openServer(HttpClient.java:517)
> >at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
> >at sun.net.www.http.HttpClient.<init>(HttpClient.java:277)
> >at sun.net.www.http.HttpClient.New(HttpClient.java:289)
> >at
>
>sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:
379)
> >at
>
>sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnectio
n.java:472)
> >at java.net.URL.openStream(URL.java:798)
> >at
>
>org.apache.xerces.readers.DefaultReaderFactory.createReader(DefaultReaderFa
ctory.java:149)
> >at
>
>org.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalEnti
ty(DefaultEntityHandler.java:747)
> >at
>
>org.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalSubs
et(DefaultEntityHandler.java:566)
> >at
>
>org.apache.xerces.framework.XMLDTDScanner.scanDoctypeDecl(XMLDTDScanner.jav
a:1131)
> >at
>
>org.apache.xerces.framework.XMLDocumentScanner.scanDoctypeDecl(XMLDocumentS
canner.java:2177)
> >at
>
>org.apache.xerces.framework.XMLDocumentScanner.access$0(XMLDocumentScanner.
java:2133)
> >at
>
>org.apache.xerces.framework.XMLDocumentScanner$PrologDispatcher.dispatch(XM
LDocumentScanner.java:882)
> >at
>
>org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner
.java:380)
> >at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:861)
> >at org.jdom.input.SAXBuilder.build(SAXBuilder.java:302)
> >at org.jdom.input.SAXBuilder.build(SAXBuilder.java:373)
> >at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
> >at test.main(test.java:52)
> >
> >Any help in figuring out what is going on is appreciated.
> >
> >Regards
> >
> >
> >Alex Colic
>
>
>
>
> (-) Jochen Strunk
> (-) SIGNAL 7 Gesellschaft für Informationstechnologie mbH
> (-) Brüder-Knauß-Str. 79 - 64285 Darmstadt,
> (-) Tel: 06151 665402, Fax: 06151 665373
> (-) strunk at signal7.de, www.signal7.de
>
>
More information about the jdom-interest
mailing list