我有以下任务(简单版本):在XSD温度中描述。有最小值,最大值和默认值。默认值应放在min ... max值内。如何用XSD描述这些东西?
我的意思是:
Min_Set_Temp [ Integer between 0 and 1000 ]
Max Set Temp [ Integer between 0 and 1000 ]
Default_Set_Temp [ Integer between Min Set Temp and Max Set Temp]
XSD开始:
<xs:simpleType name="tSetTemperature">
<xs:restriction base="xs:unsignedShort">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="Bake">
<xs:complexType>
<xs:sequence>
<xs:element name="MinSetTemp" type="tSetTemperature"/>
<xs:element name="MaxSetTemp" type="tSetTemperature"/>
<xs:element name="DefaultTemp" type="tSetTemperature"/>
</xs:sequence>
</xs:complexType>
</xs:element>
答案 0 :(得分:0)
不可能。
可以使用xs:assert
:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
vc:minVersion="1.1">
<xs:simpleType name="tSetTemperature">
<xs:restriction base="xs:unsignedShort">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="Bake">
<xs:complexType>
<xs:sequence>
<xs:element name="MinSetTemp" type="tSetTemperature"/>
<xs:element name="MaxSetTemp" type="tSetTemperature"/>
<xs:element name="DefaultTemp" type="tSetTemperature"/>
</xs:sequence>
<xs:assert test="DefaultTemp = MinSetTemp to MaxSetTemp"/>
</xs:complexType>
</xs:element>
</xs:schema>