changeset 146:0b32cc40d82f

Re #152: Test and fix extensibility of current schemas * Add extensibility to Race schema Also: * Code tidy for WarFoundryXmlFactoryUtils
author IBBoard <dev@ibboard.co.uk>
date Wed, 23 Sep 2009 19:58:21 +0000
parents 57517f472ab5
children 938409fc24cc
files api/Factories/Xml/WarFoundryXmlFactoryUtils.cs dtds/race.xsd
diffstat 2 files changed, 30 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/api/Factories/Xml/WarFoundryXmlFactoryUtils.cs	Mon Sep 21 19:20:42 2009 +0000
     1.2 +++ b/api/Factories/Xml/WarFoundryXmlFactoryUtils.cs	Wed Sep 23 19:58:21 2009 +0000
     1.3 @@ -16,6 +16,7 @@
     1.4  	/// </summary>
     1.5  	public class WarFoundryXmlFactoryUtils
     1.6  	{
     1.7 +		public static readonly string NS_BASE = "http://ibboard.co.uk/warfoundry/";
     1.8  		private static XmlReaderSettings settings;
     1.9  		private static XmlNamespaceManager nsManager;
    1.10  		
    1.11 @@ -40,11 +41,11 @@
    1.12  			if (nsManager == null)
    1.13  			{
    1.14  				nsManager = new XmlNamespaceManager(new NameTable());
    1.15 -				nsManager.AddNamespace("core", "http://ibboard.co.uk/warfoundry/core");
    1.16 -				nsManager.AddNamespace("cat", "http://ibboard.co.uk/warfoundry/cats");
    1.17 -				nsManager.AddNamespace("race", "http://ibboard.co.uk/warfoundry/race");
    1.18 -				nsManager.AddNamespace("system", "http://ibboard.co.uk/warfoundry/system");
    1.19 -				nsManager.AddNamespace("army", "http://ibboard.co.uk/warfoundry/army");
    1.20 +				nsManager.AddNamespace("core", NS_BASE + "core");
    1.21 +				nsManager.AddNamespace("cat", NS_BASE + "cats");
    1.22 +				nsManager.AddNamespace("race", NS_BASE + "race");
    1.23 +				nsManager.AddNamespace("system", NS_BASE + "system");
    1.24 +				nsManager.AddNamespace("army", NS_BASE + "army");
    1.25  			}
    1.26  			
    1.27  			return nsManager;
    1.28 @@ -67,12 +68,11 @@
    1.29  				settings.ValidationEventHandler+= new ValidationEventHandler(ValidationEventMethod);
    1.30  				XmlSchemaSet cache = new XmlSchemaSet();
    1.31  				string path =  IBBoard.Constants.ExecutablePath + "/dtds/";
    1.32 -				string nsBase = "http://ibboard.co.uk/warfoundry/";
    1.33 -				AddSchemaToCache(cache, nsBase + "core", path + "warfoundry-core.xsd");
    1.34 -				AddSchemaToCache(cache, nsBase + "cats", path + "warfoundry-cats.xsd");
    1.35 -				AddSchemaToCache(cache, nsBase + "race", path + "race.xsd");
    1.36 -				AddSchemaToCache(cache, nsBase + "system", path + "system.xsd");
    1.37 -				AddSchemaToCache(cache, nsBase + "army", path + "army.xsd");
    1.38 +				AddSchemaToCache(cache, NS_BASE + "core", path + "warfoundry-core.xsd");
    1.39 +				AddSchemaToCache(cache, NS_BASE + "cats", path + "warfoundry-cats.xsd");
    1.40 +				AddSchemaToCache(cache, NS_BASE + "race", path + "race.xsd");
    1.41 +				AddSchemaToCache(cache, NS_BASE + "system", path + "system.xsd");
    1.42 +				AddSchemaToCache(cache, NS_BASE + "army", path + "army.xsd");
    1.43  				settings.Schemas.Add(cache);
    1.44  			}
    1.45  			
    1.46 @@ -81,7 +81,7 @@
    1.47  		
    1.48  		private static void ValidationEventMethod(object sender, ValidationEventArgs e)
    1.49  		{
    1.50 -			throw new InvalidDataException("Problem validating against schema for WarFoundry data: " + e.Exception.Message, e.Exception);
    1.51 +			throw new InvalidDataException("Problem validating against schema for WarFoundry data: " + e.Message, e.Exception);
    1.52  		}
    1.53  		
    1.54  		private static void AddSchemaToCache(XmlSchemaSet cache, string xmlNamespace, string schemaLocation)
     2.1 --- a/dtds/race.xsd	Mon Sep 21 19:20:42 2009 +0000
     2.2 +++ b/dtds/race.xsd	Wed Sep 23 19:58:21 2009 +0000
     2.3 @@ -18,11 +18,13 @@
     2.4  														<xs:simpleContent>
     2.5  															<xs:extension base="xs:string">
     2.6  																<xs:attribute name="name" type="xs:string" use="required"/>
     2.7 +																<xs:anyAttribute/>
     2.8  															</xs:extension>
     2.9  														</xs:simpleContent>
    2.10  													</xs:complexType>
    2.11  												</xs:element>
    2.12  											</xs:sequence>
    2.13 +											<xs:anyAttribute/>
    2.14  										</xs:complexType>
    2.15  									</xs:element>
    2.16  									<xs:element name="unitEquipment">
    2.17 @@ -40,9 +42,11 @@
    2.18  														<xs:attribute name="roundDirection" type="updowntype" default="up"/>
    2.19  														<xs:attribute name="costMultiplier" type="core:nonNegativeDouble" default="1"/>
    2.20  														<xs:attribute name="costRounding" type="costroundingtype" default="UpToHalf"/>
    2.21 +														<xs:anyAttribute/>
    2.22  													</xs:complexType>
    2.23  												</xs:element>
    2.24  											</xs:sequence>
    2.25 +											<xs:anyAttribute/>
    2.26  										</xs:complexType>
    2.27  									</xs:element>
    2.28  									<xs:element name="unitAbilities" minOccurs="0">
    2.29 @@ -52,9 +56,11 @@
    2.30  													<xs:complexType>
    2.31  														<xs:attribute name="abilityID" type="xs:IDREF" />
    2.32  														<xs:attribute name="required" type="xs:boolean" default="true"/>
    2.33 +														<xs:anyAttribute/>
    2.34  													</xs:complexType>
    2.35  												</xs:element>
    2.36  											</xs:sequence>
    2.37 +											<xs:anyAttribute/>
    2.38  										</xs:complexType>
    2.39  									</xs:element>
    2.40  									<xs:element name="requirements" minOccurs="0">
    2.41 @@ -65,11 +71,13 @@
    2.42  														<xs:simpleContent>
    2.43  															<xs:extension base="xs:string">
    2.44  																<xs:attribute name="requirementName" type="xs:string" use="required"/>
    2.45 +																<xs:anyAttribute/>
    2.46  															</xs:extension>
    2.47  														</xs:simpleContent>
    2.48  													</xs:complexType>
    2.49  												</xs:element>
    2.50  											</xs:sequence>
    2.51 +											<xs:anyAttribute/>
    2.52  										</xs:complexType>
    2.53  									</xs:element>
    2.54  									<xs:element name="contains" minOccurs="0">
    2.55 @@ -78,9 +86,11 @@
    2.56  												<xs:element name="containedUnit">
    2.57  													<xs:complexType>
    2.58  														<xs:attribute name="containedID" type="xs:IDREF" use="required"/>
    2.59 +														<xs:anyAttribute/>
    2.60  													</xs:complexType>
    2.61  												</xs:element>
    2.62  											</xs:sequence>
    2.63 +											<xs:anyAttribute/>
    2.64  										</xs:complexType>
    2.65  									</xs:element>
    2.66  									<xs:element name="extraData" minOccurs="0">
    2.67 @@ -91,11 +101,13 @@
    2.68  														<xs:simpleContent>
    2.69  															<xs:extension base="xs:string">
    2.70  																<xs:attribute name="id" type="xs:ID" use="required"/>
    2.71 +																<xs:anyAttribute/>
    2.72  															</xs:extension>
    2.73  														</xs:simpleContent>
    2.74  													</xs:complexType>
    2.75  												</xs:element>
    2.76  											</xs:sequence>
    2.77 +											<xs:anyAttribute/>
    2.78  										</xs:complexType>
    2.79  									</xs:element>
    2.80  									<xs:element name="notes" type="xs:string" minOccurs="0" />
    2.81 @@ -110,6 +122,7 @@
    2.82  								<xs:attribute name="minSize" type="xs:nonNegativeInteger" default="5"/>
    2.83  								<xs:attribute name="maxSize" type="core:positiveOrInfiniteInteger" default="-1"/>
    2.84  								<xs:attribute name="baseSize" type="xs:nonNegativeInteger" default="0"/>
    2.85 +								<xs:anyAttribute/>
    2.86  							</xs:complexType>
    2.87  						</xs:element>
    2.88  					</xs:sequence>
    2.89 @@ -128,9 +141,11 @@
    2.90  								<xs:attribute name="name" type="xs:string" use="required"/>
    2.91  								<xs:attribute name="cost" type="core:nonNegativeNonInfiniteDouble" use="required"/>
    2.92  								<xs:attribute name="armourType" type="armourtype" default="None"/>
    2.93 +								<xs:anyAttribute/>
    2.94  							</xs:complexType>
    2.95  						</xs:element>
    2.96  					</xs:sequence>
    2.97 +					<xs:anyAttribute/>
    2.98  				</xs:complexType>
    2.99  			</xs:element>
   2.100  			<xs:element name="abilities" minOccurs="0">
   2.101 @@ -143,9 +158,11 @@
   2.102  								</xs:all>
   2.103  								<xs:attribute name="id" type="xs:ID" use="required"/>
   2.104  								<xs:attribute name="name" type="xs:string" use="required"/>
   2.105 +								<xs:anyAttribute/>
   2.106  							</xs:complexType>
   2.107  						</xs:element>
   2.108  					</xs:sequence>
   2.109 +					<xs:anyAttribute/>
   2.110  				</xs:complexType>
   2.111  			</xs:element>
   2.112  		</xs:all>
   2.113 @@ -153,6 +170,7 @@
   2.114  		<xs:attribute name="subid" type="xs:string" default=""/>
   2.115  		<xs:attribute name="name" type="xs:string" use="required"/>
   2.116  		<xs:attribute name="system" type="xs:string" use="required"/>
   2.117 +		<xs:anyAttribute/>
   2.118  	</xs:complexType>
   2.119  </xs:element>
   2.120  <xs:simpleType name="updowntype">