簡體   English   中英

xsd自定義十進制類型定義,而不是零

[英]xsd custom decimal type definition, not zero

我想定義一個十進制(正或負)的XSD類型,但不能為零。 我該怎么做?

這是定義的主體:

<simpleType name="grossValueType">
<restriction base="decimal">
<!-- What put here? -->
</restriction>
</simpleType>

定義兩個類型,negativeDecimals和positiveDecimals,然后將它們組合在一起以獲得您想要的內容:

<xs:simpleType name="negativeDecimals">
    <xs:restriction base="xs:decimal">
        <xs:maxExclusive value="0"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="positiveDecimals">
    <xs:restriction base="xs:decimal">
        <xs:minExclusive value="0"/>
    </xs:restriction>
</xs:simpleType>

<xs:element name="measure">
    <xs:simpleType>
            <xs:union memberTypes="negativeDecimals positiveDecimals"/>
    </xs:simpleType>
</xs:element>

由於基類型都不能接受0,因此該值是非法的; 所有其他小數值都是合法的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM