【发布时间】:2020-04-19 20:06:58
【问题描述】:
我有这个 xml 内容,id 值从 1 到 193。
<member lang="en" id="UN193">
<name>Zimbabwe</name>
<admissionYear>1980</admissionYear>
<population year="2019">14645468</population>
<continent>Africa</continent>
<officialLangInfo>
<language script="Latin" family="Indo-European">English</language>
<language script="Latin" family="Niger–Congo">Chewa</language>
<language script="Latin" family="Niger–Congo">Kalanga</language>
<otherLanguage>Chibarwe</otherLanguage>
</officialLangInfo>
</member>
我创建了这个限制,这给了我一个错误验证文件。有什么建议?非常感谢。
<xs:attribute name="id" use="required">
<xs:simpleType>
<xs:restriction base="xs:ID">
<xs:pattern value="[UN][0-9]{1,3}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
【问题讨论】:
-
试试
UN\d{1,3} -
UN 不应放在方括号中。它们不是必需的。方括号表示 U 或 N,两者都需要。