Вопрос

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