gpt4 book ai didi

xml - 使用 in XML schema's complexType?

转载 作者:数据小太阳 更新时间:2023-10-29 02:21:07 25 4
gpt4 key购买 nike

我定义了以下 XML complexType:

<xs:complexType name="loss">
<xs:all>
<xs:element name="lossCause" type="xs:string"/>
<xs:element name="lossDate" type="xs:dateTime"/>
<xs:element name="lossDescription" type="xs:string"/>
<xs:element name="lossLocation" type="address" minOccurs="0"/>
<xs:element name="lossTime" type="xs:string" minOccurs="0"/>
<xs:element name="officials" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="official" type="official" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="incidentOnly" type="xs:boolean" use="required"/>
<xs:attribute name="lawsuit" type="xs:boolean" use="required"/>
</xs:complexType>

和:

<xs:complexType name="propLoss">
<xs:complexContent>
<xs:extension base="loss">
<xs:all>
<xs:element name="damageDescription" type="xs:string"/>
<xs:element name="property" type="property"/>
<xs:element name="responsibleParty" type="contact" minOccurs="0"/>
</xs:all>
<xs:attribute name="businessOperational" type="xs:boolean" use="required"/>
<xs:attribute name="propertyLivable" type="xs:boolean" use="required"/>
<xs:attribute name="weatherRelated" type="xs:boolean" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>

但是,在验证时,我收到一条错误消息,指出 loss complexType 及其扩展中不允许使用 all 模型组propLoss 定义。我做错了什么?

谢谢!

最佳答案

propLoss 的一个问题是您无法在 XML Schema (1.0) 中扩展 all 组。来自规范:

Note: This specification allows only appending, and not other kinds of extensions. This decision simplifies application processing required to cast instances from derived to base type. Future versions may allow more kinds of extension, requiring more complex transformations to effect casting.

不确定 loss 的问题是什么,除非它是 propLoss 错误的附带损害。

关于xml - 使用 <xs :all> in XML schema's complexType?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7603317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com