/ / Jak przedstawić typ elementu w schemacie xml? - xml, xsd

Jak przedstawić typ elementu w schemacie xml? - xml, xsd

Tworzę schemat xml i muszę przedstawić kolumny bazy danych, które mają nazwę, typ i tabelę, do której należą.

  <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>

Czy jest na to bardziej elegancki sposób? Naturalnie mogę to zrobić:

     <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>

jeśli nie ma sposobu, aby powiedzieć, że „typ” jest typu. ;)

Odpowiedzi:

1 dla odpowiedzi № 1

Tak, byłoby miło :) Niestety w schemacie XML nie ma meta typu, którego wartością są wszystkie nazwy typów. Będziesz musiał je wyliczyć tak, jak tam na górze.