4

Looking to figure out how to match either on a set sequence or no value. Example below of my sequence, but I'm stuck for how to get it to accept either the sequence as written, or the <body> tag existing with no value inside it.

<xs:element name="body">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="id"   type="xs:string"/>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="type" type="xs:string"/>
            <xs:element name="user" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

I want the above to match on either a blank (as below) or a correctly filled tag.

<body></body>

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
Matt Klaver
  • 169
  • 1
  • 10

1 Answers1

3

You can add a minOccurs="0" to xs:sequence to allow the entire sequence to be optional.

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240