2

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>

kjhughes
  • 98,039
  • 18
  • 159
  • 218
Matt Klaver
  • 99
  • 1
  • 10

1 Answers1

2

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

See also

kjhughes
  • 98,039
  • 18
  • 159
  • 218