在 XML 中将属性类型声明为实体时出现验证错误
Validation error while declaring attribute type as entity in XML
这是我的 DTD 文件。
?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.0.7 NT (http://www.xmlspy.com) by Manukyan (YSU) -->
<!ENTITY xxx "ccc">
<!ENTITY yyy "ddd">
<!ELEMENT book (author+, title, publisher)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ATTLIST title
aaa ENTITY #IMPLIED
>
这里是对应的DSD文件。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book SYSTEM "C:\Users\PC\Desktop\XML\XMLDB\XML\BOOK.DTD">
<book>
<author>asd</author>
<title aaa="xxx"/>
<publisher/>
</book>
我收到一个验证错误。
属性 'aaa' 的值部分 'xxx' 必须是未解析实体的名称。
作为@Daniel Haley explains in his answer 的类似问题,如果您为 ccc
添加实体声明和符号 (NDATA) 声明,则 XML 现在有效:
<!DOCTYPE book [
<!NOTATION ccc SYSTEM "ccc">
<!ENTITY xxx SYSTEM "ccc" NDATA ccc>
<!ENTITY yyy "ddd">
<!ELEMENT book (author+, title, publisher)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ATTLIST title aaa ENTITY #IMPLIED>
]>
<book>
<author>asd</author>
<title aaa="xxx"/>
<publisher/>
</book>
这是我的 DTD 文件。
?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.0.7 NT (http://www.xmlspy.com) by Manukyan (YSU) -->
<!ENTITY xxx "ccc">
<!ENTITY yyy "ddd">
<!ELEMENT book (author+, title, publisher)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ATTLIST title
aaa ENTITY #IMPLIED
>
这里是对应的DSD文件。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book SYSTEM "C:\Users\PC\Desktop\XML\XMLDB\XML\BOOK.DTD">
<book>
<author>asd</author>
<title aaa="xxx"/>
<publisher/>
</book>
我收到一个验证错误。 属性 'aaa' 的值部分 'xxx' 必须是未解析实体的名称。
作为@Daniel Haley explains in his answer 的类似问题,如果您为 ccc
添加实体声明和符号 (NDATA) 声明,则 XML 现在有效:
<!DOCTYPE book [
<!NOTATION ccc SYSTEM "ccc">
<!ENTITY xxx SYSTEM "ccc" NDATA ccc>
<!ENTITY yyy "ddd">
<!ELEMENT book (author+, title, publisher)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ATTLIST title aaa ENTITY #IMPLIED>
]>
<book>
<author>asd</author>
<title aaa="xxx"/>
<publisher/>
</book>