我想从基本类型派生元素。这种基本类型(我们称之为实体)有一个 id 属性。对于派生元素,我想为此属性添加限制(不同派生实体元素的不同限制):
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Entity">
<xs:attribute name="id">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z]+[0-9]+"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:element name="someEntity">
<xs:complexType>
<xs:complexContent>
<xs:extension base="Entity">
<xs:sequence>
<xs:element name="someAdditionalElement"/>
</xs:sequence>
<!-- I would like to restrict the attribute "id" for this entity to e.g. the pattern "SOME[0-9]+" -->
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="otherEntity">
<xs:complexType>
<xs:complexContent>
<xs:extension base="Entity">
<xs:sequence>
<xs:element name="otherAdditionalElement"/>
</xs:sequence>
<!-- I would like to restrict the attribute "id" for this entity to a differtnt pattern like e.g. "OTHER[0-9]+" -->
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
这可能吗?如果可以,怎么做?