DTD 和混合内容
有人知道 mixet 内容元素(在 dtd 中)需要在末尾添加“*”吗?
例如:
我指的是我不想再次重复任何内容的情况...我只是希望能够在 #PCDATA 和其他元素之间进行选择。
我知道如果我在减法末尾删除“*”,我会得到一个糟糕的 DTD 减法... 但是 - 我不知道这是什么原因......
有人知道为什么吗?
Does someone know way a mixet content element (in dtd) there is a need to add the "*" at the end?
For example:<!ELEMENT note (#PCDATA|to|from|header|message)*>
I'm reffering to the case where I don't want to repeat anything again... I just want to be able to choose between #PCDATA and other elements.
I know that if I drop the "*" in the end of the decleration I will get a bad DTD decleration...
But - I have no idea what is the reason of that...
Anyone know why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您遇到此限制是因为混合内容模型只允许限制出现的元素,而不是它们的顺序或数量。恐怕这是 XML 规范 本身所要求的。
恐怕混合内容很难。该模型在设计时考虑了文档 - 当您考虑内联文本时它是有意义的,但在许多其他情况下则不然。如果您有选择,最佳实践建议您创建一个元素来包含您的 PCDATA。如果你不能,那么我担心你会受到混合内容模型的限制(恐怕使用另一种模式语言也没有多大帮助)。
You're hitting this restriction because the mixed content model is only allowed to constrain which elements occur not their order or the number of them. This is, I'm afraid, required by the XML Specification itself.
Mixed content is hard I'm afraid. The model was designed with documents in mind - it makes sense when you think of inline text but not in many other cases. If you have a choice, best practice would suggest that you create an element to contain your PCDATA. If you can't then I'm afraid you are stuck with the limits of mixed content models (using another schema language doesn't help much either I'm afraid).
您想要使用 ANY
另外,
*
是用于零到多次出现的运算符。所以(element|element2)*
表示或者/和You want to use ANY
Also, the
*
is the operator for zero to more occurrences. So the(element|element2)*
is saying either or/and