I am writing the XSD for my XML.I am strucked at a point.Can you please help me out. PLEASE mderators DELETE THIS

<xsd:element name="AAA"> 
    <xsd:complexType> 
   AND

<xsd:element name="CVCCodeSwitch " type="xsd:integer" nillable="true"/>

In the above one how can i make assumptions that it would be integer?

有帮助吗?

解决方案

The

<xsd:element name="CVCCodeSwitch " type="xsd:integer" nillable="true"/>

should be fine (only integer is allowed); you're probably confused because

<CVCCodeSwitch /> 

is not nil; nil xml element looks like

<CVCCodeSwitch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:nil="true"  />

(You can omit the xmlns:xsi if you've already declared it at higher level)

If you have no control over xml (i.e. you have to write xsd according to xml you already have) you have to declare type as union of integer and empty string:

<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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top