XML : An XSD element can contains a bool value or an attribute?

How can I define and xsd element that can work with both the follows soap request formats (where 'MyOption' is optional and may not be present)?

Request 1:

  <sdf:MyElement>true</sdf:MyElement>    

or

Request 2:

  <sdf:MyElement>      <sdf:MyOption>xxx</sdf:MyOption>      <Value>true</Value>  </<sdf:MyElement>    

I tried with this, but it work only with Request 2 format:

  <xs:element name="MyElement" default="false" minOccurs="0" maxOccurs="1">     <xs:complexType>        <xs:simpleContent>           <xs:extension base="xs:boolean">              <xs:attribute name="MyOption" type="xs:string" use="optional"/>           </xs:extension>         </xs:simpleContent>     </xs:complexType>  </xs:element>    

No comments:

Post a Comment