changeset 32:6b9d37f14a14

Re #32 - Migrate to schemas * Remove unused method that was still validating by DTD * Collapse Cats schema in to one nested structure System files are failing to validate because: Problem validating against schema for WarFoundry data: XmlSchema error: Invalid start element: http://ibboard.co.uk/warfoundry/system:cat XML Line 4, Position 4. which is a <cat> tag, which should match the Cat schema definition. Removing the tags results in a different error about the end </categories> tag being unexpected because of missing content.
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2009 20:47:14 +0000
parents 457c9357dd64
children 4308424b4145
files api/Factories/Xml/WarFoundryXmlFactory.cs dtds/warfoundry-cats.xsd
diffstat 2 files changed, 10 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlFactory.cs	Sat Mar 14 20:38:16 2009 +0000
+++ b/api/Factories/Xml/WarFoundryXmlFactory.cs	Sat Mar 14 20:47:14 2009 +0000
@@ -325,38 +325,6 @@
 		private void ValidationEventMethod(object sender, ValidationEventArgs e)
 		{
 			throw new InvalidDataException("Problem validating against schema for WarFoundry data: " + e.Exception.Message, e.Exception);
-		}
-
-		protected XmlDocument CreateXmlDocumentFromString(string xmlString)
-		{			
-			XmlReaderSettings settings = new XmlReaderSettings();
-			settings.XmlResolver = xmlResolver;
-			settings.ValidationType = ValidationType.DTD;
-			settings.ProhibitDtd = false;
-			settings.ValidationEventHandler+= new ValidationEventHandler(ValidationEventMethod);
-			XmlReader reader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(xmlString)), settings);
-			XmlDocument doc = new XmlDocument();
-
-			try
-			{
-				doc.Load(reader);
-			}
-			catch(XmlSchemaException ex)
-			{
-				throw new InvalidFileException(Translation.GetTranslation("ErrorInvalidXmlString", "Failed to parse invalid XML string"), ex);
-			}
-			finally
-			{
-				//We might not need to make sure the memory stream is closed, but do it just in case
-				reader.Close();
-			}
-			
-			if (doc.ChildNodes.Count!=3)
-			{
-				throw new InvalidFileException(String.Format(Translation.GetTranslation("ErrorInvalidXmlFile", "XML string was not a valid XML file. It should contain three child nodes - XML definition, DocType and root node.")));
-			}
-
-			return doc;
 		}
 					
 		private WarFoundryObject CreateObjectFromElement(XmlElement elem)
--- a/dtds/warfoundry-cats.xsd	Sat Mar 14 20:38:16 2009 +0000
+++ b/dtds/warfoundry-cats.xsd	Sat Mar 14 20:47:14 2009 +0000
@@ -3,15 +3,16 @@
 xmlns="http://ibboard.co.uk/warfoundry/cats" elementFormDefault="qualified">
 <xs:complexType name="categoriestype">
   <xs:sequence>
-    <xs:element name="cat" type="cattype" minOccurs="1" maxOccurs="unbounded"/>
+    <xs:element name="cat" minOccurs="1" maxOccurs="unbounded">
+      <xs:complexType>
+        <xs:attribute name="id" type="xs:ID" />
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="minPoints" type="core:nonNegativeDecimal" default="0"/>
+        <xs:attribute name="maxPoints" type="core:infiniteOrNonNegativeDecimal" default="-1"/>
+        <xs:attribute name="minPercentage" type="core:percentage" default="0"/>
+        <xs:attribute name="maxPercentage" type="core:percentage" default="100"/>
+      </xs:complexType>
+	</xs:element>
   </xs:sequence>
 </xs:complexType>
-<xs:complexType name="cattype">
-  <xs:attribute name="id" type="xs:ID" />   
-  <xs:attribute name="name" type="xs:string" use="required"/>
-  <xs:attribute name="minPoints" type="core:nonNegativeDecimal" default="0"/>
-  <xs:attribute name="maxPoints" type="core:infiniteOrNonNegativeDecimal" default="-1"/>
-  <xs:attribute name="minPercentage" type="core:percentage" default="0"/>
-  <xs:attribute name="maxPercentage" type="core:percentage" default="100"/>
-</xs:complexType>
 </xs:schema>
\ No newline at end of file