【发布时间】:2011-11-04 15:38:43
【问题描述】:
我正在 Visual Studio 2010 中编写一个 XSD 架构文件。我想定义一个不需要的复杂类型,并且在 xml 中有无限的整体。我使用了 minOccurs 和 maxOccurs 属性,但在编辑器中出现错误,即不允许使用这些属性(minOccurs / maxOccurs)。我可以将它们添加到简单类型,但不能添加到复杂类型。如何定义一个复杂类型可以有 0 到多次出现?
这是我使用的 xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="patient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
【问题讨论】: