changeset 31:457c9357dd64

Re #32 - Convert to schemas * Remove node count check from factory - Schema should validate document properly * Update race schema: * Add min and maxOccurs attributes * change "points" to "cost" * change equipID to ID * temporarily replace core:nonNegativeDecimal with xs:integer so that we don't get stuck on validation errors about casting to string
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2009 20:38:16 +0000
parents 92cf25b0493b
children 6b9d37f14a14
files api/Factories/Xml/WarFoundryXmlFactory.cs dtds/race.xsd
diffstat 2 files changed, 16 insertions(+), 21 deletions(-) [+]
line diff
     1.1 --- a/api/Factories/Xml/WarFoundryXmlFactory.cs	Sat Mar 14 20:16:09 2009 +0000
     1.2 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs	Sat Mar 14 20:38:16 2009 +0000
     1.3 @@ -277,11 +277,6 @@
     1.4  			finally
     1.5  			{
     1.6  				reader.Close();
     1.7 -			}
     1.8 -			
     1.9 -			if (doc.ChildNodes.Count!=3)
    1.10 -			{
    1.11 -				throw new InvalidFileException(Translation.GetTranslation("ErrorInvalidXmlFile", "XML file was not a valid XML file. It should contain three child nodes - XML definition, DocType and root node."));
    1.12  			}
    1.13  
    1.14  			return doc;
     2.1 --- a/dtds/race.xsd	Sat Mar 14 20:16:09 2009 +0000
     2.2 +++ b/dtds/race.xsd	Sat Mar 14 20:38:16 2009 +0000
     2.3 @@ -5,9 +5,9 @@
     2.4    <xs:complexType>
     2.5      <xs:all>
     2.6        <xs:element name="units" type="unitstype" minOccurs="1"/>
     2.7 -      <xs:element name="categories" type="cats:categoriestype" />
     2.8 -      <xs:element name="equipment" type="equipmenttype" />
     2.9 -      <xs:element name="abilities" type="abilitiestype" />
    2.10 +      <xs:element name="categories" type="cats:categoriestype" minOccurs="0" />
    2.11 +      <xs:element name="equipment" type="equipmenttype" minOccurs="0" />
    2.12 +      <xs:element name="abilities" type="abilitiestype" minOccurs="0" />
    2.13      </xs:all>
    2.14      <xs:attribute name="id" type="xs:ID" />
    2.15      <xs:attribute name="subid" type="xs:string" default=""/>
    2.16 @@ -24,11 +24,11 @@
    2.17    <xs:all>
    2.18      <xs:element name="stats" type="statstype" minOccurs="1" />
    2.19      <xs:element name="unitEquipment" type="unitequipmenttype" />
    2.20 -    <xs:element name="unitAbilities" type="unitabilitiestype" />
    2.21 -    <xs:element name="requirements" type="requirementstype" />
    2.22 -    <xs:element name="contains" type="containstype" />
    2.23 -    <xs:element name="extraData" type="extradatatype" />
    2.24 -    <xs:element name="notes" type="xs:string" />
    2.25 +    <xs:element name="unitAbilities" type="unitabilitiestype" minOccurs="0" />
    2.26 +    <xs:element name="requirements" type="requirementstype" minOccurs="0" />
    2.27 +    <xs:element name="contains" type="containstype" minOccurs="0" />
    2.28 +    <xs:element name="extraData" type="extradatatype" minOccurs="0" />
    2.29 +    <xs:element name="notes" type="xs:string" minOccurs="0" />
    2.30    </xs:all>
    2.31    <xs:attribute name="id" type="xs:ID" />
    2.32    <xs:attribute name="typeName" type="xs:string" use="required"/>
    2.33 @@ -36,9 +36,9 @@
    2.34    <xs:attribute name="unitPoints" type="core:nonNegativeDecimal" default="0"/>
    2.35    <xs:attribute name="points" type="core:nonNegativeDecimal" use="required"/>
    2.36    <xs:attribute name="minNum" type="xs:nonNegativeInteger" default="0"/>
    2.37 -  <xs:attribute name="maxNum" type="core:infiniteOrNonNegativeInteger" default="-1"/>
    2.38 +  <xs:attribute name="maxNum" type="xs:integer" default="-1"/>
    2.39    <xs:attribute name="minSize" type="xs:positiveInteger" default="5"/>
    2.40 -  <xs:attribute name="maxSize" type="core:infiniteOrNonNegativeInteger" default="-1"/>
    2.41 +  <xs:attribute name="maxSize" type="xs:integer" default="-1"/>
    2.42    <xs:attribute name="baseSize" type="xs:nonNegativeInteger" default="0"/>
    2.43  </xs:complexType>
    2.44  <xs:complexType name="statstype">
    2.45 @@ -59,11 +59,11 @@
    2.46    </xs:sequence>
    2.47  </xs:complexType>
    2.48  <xs:complexType name="unitequipmentitemtype">
    2.49 -  <xs:attribute name="equipID" type="xs:IDREF" />
    2.50 +  <xs:attribute name="id" type="xs:IDREF" />
    2.51    <xs:attribute name="required" type="xs:boolean" default="false"/>
    2.52    <xs:attribute name="exclusivityGroup" type="xs:string" default=""/>
    2.53 -  <xs:attribute name="minNum" type="core:infiniteOrNonNegativeInteger" default="-1"/>
    2.54 -  <xs:attribute name="maxNum" type="core:infiniteOrNonNegativeInteger" default="-1"/>
    2.55 +  <xs:attribute name="minNum" type="xs:integer" default="-1"/>
    2.56 +  <xs:attribute name="maxNum" type="xs:integer" default="-1"/>
    2.57    <xs:attribute name="minPercentage" type="core:percentage" default="100"/>
    2.58    <xs:attribute name="maxPercentage" type="core:percentage" default="100"/>
    2.59    <xs:attribute name="roundDirection" type="updowntype" default="up"/>
    2.60 @@ -117,16 +117,16 @@
    2.61  </xs:complexType>
    2.62  <xs:complexType name="equipmenttype">
    2.63    <xs:sequence>
    2.64 -    <xs:element name="equipmentItem" type="equipmentitemtype"/>
    2.65 +    <xs:element name="equipmentItem" type="equipmentitemtype" maxOccurs="unbounded" />
    2.66    </xs:sequence>
    2.67  </xs:complexType>
    2.68  <xs:complexType name="equipmentitemtype">
    2.69    <xs:all>
    2.70 -    <xs:element name="description" type="xs:string" />
    2.71 +    <xs:element name="description" type="xs:string" minOccurs="0" />
    2.72    </xs:all>
    2.73    <xs:attribute name="id" type="xs:ID" use="required"/>
    2.74    <xs:attribute name="name" type="xs:string" use="required"/>
    2.75 -  <xs:attribute name="points" type="core:nonNegativeDecimal" use="required"/>
    2.76 +  <xs:attribute name="cost" type="core:nonNegativeDecimal" use="required"/>
    2.77    <xs:attribute name="armoutType" type="armourtype" default="none"/>
    2.78  </xs:complexType>
    2.79  <xs:simpleType name="armourtype">