I have the following XML:
<customer>
<name>John Paul</name>
<cpf_cnpj>1376736333334</cpf_cnpj>
</customer>
The <cpf_cnpj>
element must have a minimum size of 11 and a maximum size of 15, and there can only be numeric (between 0 and 9) characters. My XSD is looking like this:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="customer">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="cpf_cnpj" minOccurs="1" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="11"/>
<xs:maxLength value="15"/>
<xs:pattern value="[0-9]{15}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
My problem is that on the xs:pattern
node, I don't know what to use, because despite the fact the I have a minLenght of 11 and maxLenght of 15, because of the {15}, the XML does not parse if a have an 11 to 14 sized value.
How can I have a variable size ranging from 11 to 15, and enforce only numeric characters for this node?
Tks!