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 wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlFactoryUtils.cs	Mon Sep 21 19:20:42 2009 +0000
+++ b/api/Factories/Xml/WarFoundryXmlFactoryUtils.cs	Wed Sep 23 19:58:21 2009 +0000
@@ -16,6 +16,7 @@
 	/// </summary>
 	public class WarFoundryXmlFactoryUtils
 	{
+		public static readonly string NS_BASE = "http://ibboard.co.uk/warfoundry/";
 		private static XmlReaderSettings settings;
 		private static XmlNamespaceManager nsManager;
 		
@@ -40,11 +41,11 @@
 			if (nsManager == null)
 			{
 				nsManager = new XmlNamespaceManager(new NameTable());
-				nsManager.AddNamespace("core", "http://ibboard.co.uk/warfoundry/core");
-				nsManager.AddNamespace("cat", "http://ibboard.co.uk/warfoundry/cats");
-				nsManager.AddNamespace("race", "http://ibboard.co.uk/warfoundry/race");
-				nsManager.AddNamespace("system", "http://ibboard.co.uk/warfoundry/system");
-				nsManager.AddNamespace("army", "http://ibboard.co.uk/warfoundry/army");
+				nsManager.AddNamespace("core", NS_BASE + "core");
+				nsManager.AddNamespace("cat", NS_BASE + "cats");
+				nsManager.AddNamespace("race", NS_BASE + "race");
+				nsManager.AddNamespace("system", NS_BASE + "system");
+				nsManager.AddNamespace("army", NS_BASE + "army");
 			}
 			
 			return nsManager;
@@ -67,12 +68,11 @@
 				settings.ValidationEventHandler+= new ValidationEventHandler(ValidationEventMethod);
 				XmlSchemaSet cache = new XmlSchemaSet();
 				string path =  IBBoard.Constants.ExecutablePath + "/dtds/";
-				string nsBase = "http://ibboard.co.uk/warfoundry/";
-				AddSchemaToCache(cache, nsBase + "core", path + "warfoundry-core.xsd");
-				AddSchemaToCache(cache, nsBase + "cats", path + "warfoundry-cats.xsd");
-				AddSchemaToCache(cache, nsBase + "race", path + "race.xsd");
-				AddSchemaToCache(cache, nsBase + "system", path + "system.xsd");
-				AddSchemaToCache(cache, nsBase + "army", path + "army.xsd");
+				AddSchemaToCache(cache, NS_BASE + "core", path + "warfoundry-core.xsd");
+				AddSchemaToCache(cache, NS_BASE + "cats", path + "warfoundry-cats.xsd");
+				AddSchemaToCache(cache, NS_BASE + "race", path + "race.xsd");
+				AddSchemaToCache(cache, NS_BASE + "system", path + "system.xsd");
+				AddSchemaToCache(cache, NS_BASE + "army", path + "army.xsd");
 				settings.Schemas.Add(cache);
 			}
 			
@@ -81,7 +81,7 @@
 		
 		private static void ValidationEventMethod(object sender, ValidationEventArgs e)
 		{
-			throw new InvalidDataException("Problem validating against schema for WarFoundry data: " + e.Exception.Message, e.Exception);
+			throw new InvalidDataException("Problem validating against schema for WarFoundry data: " + e.Message, e.Exception);
 		}
 		
 		private static void AddSchemaToCache(XmlSchemaSet cache, string xmlNamespace, string schemaLocation)
--- a/dtds/race.xsd	Mon Sep 21 19:20:42 2009 +0000
+++ b/dtds/race.xsd	Wed Sep 23 19:58:21 2009 +0000
@@ -18,11 +18,13 @@
 														<xs:simpleContent>
 															<xs:extension base="xs:string">
 																<xs:attribute name="name" type="xs:string" use="required"/>
+																<xs:anyAttribute/>
 															</xs:extension>
 														</xs:simpleContent>
 													</xs:complexType>
 												</xs:element>
 											</xs:sequence>
+											<xs:anyAttribute/>
 										</xs:complexType>
 									</xs:element>
 									<xs:element name="unitEquipment">
@@ -40,9 +42,11 @@
 														<xs:attribute name="roundDirection" type="updowntype" default="up"/>
 														<xs:attribute name="costMultiplier" type="core:nonNegativeDouble" default="1"/>
 														<xs:attribute name="costRounding" type="costroundingtype" default="UpToHalf"/>
+														<xs:anyAttribute/>
 													</xs:complexType>
 												</xs:element>
 											</xs:sequence>
+											<xs:anyAttribute/>
 										</xs:complexType>
 									</xs:element>
 									<xs:element name="unitAbilities" minOccurs="0">
@@ -52,9 +56,11 @@
 													<xs:complexType>
 														<xs:attribute name="abilityID" type="xs:IDREF" />
 														<xs:attribute name="required" type="xs:boolean" default="true"/>
+														<xs:anyAttribute/>
 													</xs:complexType>
 												</xs:element>
 											</xs:sequence>
+											<xs:anyAttribute/>
 										</xs:complexType>
 									</xs:element>
 									<xs:element name="requirements" minOccurs="0">
@@ -65,11 +71,13 @@
 														<xs:simpleContent>
 															<xs:extension base="xs:string">
 																<xs:attribute name="requirementName" type="xs:string" use="required"/>
+																<xs:anyAttribute/>
 															</xs:extension>
 														</xs:simpleContent>
 													</xs:complexType>
 												</xs:element>
 											</xs:sequence>
+											<xs:anyAttribute/>
 										</xs:complexType>
 									</xs:element>
 									<xs:element name="contains" minOccurs="0">
@@ -78,9 +86,11 @@
 												<xs:element name="containedUnit">
 													<xs:complexType>
 														<xs:attribute name="containedID" type="xs:IDREF" use="required"/>
+														<xs:anyAttribute/>
 													</xs:complexType>
 												</xs:element>
 											</xs:sequence>
+											<xs:anyAttribute/>
 										</xs:complexType>
 									</xs:element>
 									<xs:element name="extraData" minOccurs="0">
@@ -91,11 +101,13 @@
 														<xs:simpleContent>
 															<xs:extension base="xs:string">
 																<xs:attribute name="id" type="xs:ID" use="required"/>
+																<xs:anyAttribute/>
 															</xs:extension>
 														</xs:simpleContent>
 													</xs:complexType>
 												</xs:element>
 											</xs:sequence>
+											<xs:anyAttribute/>
 										</xs:complexType>
 									</xs:element>
 									<xs:element name="notes" type="xs:string" minOccurs="0" />
@@ -110,6 +122,7 @@
 								<xs:attribute name="minSize" type="xs:nonNegativeInteger" default="5"/>
 								<xs:attribute name="maxSize" type="core:positiveOrInfiniteInteger" default="-1"/>
 								<xs:attribute name="baseSize" type="xs:nonNegativeInteger" default="0"/>
+								<xs:anyAttribute/>
 							</xs:complexType>
 						</xs:element>
 					</xs:sequence>
@@ -128,9 +141,11 @@
 								<xs:attribute name="name" type="xs:string" use="required"/>
 								<xs:attribute name="cost" type="core:nonNegativeNonInfiniteDouble" use="required"/>
 								<xs:attribute name="armourType" type="armourtype" default="None"/>
+								<xs:anyAttribute/>
 							</xs:complexType>
 						</xs:element>
 					</xs:sequence>
+					<xs:anyAttribute/>
 				</xs:complexType>
 			</xs:element>
 			<xs:element name="abilities" minOccurs="0">
@@ -143,9 +158,11 @@
 								</xs:all>
 								<xs:attribute name="id" type="xs:ID" use="required"/>
 								<xs:attribute name="name" type="xs:string" use="required"/>
+								<xs:anyAttribute/>
 							</xs:complexType>
 						</xs:element>
 					</xs:sequence>
+					<xs:anyAttribute/>
 				</xs:complexType>
 			</xs:element>
 		</xs:all>
@@ -153,6 +170,7 @@
 		<xs:attribute name="subid" type="xs:string" default=""/>
 		<xs:attribute name="name" type="xs:string" use="required"/>
 		<xs:attribute name="system" type="xs:string" use="required"/>
+		<xs:anyAttribute/>
 	</xs:complexType>
 </xs:element>
 <xs:simpleType name="updowntype">