问题描述
- DTD的ATTLIST没有效果
- 定义了xml和dtd文件,但是dtd的属性约束没有效果。
xml 文件
<?xml version=""1.0"" encoding=""UTF-8""?><!DOCTYPE books SYSTEM ""books2.dtd""><books> <book id=""a123"" city=""阿斯顿""> <name> </name> <author> </author> <price> </price> </book> <book id=""a123""> <name> </name> <author> </author> <price> </price> </book></books>
下面是dtd文件
<?xml version=""1.0"" encoding=""UTF-8""?><!ELEMENT books (book+)><!ELEMENT book (name?author(price|money))><!ELEMENT name (#PCDATA)><!ELEMENT author (#PCDATA)><!ELEMENT price (#PCDATA)><!ATTLIST book id ID #REQUIRED title CDATA #IMPLIED lang CDATA #FIXED ""固定值"" category CDATA ""默认值"" pId IDREF #REQUIRED city (北京|上海|广州) #REQUIRED>
时间: 2024-10-23 12:56:47