making an element optional using xsd -cvc-length-valid ERROR -
<xs:element name="currencycode" minoccurs="0"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:length value="3" /> </xs:restriction> </xs:simpletype> </xs:element>
but if value empty returns error
cvc-length-valid: value '' length = '0' not facet-valid respect length '3' type '#anontype_currencycodeserviceservicelist'.
so how can deal ?
your schema allows omitt currencycode
element if present value must string 3 characters length.
you weaken restriction allow 0-length values specifying min , max length:
<xs:element name="currencycode" minoccurs="0"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:minlength value="0" /> <xs:maxlength value="3" /> </xs:restriction> </xs:simpletype> </xs:element>
this allow values "eu " not valid currency code.
a different approach be, specify list of valid currency code values , include empty string valid code:
<xs:element name="currencycode" minoccurs="0"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:enumeration value=""/> <xs:enumeration value="usd"/> <xs:enumeration value="gbp"/> <xs:enumeration value="eur"/> <!-- add currency codes need --> </xs:restriction> </xs:simpletype> </xs:element>
Comments
Post a Comment