使用 xs:extension &xs:限制在一起? [英] Using xs:extension & xs:restriction together?

查看:41
本文介绍了使用 xs:extension &xs:限制在一起?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写 XML 模式时,我正在尝试做这样的事情

While writing an XML schema, I am attempting to do something like this

<xs:complexType name="ValueWithUnits">
    <xs:simpleContent>
        <xs:extension base="xs:double">
            <xs:attribute name="uom" fixed="second"/>
            <xs:minInclusive="0"/>
            <xs:maxInclusive="10"/>
        </xs:extension>
    </xs:simpleContent>
</xs:complexType>

不幸的是,在 xs:extension 上允许 xs:attribute 而 xs:minInclusive &xs:maxInclusive 允许用于 xs:restriction,但不能一起使用.

Unfortunately, xs:attribute is allowed on xs:extension while xs:minInclusive & xs:maxInclusive are allowed on xs:restriction, but not together.

构建它的最佳方法是什么?我必须用适当的单位定义扩展吗?然后用我的 min & 限制它最大值?

What is the best way to structure this? Do I have to define an extension with the appropriate units & then restrict it with my min & max values?

推荐答案

您需要定义对双分隔符的限制

You need to define the restriction on the double separatley

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio Developer Edition 8.1.4.2482 (http://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="RestrictedDouble">
        <xs:restriction base="xs:double">
            <xs:minInclusive value="0" />
            <xs:maxInclusive value="10" />
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="ValueWithUnits">
        <xs:simpleContent>
            <xs:extension base="RestrictedDouble">
                <xs:attribute name="uom" fixed="second" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>

这篇关于使用 xs:extension &amp;xs:限制在一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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