Avoid resolve dtd Reference

Hi! I’ve some little problems with Tamino Api4J.
Simple code:


public class inoTest{

	protected TXMLObjectModel model = TDOMObjectModel.getInstance();

	public static void main(String[] args) throws TException, IOException {
		TXMLObject xml = TXMLObject.newInstance(model);
		File f= new File("prop.xml");
		FileInputStream fin = new FileInputStream(f);
		xml.readFrom(fin);
		fin.close();
		xml.writeTo(System.out);
		}
	}

prop.xml contains:


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> 

<properties>
    <entry key="key">value</entry>
</properties>

For the record:


Exception in thread "main" com.softwareag.tamino.db.api.io.TStreamReadException( message: Problems during parsing input stream and building DOM document., tag: JavaTaminoAPI_4_2_0_53, java: 1.5.0_04, os: Windows XP 5.1 ):

        at com.softwareag.tamino.db.api.objectModel.dom.TDOMAdapter.internalReadFrom(Unknown Source)
        at com.softwareag.tamino.db.api.objectModel.dom.TDOMAdapter.readFrom(Unknown Source)
        at com.softwareag.tamino.db.api.objectModel.dom.TDOMAdapter.readFrom(Unknown Source)
        at inoTest.main(inoTest.java:10)
Caused by: java.net.ConnectException: Connection timed out: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.Socket.connect(Socket.java:507)
        at java.net.Socket.connect(Socket.java:457)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
        at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
        at sun.net.www.http.HttpClient.New(HttpClient.java:287)
        at sun.net.www.http.HttpClient.New(HttpClient.java:299)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:792)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:744)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:669)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:913)
        at java.net.URL.openStream(URL.java:1007)
        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        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 Source)
        at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.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 com.softwareag.tamino.db.api.objectModel.dom.TDOMReader.read(Unknown Source)
        at com.softwareag.tamino.db.api.objectModel.dom.TDOMReader.read(Unknown Source)
        at com.softwareag.tamino.db.api.objectModel.dom.TDOMReader.read(Unknown Source)
        ... 4 more
Java Result: 1

I understand that the parser tries to resolve the DTD reference. Since I have no Internet connection in my computer, this takes me to an error. It’s imposible to me to change that XML, it’s the Java XML for Properties, generated with Properties.storeToXML().
Any suggestion?
Thanks
PD: I’ve also tried the other three XMLModels. SAX, JDOM, Stream

Hello,
You can set a preference to turn off DTD resolution. You need a new line of code, which needs to be inserted before you try to create your new TXMLObject:

TPreference.getInstance().setUseApacheLoadExternalDTD( false );

The TPreference class is in package “com.softwareag.tamino.db.api.common” in TaminoAPI4J.jar.

Hope this helps.

Thank you for the package reference. I don’t know why, but the class is not in the Javadoc included my installation.
That remebers me that also the Interface TInputStreamCloseListener is not in the Javadoc.
How do you build the Javadoc? There are some holes.

Hi,

We are facing the same problem.

When we turn off the DTD resolution, the DTD declaration line from the XML document which is inserted is not seen in the document present in database.

Modifying the document mayn’t be accepted in some scenarios…

Is there any other way to resolve this?

Regards,
Aravind