XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Fw: How to open XML file that reference entity resolver (DTD) - Complete

Hi,

Left out the code that opens the Sport.xml.

Thanks,

Jack


----- Forwarded Message ----
From: Jack Bush <netbeansfan@yahoo.com.au>
To: xml-dev@lists.xml.org
Sent: Mon, 28 June, 2010 10:05:19 PM
Subject: How to open XML file that reference entity resolver (DTD)

Hi All,
 
I am trying to read an XML document which reference an entity resolver at the beginning and failed to open. The first few lines are as follows:
 1. <?xml version="1.0" encoding="UTF-8"?>
2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
3. <html xmlns="http://www.w3.org/1999/xhtml"; xmlns:html="http://www.w3.org/1999/xhtml";><head><script type="text/javascript">
.....
 
Below is the error output encountered:
 
java.net.UnknownHostException: www.w3.org
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClientHttpURLConnection.java:860)
at sun.net.www.protocol.http.HttpURLConnection.plainConnectHttpURLConnection.java:801)
at sun.net.www.protocol.http.HttpURLConnection.connectHttpURLConnection.java:726)
at sun.net.www.protocol.http.HttpURLConnection.getInputStreamHttpURLConnection.java:1049)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntityXMLEntityManager.java:677)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntityXMLEntityManager.java:1315)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntityXMLEntityManager.java:1282)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSourceXMLDTDScannerImpl.java:283)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatchXMLDocumentScannerImpl.java:1193)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.nextXMLDocumentScannerImpl.java:1090)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.nextXMLDocumentScannerImpl.java:1003)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.nextXMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.nextXMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocumentXMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parseXML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parseXML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parseXMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parseAbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parseSAXParserImpl.java:522)at org.jdom.input.SAXBuilder.build(SAXBuilder.java:489)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:888)
 
Here is the few lines that open the XML document:
 
a. BufferedReader incomingbrXml = new BufferedReader(new FileReader("C:\Sport.xml"));
b. SAXBuilder saxBuilder = new SAXBuilder(false);
c. Document jdomXmlDocument = saxBuilder.build(incomingbrXml);
On the other hand, it was possible to open it by removing the entity reference document on line 2. As a result, I would like to find out:
( i ) How to load an XML document without having to look up the DTD file which is of no use to me? 
( ii ) Otherwise, how to come up with a local entity resolver to overcome this issue?
 
I am confused with different implementations of the few solutions available.
Many thanks,
Jack






[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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

Copyright 1993-2007 XML.org. This site is hosted by OASIS