XSD验证 - 正则表达式



我真的和XSD一样" noob",但我正在尽力而为。

我有这个XML:

<nombre_completo xmlns:xsi="xxxx "xsi:noNamespaceSchemaLocation="nombre_completo.xsd">
  <nombre>Jame Ruiz</nombre>
  <apellido1>Sancho</apellido1>
  <apellido2>Vera</apellido2>
</nombre_completo>

和此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>

我只想验证名称部分。例如,构成名称:Miguel Angel,Jaime Ruiz。或者只是一个名字,例如"拉蒙"或"约翰"。

我尝试过:

[a-zA-Z]* [a-zA-Z]? 

但是什么都没有。

[a-zA-Z]* [a-zA-Z]什么都不接受,一个字母在前面。 所以你需要这样的东西

[a-zA-Z]+ [a-zA-Z]*

这将给出任何字母的组合,但不能为空

 [a-zA-Z]+

加上这个会给您空的或任何字母组合。

[a-zA-Z]*

最新更新