Reputation: 21
I'm really "noob" with XSD, but I'm doing my best.
I have this XML:
<nombre_completo xmlns:xsi="xxxx "xsi:noNamespaceSchemaLocation="nombre_completo.xsd">
<nombre>Jame Ruiz</nombre>
<apellido1>Sancho</apellido1>
<apellido2>Vera</apellido2>
</nombre_completo>
And This XSD:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="nombre_completo">
<xs:complexType>
<xs:sequence>
<xs:element name="nombre" type="verificar_nombre"/>
<xs:element name="apellido1" type="xs:string"/>
<xs:element name="apellido2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="verificar_nombre">
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z]*"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
All I Want its to Validate the name part. With a For Example Composed name: Miguel Angel, Jaime Ruiz. Or Just a Single Name like "Ramon" or "John".
I have tried:
[a-zA-Z]* [a-zA-Z]?
But nothing.
Upvotes: 0
Views: 96
Reputation: 10307
[a-zA-Z]* [a-zA-Z]
can accept nothing and one letter in front.
so you need something like this
[a-zA-Z]+ [a-zA-Z]*
This will give any combination of letters but can't be empty
[a-zA-Z]+
plus this that will give you empty or any combination of letters.
[a-zA-Z]*
Upvotes: 1