的test.xml:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE email SYSTEM "test.dtd"> <email> <von>test@test.com</von> <zu>xxx@example.com</zu> <titel>Hello</titel> <text>Dear John....;-).</text> <prior type="schnell"/> </email>
test.dtd:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE email [ <!ELEMENT email (von,zu,titel,text,prior)> <!ELEMENT von (#PCDATA)> <!ELEMENT zu (#PCDATA)> <!ELEMENT titel (#PCDATA)> <!ELEMENT text (#PCDATA)> <!ATTLIST prior type CDATA #required > ]>
The markup declarations contained or pointed to by the document type declaration must be well-formed. [2]
请帮忙!!
您有重复的DOCTYPE声明.如果要引用外部DTD:
的test.xml
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE email SYSTEM "test.dtd"> <email> <von>test@test.com</von> <zu>xxx@example.com</zu> <titel>Hello</titel> <text>Dear John....;-).</text> <prior type="schnell"/> </email>
test.dtd
<!ELEMENT email (von,prior)> <!ELEMENT von (#PCDATA)> <!ELEMENT zu (#PCDATA)> <!ELEMENT titel (#PCDATA)> <!ELEMENT text (#PCDATA)> <!ELEMENT prior EMPTY> <!ATTLIST prior type CDATA #required >
如果您希望将DTD作为XML文件(内部子集)的一部分:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE email [ <!ELEMENT email (von,prior)> <!ELEMENT von (#PCDATA)> <!ELEMENT zu (#PCDATA)> <!ELEMENT titel (#PCDATA)> <!ELEMENT text (#PCDATA)> <!ELEMENT prior EMPTY> <!ATTLIST prior type CDATA #required > ]> <email> <von>test@test.com</von> <zu>xxx@example.com</zu> <titel>Hello</titel> <text>Dear John....;-).</text> <prior type="schnell"/> </email>
注意:您还缺少先前元素的ELEMENT声明.