使用 <xs:all>在 XML 模式的 complexType 中? [英] Use <xs:all> in XML schema's complexType?

查看:32
本文介绍了使用 <xs:all>在 XML 模式的 complexType 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义了以下 XML complexType:

I have the following XML complexTypes defined:

<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 定义.我做错了什么?

However, upon validation, I get an error stating that the all model group isn't allowed within the loss complexType nor its extension propLoss definition. What is it that I'm doing wrong?

谢谢!

推荐答案

propLoss 的一个问题是你不能在 XML Schema (1.0).来自规范:

A problem with propLoss is that you can't extend an all group in XML Schema (1.0). From the spec:

注意:本规范只允许追加,不允许其他类型的扩展名.这一决定简化了所需的申请处理将实例从派生类型转换为基类型.未来版本可能允许更多种类的扩展,需要更复杂的转换效果铸造.

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 错误造成的附带损害.

Not sure what the problem with loss is unless it collateral damage from the propLoss error.

这篇关于使用 &lt;xs:all&gt;在 XML 模式的 complexType 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆