dtd 的以下部分无效/工作:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root [
<!ELEMENT root (height)>
<!ENTITY % objectPropAttr
"min CDATA #REQUIRED
max CDATA #REQUIRED">
<!ELEMENT height EMPTY>
<!ATTLIST height %objectPropAttr;>
]>
<!-- xml can be left out, since parser never reaches it -->
<root>
<height min="1" max="5"/>
</root>
编辑:
我正在使用java来读取xml:
final File file = new File("file.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setValidating(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
dBuilder.parse(file);
错误信息:
必须在元素“height”的属性列表声明中提供属性名称。