如何声明空或非空 dtd 元素
如何在 DTD 中声明自闭合或包含元素的元素?我找到了 * 运算符,但我无法验证这是否也可以验证空元素。
我已经尝试过这个,但它在 Visual Studio 中给出编译错误,指出未声明 EMPTY
元素:
<!ELEMENT File (Annotations|EMPTY)>
<!ELEMENT Annotations (State*)>
<!ELEMENT State EMPTY>
或者我可以尝试以下操作,但我无法验证它是否正常:
<!ELEMENT File (Annotations?)>
...
How can I declare an element in DTD that is self-closing or contains elements? I have found the *
-operator, but I can't verify if this can also validate empty elements.
I have tried this, but it gives a compilation error in Visual Studio saying that the EMPTY
element is not declared:
<!ELEMENT File (Annotations|EMPTY)>
<!ELEMENT Annotations (State*)>
<!ELEMENT State EMPTY>
Or I could try the following, but I can't validate if it is ok:
<!ELEMENT File (Annotations?)>
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您的
File
元素声明是正确的:您所说的是
File
可以包含零个或一个Annotations
元素。另外,如果您使用
*
而不是?
,您会说File
可以包含零个或更多< /em>注释
元素。有效示例:
Yes, your element declaration for
File
is correct:What you're saying is that
File
can contain zero or oneAnnotations
element.Also, if you would've used
*
instead of?
, you would've been sayingFile
can contain zero or moreAnnotations
elements.Valid examples: