考虑以下架构:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Root">
<xs:sequence>
<xs:element ref="Child" />
<xs:element name="Child2" type="Child" />
</xs:sequence>
<xs:attribute ref="Att" />
<xs:attribute name="Att2" type="Att" />
</xs:complexType>
<xs:complexType name="Child">
<xs:attribute ref="Att" />
</xs:complexType>
<xs:attribute name="Att" type="xs:integer" />
</xs:schema>
第ref
6 行的 to "Child" 失败,而第type
7 行的验证通过。对于属性,ref
成功而type
失败。我试图理解为什么。
我的理解ref
是它只是引用另一个元素并指定您希望在该位置看到引用类型的实例(具有定义中给出的名称)。显然我错了,那么ref
实际上是什么意思?