我正在为我的XML编写XSD。请管理员删除此
<xsd:element name="AAA">
<xsd:complexType>
AND
<xsd:element name="CVCCodeSwitch " type="xsd:integer" nillable="true"/>
在上面的一个中,我如何假设它将是整数?
这
<xsd:element name="CVCCodeSwitch " type="xsd:integer" nillable="true"/>
应该很好(只允许整数);你可能很困惑,因为
<CVCCodeSwitch />
不为零;nil xml元素看起来像
<CVCCodeSwitch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true" />
(如果您已经在更高级别声明了xmlns:xsi,则可以忽略它)
如果您无法控制xml(即必须根据已经拥有的xml编写xsd),则必须将type声明为整数和空字符串的并集:
<xsd:element name="CVCCodeSwitch">
<xsd:simpleType>
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:integer" />
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value=""/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
</xsd:element>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句