【发布时间】:2014-05-17 16:50:11
【问题描述】:
这是我编写的一个简化的 XML Schema 示例:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://pius.lt" xmlns="http://pius.lt" elementFormDefault="qualified">
<xs:complexType name="person">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="email" type="xs:string"/>
<xs:element name="sex" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="user">
<xs:complexContent>
<xs:extension base="person">
<xs:sequence>
<xs:element name="password" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:integer" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="admin">
<xs:complexContent>
<xs:restriction base="user">
<xs:sequence>
<xs:element name="email" type="xs:string" fixed="admin@pius.lt"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
我得到的错误是:
Not valid.
Error - Line 22, 31: org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 31; rcase-Recurse.2: There is not a complete functional mapping between the particles.
Error - Line 22, 31: org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 31; derivation-ok-restriction.5.4.2: Error for type 'admin'. The particle of the type is not a valid restriction of the particle of the base.
我错过了什么?
附:是否可以对该“电子邮件”字段应用模式限制?类似于.+@example.com。
【问题讨论】:
标签: xml schema restriction