我想打一个XSD,将允许类似如下:制约混合模式XSD
<document>
Here is first paragraph with e.g. <i>itallic</i> and <b>bold</b>.
<p>Here is the second paragraph also with some <i>itallic</i></p>
<p>Here is the third paragraph</p>
<!-- If there is any character data here it should be rejected -->
</document>
例如,我想允许第一段没有< p>标签角落找寻它,但后续段落必须具备。
任何提示我应该看什么?在我看来,我无法通过将mixed =“true”放在复杂类型定义上来获得我想要的结果。
更新:这不是因为第一段是特殊的。这仅仅是因为我想避免写一些标签。例如,我希望能够让这个命令列表:
<ol>
<le>Here is the first list element, only one paragraph, easy to write</le>
<le>Here is the second element.
<p>The second element has an extra paragaph.</p>
</le>
</ol>
正常情况下将是只有一个在每个列表元素段落所以很讨厌不得不写两个<乐>和< p>。不过,我想支持列表元素中多个段落的不寻常情况。
你有没有尝试过你可以分享? – psubsee2003
有时当XSD不允许某种设计时,这是因为XSD的设计者不想鼓励人们以这种方式使用XML。有时候我认为他们是对的。 –