OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Problem parsing XML file with Xerces-J

[ Lists Home | Date Index | Thread Index ]

The XML parser is trying to access the document at http://host/x.dtd (using
the java.net library) and gets a timeout because it isn't accessible.

The fact that you didn't request validation is irrelevant. It's a common,
and erroneous, belief that if you don't request validation then the parser
won't try to read the external DTD. It needs it to expand entity references.

Try either editing the DTD reference out of the file before parsing it, or
using an EntityResolver to satisfy the reference from somewhere else.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Midsummer Sun [mailto:midsummer.sun@gmail.com] 
> Sent: 31 March 2005 10:33
> To: xml-dev@lists.xml.org
> Subject: [xml-dev] Problem parsing XML file with Xerces-J
> 
> Hi Friends,
>    I am parsing a XML file using Xerces-J 2.6.2 using the DOM API. I
> am facing some problem. The XML document is available in my program in
> Java string form.
> 
> Here is relevant portion of code (with line numbers for 
> readibility) ..
> 
> 1) DocumentBuilderFactoryImpl factory = new 
> DocumentBuilderFactoryImpl();
> 2) DocumentBuilder builder = factory.newDocumentBuilder();
> 3) String rsp = "xmlstring";
> 4) Document document = builder.parse(new InputSource(new 
> StringReader(rsp)));
> 
> A sample xmlstring is (for line 3) -
> <?xml version='1.0' encoding='ISO-8859-1'?><!DOCTYPE MESSAGING SYSTEM
> 'http://host/x.dtd'><MESSAGING></MESSAGING>
> 
> (I am not using the validating mode. This XML is sent to my program by
> a remote process and DTD reference is redundant to me).
> 
> Line 4 is giving error (I am pasting full stack trace for 
> your reference) -
> java.net.ConnectException: Connection timed out: connect
>         at java.net.PlainSocketImpl.socketConnect(Native Method)
>         at java.net.PlainSocketImpl.doConnect(Unknown Source)
>         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
>         at java.net.PlainSocketImpl.connect(Unknown Source)
>         at java.net.Socket.connect(Unknown Source)
>         at java.net.Socket.connect(Unknown Source)
>         at sun.net.NetworkClient.doConnect(Unknown Source)
>         at sun.net.www.http.HttpClient.openServer(Unknown Source)
>         at sun.net.www.http.HttpClient.openServer(Unknown Source)
>         at sun.net.www.http.HttpClient.<init>(Unknown Source)
>         at sun.net.www.http.HttpClient.<init>(Unknown Source)
>         at sun.net.www.http.HttpClient.New(Unknown Source)
>         at sun.net.www.http.HttpClient.New(Unknown Source)
>         at sun.net.www.http.HttpClient.New(Unknown Source)
>         at 
> sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Sour
> ce)
>         at 
> sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
>         at 
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
> urce)
>         at 
> org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown So
> urce)
>         at 
> org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
>         at 
> org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source
> )
>         at 
> org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Sourc
> e)
>         at 
> org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(
> Unknown Source)
>         at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
> known Source)
>         at 
> org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>         at 
> org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>         at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
>         at 
> org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
>         at XYZ.main(XYZ.java:47)
> 
> I don't know what this call has to do with java.net package !
> 
> I'll appreciate help in understanding what is going wrong, 
> and how to solve it..
> 
> Best regards,
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS