xsd validation ERROR with both minOccurs and length used simultaneously -
<xsd:element name="currencycode" minoccurs="0" type="xsd:string"> <xsd:simpletype> <xsd:restriction> <xsd:length value="3"/> </xsd:restriction> </xsd:simpletype> </xsd:element>
i want currencycode optional value , if @ there value should have length of 3 letters .. either currencycode can have length=0 or length=3
when use above code validator returns error when there empty field
so how can deal ??
have not tried (do not have suitable env set on machine) according specification can follows:
<xsd:element name="currencycode" minoccurs="0" type="xsd:string"> <xsd:simpletype> <xsd:restriction base="xsd:string"> <xsd:pattern value="(?:^$|\w{3})"/> </xsd:restriction> </xsd:simpletype> </xsd:element>
regular expression (?:^$|\w{3})
matches either empty string or 3 word characters. can use (?:^$|[a-z]{3})
in case want accept currency codes in upper case.
Comments
Post a Comment