How do I make items optional in ?

后端 未结 2 697
情书的邮戳
情书的邮戳 2020-12-18 22:43

I have such xsd. These all fields can exist or not and in unpredictable order.




        
相关标签:
2条回答
  • 2020-12-18 23:28

    You need to put the minOccurs on the individual elements, not the <xs:all>, i.e.

    <xs:all>
        <xs:element ref="field1" minOccurs="0"/>
        <xs:element ref="field2" minOccurs="0"/>
        <xs:element ref="field3" minOccurs="0"/>
        <xs:element ref="field4" minOccurs="0"/>
        <xs:element ref="field5" minOccurs="0"/>
    </xs:all>
    

    Putting minOccurs="0" on the <xs:all> is saying that entire group may be omitted, not individual elements.

    See XML Schema docs.

    0 讨论(0)
  • 2020-12-18 23:42

    try like this in all

     <xs:element ref="field4" minOccurs="0" >
    
    0 讨论(0)
提交回复
热议问题