xsd:union 在 XML Schema (XSD) 中的用途是什么? [英] What is purpose of xsd:union in XML Schema (XSD)?

查看:31
本文介绍了xsd:union 在 XML Schema (XSD) 中的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我出于某种目的解析 XSD,但在某些 XSD 节点上遇到了问题.联合在 XSD 中的用途是什么,为什么要使用它.

I am parsing XSD for some purpose but facing issues with some XSD nodes. What is the use of the union in XSD and why it is used.

它是否用于对 XML 施加某种限制?我正在附加联合和简单类型节点.

Is it used to put some sort of restriction on XML? I am attaching union and simple type node.

请解释为什么使用它?

<xsd:simpleType name="PeriodExtendedEnum">
    <xsd:union memberTypes="PeriodEnum">
        <xsd:simpleType>
            <xsd:restriction base="xsd:token">
                <xsd:enumeration value="T" />
            </xsd:restriction>
        </xsd:simpleType>
    </xsd:union>
</xsd:simpleType>


<xsd:simpleType name="PeriodEnum">
    <xsd:restriction base="xsd:token">
        <xsd:enumeration value="D" />
        <xsd:enumeration value="W" />
        <xsd:enumeration value="M" />
        <xsd:enumeration value="Y" />
    </xsd:restriction>
</xsd:simpleType>

推荐答案

xsd:union 元素允许派生由 union 组成的新类型其成员类型.

The xsd:union element allows derivation of a new type consisting of the union in the set theoretical sense of the types of its memberTypes.

在您的示例中,PeriodExtendedEnumPeriodEnum {D, W, M 的并集Y} 和 {T}:也就是说,PeriodExtendedEnum 将允许其两个 memberType 的所有值:{DWMYT}.

In your example, PeriodExtendedEnum is the union of PeriodEnum {D, W, M, Y} and {T}: That is, PeriodExtendedEnum would allow all of the values of its two memberTypes: {D, W, M, Y, T}.

这篇关于xsd:union 在 XML Schema (XSD) 中的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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