tags:

views:

56

answers:

1

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. ;)

+1  A: 

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.

xcut
yes meta type is exactly what i want. thanks 4 info! i have 2 accept your answer in a bit if nobody else can provide better solution than my "enum" strings...
matti