我已将属性“number”设置为#REQUIRED,但空值有效吗?
DTD:
<!ATTLIST person number CDATA #REQUIRED>
XML:
<person number="" />
最佳答案
是的,空值足以满足 XML 属性的#REQUIRED
约束。属性的值是无关紧要的;只需要属性的存在即可:
Validity constraint: Required Attribute
If the default declaration is the keyword
#REQUIRED
, then the attribute must be specified for all elements of the type in the attribute-list declaration.
关于XML 属性需要空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44999039/