Home > database >  How relax enum in xsd for value outside enum
How relax enum in xsd for value outside enum

Time:09-26

Sorry if this is a stupid question but have to ask to know if this is possible So this is XSD

<xs:simpleType name="PhoneTypeEnum">
    <xs:restriction base="xs:string">
        <xs:enumeration value="Fax"/>
        <xs:enumeration value="Voice"/>
        <xs:enumeration value="Pager"/>
    </xs:restriction>
</xs:simpleType>

The relaxation is below

  1. When we get values where fax or FAX the validation should not fail and still except as Fax as correct value.
  2. When there is no values matching either of Fax ,Voice or Pager then also XSD validation should not fail but go as unknown as values .

Is this possible in XSD schema validation ? If not then we have to do this in custom code validation in java .

Please suggest if this is doable ?

CodePudding user response:

With XSD 1.0 the only way to do case-blind matching is along the lines

<xs:restriction base="xs:string">
  <xs:pattern value="[Ff][Aa][Xx]|[Vv][Oo][Ii][Cc][Ee]|..."/>
</xs:restriction>

With XSD 1.1 you could use an assertion instead.

But I don't understand your requirement that validation shouldn't fail if the conditions aren't met. (Technically, validation never fails: it reports an element as being either valid or invalid. However, most schema processors don't make it easy to validate a document and then inspect the nodes to see which are valid and which aren't.)

  • Related