XML 属性需要空值
XML attribute required with empty value
我已将属性 "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.
我已将属性 "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.