I have xsd schema that define Gender element that accepts only F or M value but I want it also to accept empty <Gender/> element. How to fix following schema?
...
<xs:simpleTyp开发者_开发百科e name="Gender">        
        <xs:restriction base="xs:string">
            <xs:enumeration value="M" />
            <xs:enumeration value="F" />
        </xs:restriction>
</xs:simpleType>
...
Have you tried adding:
<xs:enumeration value="" />
?
However, this is bad practice. If you want to represent this information in the instance documents, you should omit the <Gender> element altogether, rather than providing an empty one.  Also, it's unclear what <Gender/> means - does this mean "no gender", or "unknown gender"?  If it's one of those possibilities, perhaps you should add those to the eneration:
<xs:simpleType name="Gender">        
        <xs:restriction base="xs:string">
            <xs:enumeration value="M" />
            <xs:enumeration value="F" />
            <xs:enumeration value="unknown" />
        </xs:restriction>
</xs:simpleType>
You could use a pattern instead:
<xs:simpleType name="Gender">        
   <xs:restriction base="xs:string">
      <xs:pattern value="(M|F)?"/>
   </xs:restriction>
</xs:simpleType>
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论