当前位置 : 主页 > 网页制作 > xml >

在XML模式的complexType中使用?

来源:互联网 收集:自由互联 发布时间:2021-06-13
我定义了以下 XML complexTypes: 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="lossL
我定义了以下 XML complexTypes:

<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>

但是,在验证时,我收到一条错误,指出在复杂损失类型及其扩展名propLoss定义中不允许使用所有模型组.我做错了什么?

谢谢!

propLoss的一个问题是你不能在XML Schema(1.0)中扩展所有组.从规格:

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.

不确定丢失的问题是什么,除非它因propLoss错误而造成附带损害.

网友评论