如何使 xsd 中的顺序无关紧要且最大出现次数 > 1
How to make it such that order doesnt matter in xsd with maxOccurrence > 1
我有以下 xml,我愿意接受:
<Movies>
<Title>
<Platform>Hulu</Platform>
<PlatformID>500219855</PlatformID>
<Type>Movie</Type>
</Title>
<Title>
<Type>Movie</Type>
<Platform>Hulu</Platform>
<PlatformID>50019855</PlatformID>
<Platform>ITunes</Platform>
</Title>
</Movies>
我目前正在使用 xs:sequence
,但这限制了订购。我也尝试使用 xs:all
代替,但这只允许 maxOccurrence
为 0 或 1,因此在我有 2 个平台值的上述情况下不起作用。我将如何使用 xsd 场景完成上述操作?
您尝试过使用 <xsd:choice maxOccurs="unbounded"></xsd:choice>
关键是结合xs:choice和maxOccurs="unbounded"。如果您只使用 xs:all,您可以使用每个句点之一。
虽然 xs:any 有效,但它不会将您的选择限制为逐项列出的四个元素。它将允许任何东西,这几乎违背了模式的目的。
我有以下 xml,我愿意接受:
<Movies>
<Title>
<Platform>Hulu</Platform>
<PlatformID>500219855</PlatformID>
<Type>Movie</Type>
</Title>
<Title>
<Type>Movie</Type>
<Platform>Hulu</Platform>
<PlatformID>50019855</PlatformID>
<Platform>ITunes</Platform>
</Title>
</Movies>
我目前正在使用 xs:sequence
,但这限制了订购。我也尝试使用 xs:all
代替,但这只允许 maxOccurrence
为 0 或 1,因此在我有 2 个平台值的上述情况下不起作用。我将如何使用 xsd 场景完成上述操作?
您尝试过使用 <xsd:choice maxOccurs="unbounded"></xsd:choice>
关键是结合xs:choice和maxOccurs="unbounded"。如果您只使用 xs:all,您可以使用每个句点之一。
虽然 xs:any 有效,但它不会将您的选择限制为逐项列出的四个元素。它将允许任何东西,这几乎违背了模式的目的。