“任意数量的这些元素 - 以任何顺序”的XML Schema构造

时间:2021-03-13 17:14:31

I need to create an XML schema that looks something like this:

我需要创建一个看起来像这样的XML模式:

<xs:element name="wrapperElement">
<xs:complexType>
    <xs:sequence>
        <xs:element type="el1">
        <xs:element type="el2">
    </xs:sequence>

    <xs:WhatGoesHere?>
        <xs:element type="el3"> 
        <xs:element type="el4">
        <xs:element type="el5">
    </xs:WhatGoesHere?>

    <xs:sequence>
        <xs:element type="el6">
        <xs:element type="el7">
    </xs:sequence>
</xs:complexType>
</xs:element>

What I need is a replacement for "WhatGoesHere" such that any number of el3, el4 and el5 can appear in any order. For instance it could contain {el3, el3, el5, el3}

我需要的是替换“WhatGoesHere”,这样任何数量的el3,el4和el5都可以按任何顺序出现。例如,它可以包含{el3,el3,el5,el3}

Any idea on how to solve this?

关于如何解决这个问题的任何想法?

1 个解决方案

#1


13  

You want xs:choice with occurrence constraints:

你想要xs:choice与出现约束:

<xs:element name="wrapperElement">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="e11"/>
      <xs:element name="el2"/>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="el3"/>
        <xs:element name="el4"/>
        <xs:element name="el5"/>
      </xs:choice>
      <xs:element name="el6"/>
      <xs:element name="el7"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

#1


13  

You want xs:choice with occurrence constraints:

你想要xs:choice与出现约束:

<xs:element name="wrapperElement">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="e11"/>
      <xs:element name="el2"/>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="el3"/>
        <xs:element name="el4"/>
        <xs:element name="el5"/>
      </xs:choice>
      <xs:element name="el6"/>
      <xs:element name="el7"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>