58,452
社区成员
发帖
与我相关
我的任务
分享
[Fatal Error] contents.dtd:4:3: The markup declarations contained or pointed to by the document type declaration must be well-formed.
org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at com.jimshi.firstPrj.testXml.SAXTreeView.buildTree(SAXTreeView.java:45)
at com.jimshi.firstPrj.testXml.SAXTreeView.init(SAXTreeView.java:36)
at com.jimshi.firstPrj.testXml.SAXTreeView.main(SAXTreeView.java:61)
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT book (title, contents)>
<!ATTLIST book xmlns CDATA #REQUIRED>
<!ElEMENT title (#PCDATA)>
<!ELEMENT contents (chapter+)>
<!ElEMENT chapter (topic+)>
<!ATTLIST chapter title CDATA #REQUIRED>
<!ELEMENT topic EMPTY>
<!ATTLIST topic name CDATA #REQURED>
<?xml version="1.0"?>
<!DOCTYPE book SYSTEM "Config/contents.dtd">
<!-- content of book -->
<book xmlns="com.jimshi.firstPrj.testXml">
<title>Java and XML</title>
<!-- list of chapters -->
<contents>
<chapter title="Introduction">
<topic name="XML Matters" />
<topic name="What's Important" />
<topic name="The Essentials" />
<topic name="What's Next?" />
</chapter>
<chapter title="Nuts and Bolts">
<topic name="The Basics" />
<topic name="Constraints" />
<topic name="Transformation" />
<topic name="And more..." />
<topic name="What's Next?" />
</chapter>
<chapter title="SAX">
<topic name="Getting Prepared" />
<topic name="SAX Readers" />
<topic name="Content Handlers" />
<topic name="Gotchars!" />
<topic name="What's Next?" />
</chapter>
<chapter title="Advanced SAX">
<topic name="Properties and Features" />
<topic name="More Handlers" />
<topic name="Filters and Writers" />
<topic name="Gotchars!" />
<topic name="What's Next?" />
</chapter>
<chapter title="DOM">
<topic name="The Document Object Model" />
<topic name="Serialization" />
<topic name="Mutability" />
<topic name="GotChar!" />
<topic name="What's Next?" />
</chapter>
<!-- to be continued -->
</contents>
</book>
XMLReader reader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
InputStream instream = new FileInputStream(xmlURI);
InputSource inputSource = new InputSource(instream);
reader.parse(inputSource);