I want to make the game data file use XML and XSD.
It must be extensible.
xml :
<?xml version="1.0" encoding="utf-8"?>
<enemy xmlns="rubtub2314@gmail.com/Enemy_Data.xml"
xmlns:schema="rubtub2314@gmail.com/Enemy_Data.xml">
<info id="0" name="warrior">
<atk>1</atk>
<def>1</def>
<hp>1</hp>
<spd>1</spd>
**<anti_magic>1</anti_magic>**
</info>
<info id="1" name="archer">
<atk>1</atk>
<def>1</def>
<hp>1</hp>
<spd>1</spd>
</info>
</enemy>
xsd :
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="rubtub2314@gmail.com/Enemy_Data.xsd"
targetNamespace="rubtub2314@gmail.com/Enemy_Data.xml"
elementFormDefault="qualified">
<xs:element name="enemy">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="info">
<xs:complexType>
<xs:sequence>
<xs:element name="atk" type="xs:positiveInteger"/>
<xs:element name="def" type="xs:positiveInteger"/>
<xs:element name="hp" type="xs:positiveInteger"/>
<xs:element name="spd" type="xs:positiveInteger"/>
**<xs:any minOccurs="0"/>**
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
But my any keyword does not work. It make Just one line error message
'rubtub2314@gmail.com/Enemy_Data.xml:anti_magic' element does not declared. (<- it maybe not correct translation)
Why do I get this error?
I want to create an extensible XML that can add other parameters under the info element.
Have a look at the definition of xs:any:
{process contents} controls the impact on ·assessment· of the information items allowed by wildcards, as follows:
- strict
There must be a top-level declaration for the item available, or the item must have an xsi:type, and the item must be ·valid· as appropriate.- skip
No constraints at all: the item must simply be well-formed XML.- lax
If the item has a uniquely determined declaration available, it must be ·valid· with respect to that definition, that is, ·validate· if you can, don't worry if you can't.
So use "skip" or "lax" as a parameter in the following line:
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>