dtd和混合内容 [英] dtd and mixed content

查看:98
本文介绍了dtd和混合内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道混合内容元素(在dtd中)需要在末尾添加"*"吗?

Does someone know way a mixet content element (in dtd) there is a need to add the "*" at the end?

例如:<!ELEMENT note (#PCDATA|to|from|header|message)*>

我不想再重复任何事情了……我只想能够在#PCDATA和其他元素之间进行选择.

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.

我知道,如果在清算结束时放下"*",我将得到错误的DTD清算... 但是-我不知道是什么原因...

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...

有人知道为什么吗?

推荐答案

您遇到了此限制,因为仅允许混合内容模型约束哪些元素出现而不是它们的顺序或数量.恐怕这是 XML规范本身所必需的.

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.

混合的内容很难.该模型在设计时就考虑了文档-当您想到内联文本时很有意义,但在其他许多情况下却没有.如果可以选择,最佳实践将建议您创建一个包含PCDATA的元素.如果不能,那么恐怕您会受制于混合内容模型的限制(恐怕使用另一种模式语言也无济于事).

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).

这篇关于dtd和混合内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆