char m
char m

Reputation: 8336

How to present a type of an element in xml-schema?

I'm making a xml schema and I have to present database columns which have name, type and table they belong to. Like this:

  <xs:complexType name="tMappingItem">
    <xs:sequence>
      <xs:element name="name" type="xs:string" />
      <xs:element name="type" type="xs:string" />
      <xs:element name="table" type="xs:string" />
    </xs:sequence>
  </xs:complexType>

Is there a more elegant way to do this? I can naturally do this:

     <xs:element name="type" >
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="FLOAT" />
            <xs:enumeration value="DOUBLE" />
            <xs:enumeration value="INT" />
            <xs:enumeration value="DATETIME" />
            <xs:enumeration value="STRING" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

if there is no way to tell that "type" is of type type. ;)

Upvotes: 2

Views: 225

Answers (1)

xcut
xcut

Reputation: 6349

Yes, that would be nice :) Unfortunately, there is no meta type in XML schema whose value are all the type names. You will have to enumerate them as you do up there.

Upvotes: 1

Related Questions