您可以通过 DTD 在 XML 属性值中使用正斜杠“/”吗?
Can you use a forward slash "/" in an XML attribute value via DTD?
我有一个名为 item_category 的属性,我想用作枚举值 (h/w | s/w)。那可能吗?如果是怎么回事?基本上我试过了:
<!ATTLIST item
item_category (h/w | s/w) #REQUIRED>
但是我得到了像 Expecting "|".
和 Missing attribute presence #IMPLIED, #Required...
和 Expecting ")".
这样的错误,所以它实际上并没有将正斜杠作为值。
我认为你不能直接。
ATTLIST
中枚举的值必须是 NOTATION
或 NMTOKEN
。
https://www.w3.org/TR/REC-xml/#NT-AttlistDecl
[Definition: Enumerated attributes have a list of allowed values in their declaration ]. They must take one of those values. There are two kinds of enumerated attribute types:
Enumerated Attribute Types
[57] EnumeratedType ::= NotationType | Enumeration
[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' [VC: Notation Attributes]
[VC: One Notation Per Element Type]
[VC: No Notation on Empty Element]
[VC: No Duplicate Tokens]
[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' [VC: Enumeration]
[VC: No Duplicate Tokens]
/
不允许出现在 NMTOKEN
的值中。
允许作为NOTATION
的值。
<!NOTATION hw PUBLIC "h/w">
<!NOTATION sw PUBLIC "s/w">
<!ATTLIST item
item_category NOTATION (hw|sw) #REQUIRED>
]>
我有一个名为 item_category 的属性,我想用作枚举值 (h/w | s/w)。那可能吗?如果是怎么回事?基本上我试过了:
<!ATTLIST item
item_category (h/w | s/w) #REQUIRED>
但是我得到了像 Expecting "|".
和 Missing attribute presence #IMPLIED, #Required...
和 Expecting ")".
这样的错误,所以它实际上并没有将正斜杠作为值。
我认为你不能直接。
ATTLIST
中枚举的值必须是 NOTATION
或 NMTOKEN
。
https://www.w3.org/TR/REC-xml/#NT-AttlistDecl
[Definition: Enumerated attributes have a list of allowed values in their declaration ]. They must take one of those values. There are two kinds of enumerated attribute types:
Enumerated Attribute Types [57] EnumeratedType ::= NotationType | Enumeration
[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' [VC: Notation Attributes] [VC: One Notation Per Element Type] [VC: No Notation on Empty Element] [VC: No Duplicate Tokens]
[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' [VC: Enumeration] [VC: No Duplicate Tokens]
/
不允许出现在 NMTOKEN
的值中。
允许作为NOTATION
的值。
<!NOTATION hw PUBLIC "h/w">
<!NOTATION sw PUBLIC "s/w">
<!ATTLIST item
item_category NOTATION (hw|sw) #REQUIRED>
]>