xsd:extension、xsd:restriction、使用="prohibited"?

xsd:extension, xsd:restriction, and use="prohibited"?

所以我这里有这个代码片段:

<xs:complexType name="TT1">
    <xs:simpleContent>
        <xs:extension base="xs:string">
            <xs:attribute name="A1" type="xs:integer" use="required"/>
            <xs:attribute name="A2" type="xs:integer" use="optional"/>
        </xs:extension>
    </xs:simpleContent>
</xs:complexType>

<xs:complexType name="TT2">
    <xs:simpleContent>
        <xs:restriction base="TT1">
            <xs:attribute name="A1" use="prohibited"/>
        </xs:restriction>
    </xs:simpleContent>
</xs:complexType>

问题是:这整件事有效吗?

我唯一看到的是TT1:

<xs:extension base="xs:string">

这是无意义的,因为 A1A2 的类型应该是整数。

还有什么我看不到的吗?

P.S。我不太确定 TT2 中 use="prohibited" 的意义,但我不知道为什么。

which is nonsensical since the types for A1 and A2 are supposed to be integer.

不,这不是无稽之谈。 A1A2 是属性,它们的类型可以独立于其关联元素 (TT1) 的内容类型来定义,xs:string.

P.S. I'm not quite sure about the sense of the use="prohibited" in TT2 but I don't know why.

如果这种覆盖尝试让您感到不安,那应该是这样。不允许通过将其切换为禁止来覆盖必需的属性。所以,不,这个 XSD 片段无效。