Xml XSD使用的xs:group元素不是按特定顺序排列的

Xml XSD使用的xs:group元素不是按特定顺序排列的,xml,xsd,Xml,Xsd,我有以下xml结构 <library> <propertySet> <SUPorganisationId></SUPorganisationId> <SUPdataCategory></SUPdataCategory> <SUPguId></SUPguId> <LIBuserNotice></LIBuserNotice> </pro

我有以下xml结构

<library>
  <propertySet>
    <SUPorganisationId></SUPorganisationId>
    <SUPdataCategory></SUPdataCategory>
    <SUPguId></SUPguId>
    <LIBuserNotice></LIBuserNotice>
  </propertySet>
</library>

属性集内的属性可以出现一次(minOccurs=“0”maxOccurs=“1”),并且可以是任意顺序。在创建XSD时,我希望将一些属性(前缀为SUP)分组以供进一步使用。因此,我提出了以下xsd片段

<xs:element name="propertySet">
  <xs:complexType>
    <xs:all>
      <xs:group ref="CORproperties"/>
      <xs:element name="LIBuserNotice" type="xs:string" minOccurs="0" maxOccurs="1"/>
    </xs:all>
  </xs:complexType>
<xs:element name="propertySet">

<xs:group name="CORproperties">
  <xs:all>
    <xs:element name="SUPorganisationId" type="xs:integer" minOccurs="0" maxOccurs="1"/>
    <xs:element name="SUPdataCategory" type="xs:integer" minOccurs="0" maxOccurs="1"/>
    <xs:element name="SUPguId" type="xs:string" minOccurs="0" maxOccurs="1"/>
  </xs:all>
</xs:group>


有了这个xsd,我得到的错误是,xs:all的用法不正确。我不得不使用xs:all,因为没有显示属性的顺序。但是如果我使用xs:sequence,它可以正常工作。有人能告诉我正确的路径吗?

xs:all
的注释中,我们看到它不能有组:

<all
   id = ID
   maxOccurs = 1 : 1
   minOccurs = (0 | 1) : 1
   {any attributes with non-schema namespace . . .}>
   Content: (annotation?, element*)
</all>

您可以使用
来执行此操作。如果以这种方式重构架构,它将正常工作:

警告:它仅在XSD 1.1中可用。在XSD 1.0中,它是不允许的。

<xs:element name="propertySet">
    <xs:complexType>
     <xs:complexContent>
         <xs:extension base="CORProperties">
             <xs:all>
                 <xs:element name="LIBuserNotice" type="xs:string" minOccurs="0" maxOccurs="1"/>
             </xs:all>
         </xs:extension>
     </xs:complexContent>
    </xs:complexType>
</xs:element>

<xs:complexType name="CORProperties">
    <xs:all>
        <xs:element name="SUPorganisationId" type="xs:integer" minOccurs="0" maxOccurs="1"/>
        <xs:element name="SUPdataCategory" type="xs:integer" minOccurs="0" maxOccurs="1"/>
        <xs:element name="SUPguId" type="xs:string" minOccurs="0" maxOccurs="1"/>
    </xs:all>
</xs:complexType>


谢谢,托尼。但是如果我使用choice,则propertySet中只允许有一个属性元素,这在本例中是不允许的。@Prabudasrirahal make your choice
maxOccurs
unbounded可以使它出现多次,当然,它可能有重复的属性元素。这不能满足您的需要吗?是的,不幸的是,我不能有副本。据我所知,
extension
组织的内容在
super
sub
的元素之间有顺序,xsd 1.1有什么变化吗?@potame谢谢您的建议。我尝试了您的complexContent解决方案,但complexContent似乎不支持xs:all。我得到以下错误异常:cos all limited.1.2:所有模型组必须出现在{min ocurses}={max ocurses}=1的粒子中,并且该粒子必须是构成复杂类型定义的{content type}的对的一部分。它可以与xs:sequence配合使用,但我不能使用它,因为我想忽略顺序;您是否已检查是否允许使用XSDV1.1,并已将模式版本设置为1.1?否则,默认情况下,架构版本为“1.0”,引发的异常是我在此特定版本中得到的异常。非常感谢,这是导致此错误的另一个问题。这正是我所需要的。你让我很开心。谢谢
<xs:element name="propertySet">
    <xs:complexType>
     <xs:complexContent>
         <xs:extension base="CORProperties">
             <xs:all>
                 <xs:element name="LIBuserNotice" type="xs:string" minOccurs="0" maxOccurs="1"/>
             </xs:all>
         </xs:extension>
     </xs:complexContent>
    </xs:complexType>
</xs:element>

<xs:complexType name="CORProperties">
    <xs:all>
        <xs:element name="SUPorganisationId" type="xs:integer" minOccurs="0" maxOccurs="1"/>
        <xs:element name="SUPdataCategory" type="xs:integer" minOccurs="0" maxOccurs="1"/>
        <xs:element name="SUPguId" type="xs:string" minOccurs="0" maxOccurs="1"/>
    </xs:all>
</xs:complexType>