Pattern vs. nillable

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">
<xs:pattern value="\d{3}(\.)?\d{3}(\.)?\d{3}-\d{2}"></xs:pattern>
</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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top