Jdom dom4j Parsing XML does not validate DTD doctype

Source: Internet
Author: User
Tags socket error
First, write in all before:
Because Dom4j and jdom on this issue is the same way to deal with, but one is Saxbuilder a saxreader, here to jdom distance, as for the dom4j only need to replace the same.
Ii. situation in which the problem occurred
When you read a DTD-validated XML file with Jdom, your network is not available. The following error occurs:
1, the code is as follows
Package DOM;

Import Java.io.File;

Import org.jdom.Document;
Import Org.jdom.input.SAXBuilder;

public class Testjdom {
public static void Main (string[] args) {
File File = new file ("./src/dom/aiwf_aiservice.xml");
if (file.exists ()) {
Saxbuilder builder = new Saxbuilder ();
try {
Document doc = builder.build (file);
System.out.println (DOC);
catch (Exception e) {
E.printstacktrace ();
}
} else {
System.out.println ("Can not find XML file:"
+ File.getabsolutepath ());
}
}
}

2,xml document;? XML version= "1.0" encoding= "GBK"?>
<! DOCTYPE Workflow Public "-//opensymphony group//dtd osworkflow 2.8//en" "http://www.opensymphony.com/osworkflow/ Workflow_2_8.dtd ">
< Workflow >
...............
</Workflow >


3, the error is as follows Java.net.SocketException:Permission Denied: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 Com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity (xmlentitymanager.java:973)
At Com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity (xmlentitymanager.java:905)
At Com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity (xmlentitymanager.java:872)
At Com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource (xmldtdscannerimpl.java:282)
At Com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$dtddispatcher.dispatch ( xmldocumentscannerimpl.java:1021)
At Com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument ( xmldocumentfragmentscannerimpl.java:368)
At Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (xml11configuration.java:834)
At Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (xml11configuration.java:764)
At Com.sun.org.apache.xerces.internal.parsers.XMLParser.parse (xmlparser.java:148)
At Com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse (abstractsaxparser.java:1242)
At Org.jdom.input.SAXBuilder.build (saxbuilder.java:453)
At Org.jdom.input.SAXBuilder.build (saxbuilder.java:810)
At Org.jdom.input.SAXBuilder.build (saxbuilder.java:789)
At Dom. Testjdom.main (testjdom.java:26)


Three, parsing reason
Jdom parsing to
doctype workflow public  when executing a build-/OPENSYMPHONY&NBSP;GROUP//DTD  osworkflow 2.8//en " " HTTP://WWW.OPENSYMPHONY.COM/OSWORKFLOW/WORKFLOW_2_8.DTD
will go to read http:// www.opensymphony.com/osworkflow/workflow_2_8.dtd  here the DTD file to verify, but because the network is not a pass, so will be reported socket error.

Four, workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.