D
Daniel Serodio
Is it possible to have an element which is both restricted by a pattern
and nillable?
Example schema:
<xs:simpleType name="cpfType">
<xs:restriction base="xs:string">
<xsattern value="\d{3}(\.)?\d{3}(\.)?\d{3}-\d{2}"></xsattern>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="pessoa-fisicaType">
<xs:sequence>
<xs:element type="cpfType" name="cpf" nillable="true"/>
<xs:element type="xs:string" name="nome" nillable="true"/>
</xs:sequence>
</xs:complexType>
Example XML:
<pessoa-fisica>
<cpf></cpf>
<nome>JOSE MANOEL ANDRADE GOMES</nome>
</pessoa-fisica>
Eclipse validator reports 2 errors:
cvc-pattern-valid: Value '' is not facet-valid with respect to pattern
'\d{3}(\.)?\d{3}(\.)?\d{3}-\d{2}' for type 'cpfType'.
cvc-type.3.1.3: The value '' of element 'cpf' is not valid.
and nillable?
Example schema:
<xs:simpleType name="cpfType">
<xs:restriction base="xs:string">
<xsattern value="\d{3}(\.)?\d{3}(\.)?\d{3}-\d{2}"></xsattern>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="pessoa-fisicaType">
<xs:sequence>
<xs:element type="cpfType" name="cpf" nillable="true"/>
<xs:element type="xs:string" name="nome" nillable="true"/>
</xs:sequence>
</xs:complexType>
Example XML:
<pessoa-fisica>
<cpf></cpf>
<nome>JOSE MANOEL ANDRADE GOMES</nome>
</pessoa-fisica>
Eclipse validator reports 2 errors:
cvc-pattern-valid: Value '' is not facet-valid with respect to pattern
'\d{3}(\.)?\d{3}(\.)?\d{3}-\d{2}' for type 'cpfType'.
cvc-type.3.1.3: The value '' of element 'cpf' is not valid.