Hi,
I'm currently developing a tilebased game and I want to store informations about my game's tiles in an xml file. A tile's definition should look as similar as possible to this:
<tile id="anID">
<properties>
<property name="aUniquePropName1" type="string">
test</property>
<property name="aUniquePropName2" type="boolean">true</property>
<property name="aUniquePropName3" type="int">32456</property>
</properties>
</tile>
The value of any <property> element should be validated depending on the type attribute's value. Additionally, I would like to use existing schema primitives such as int,
string and boolean. My current approach for the definition of a tile's property looks like this:
<xs:complexType name="TilePropertyType" abstract="true">
<xs:simpleContent>
<xs:extension base="xs:anySimpleType">
<xs:attribute name="name" type="xs:Name" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
And a derivation of this type:
<xs:complexType name="String">
<xs:simpleContent>
<xs:restriction base="etg:TilePropertyType">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
I'm using XMLSpy 2004 which validates the files before saving, and trying to save doesn't produce an error. However, if I try to switch to a graphical representation of my schema(there is a text view and several more graphical, a bit UML like views), I get the following error:
Unable to show schema:
The element xs:simpleType is unexpected at this location.
And the line "<xs:simpleType>" after "<xs:restriction base="etg:TilePropertyType">" in the complexType String is marked.
Is this a bug of XMLSpy(i suppose not) or is my schema really not valid and XMLSpy doesn't check everything when saving? If my schema is invalid, how could I correct it(with the same functionality) to make it valid?
What I'm doing is basically trying to have two supertypes: TilePropertyType and, in this example, xs:string. Is this possible in XML schemas?
Thanks for any answers,
Michael Herrmann