【发布时间】:2016-09-06 18:17:19
【问题描述】:
给定 XML 元素
<shoesize country="france">35</shoesize>
我想为其整数简单内容设置一个默认值。
现在,上面的示例取自 w3schools,它带有以下 XSD:
<xs:element name="shoesize" type="shoetype"/>
<xs:complexType name="shoetype">
<xs:simpleContent>
<xs:extension base="xs:integer">
<xs:attribute name="country" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
尽管我知道默认值“只能在元素的内容是简单类型或纯文本时使用”而 shoesize 是一个 complexType,但我还是很纠结相信我无法为 shoesize 设置这样的默认值或找到实际这样做的方法。
在我的试验中,我在 shoesize xs:element、xs:simpleContent 和 xs:extension; 中设置了一个默认值。没有经过验证。
【问题讨论】: