我正在为一个项目编写 XML 模式。我无法解决以下问题:
一个元素不能自己嵌套,例如:
<document>
<text>
<b>
<i>
<a link="http://wikipedia.org">
<b />
</a>
</i>
</b>
</text>
</document>
不应允许此示例,因为 b 正在嵌套自身。所以我对你的问题是:“是否有可能禁止一个元素嵌套它自己,如果是,那么做这个伎俩的程序是什么?”
谢谢!
\莫顿·默勒
编辑:到目前为止,我只确保一个元素可以是它自己的子元素,而不是一个元素不能有一个它自己的后代。
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://cs.au.dk/dWebTek/WikiXML"
targetNamespace="http://cs.au.dk/dWebTek/WikiXML"
elementFormDefault="qualified">
<element name="wiki">
<complexType>
<choice maxOccurs="unbounded">
<!-- A lot of other element is listed here -->
<element name="bold" type="xs:boldnest"/> <!-- Missing nest function -->
</choice>
<complexType>
</element>
<complexType name="boldnest">
<choice maxOccurs="unbounded">
<element name="bold" minOccurs="0" maxOccurs="0" type="xs:boldnest"/>
<!-- All the other element is copy pasted in here -->
</choice>
</complexType>