xml – 一起使用xs:extension&xs:限制

在编写XML模式时,我正在尝试这样做
<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:限制,但不是在一起.

什么是最好的结构方式?我必须使用适当的单位&然后用我的最小&最大值?

您需要定义双重分隔符上的限制
<?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>

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念