0
从这个例子:使用XML Schema如何定义属性并限制文本?
<cost isoCode="GBP">27.45</cost>
我如何定义的属性类型和限制'27 0.45' float类型?
我一直在尝试混合ComplexType,但没有任何运气!
谢谢。
从这个例子:使用XML Schema如何定义属性并限制文本?
<cost isoCode="GBP">27.45</cost>
我如何定义的属性类型和限制'27 0.45' float类型?
我一直在尝试混合ComplexType,但没有任何运气!
谢谢。
您可以使用xs:simpleContent
来完成此操作。以下是出发点。
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="cost">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:float">
<xs:attribute name="isoCode" type="isoCodeType" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="isoCodeType">
<xs:restriction base="xs:string">
<xs:enumeration value="GBP" />
<xs:enumeration value="other" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
我会建议永远不要使用浮动等货币值;而是使用小数或整数。 – 2012-02-29 02:16:18