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 diff
     1.1 --- a/api/Factories/Xml/WarFoundryXmlFactory.cs	Sat Mar 14 20:38:16 2009 +0000
     1.2 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs	Sat Mar 14 20:47:14 2009 +0000
     1.3 @@ -325,38 +325,6 @@
     1.4  		private void ValidationEventMethod(object sender, ValidationEventArgs e)
     1.5  		{
     1.6  			throw new InvalidDataException("Problem validating against schema for WarFoundry data: " + e.Exception.Message, e.Exception);
     1.7 -		}
     1.8 -
     1.9 -		protected XmlDocument CreateXmlDocumentFromString(string xmlString)
    1.10 -		{			
    1.11 -			XmlReaderSettings settings = new XmlReaderSettings();
    1.12 -			settings.XmlResolver = xmlResolver;
    1.13 -			settings.ValidationType = ValidationType.DTD;
    1.14 -			settings.ProhibitDtd = false;
    1.15 -			settings.ValidationEventHandler+= new ValidationEventHandler(ValidationEventMethod);
    1.16 -			XmlReader reader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(xmlString)), settings);
    1.17 -			XmlDocument doc = new XmlDocument();
    1.18 -
    1.19 -			try
    1.20 -			{
    1.21 -				doc.Load(reader);
    1.22 -			}
    1.23 -			catch(XmlSchemaException ex)
    1.24 -			{
    1.25 -				throw new InvalidFileException(Translation.GetTranslation("ErrorInvalidXmlString", "Failed to parse invalid XML string"), ex);
    1.26 -			}
    1.27 -			finally
    1.28 -			{
    1.29 -				//We might not need to make sure the memory stream is closed, but do it just in case
    1.30 -				reader.Close();
    1.31 -			}
    1.32 -			
    1.33 -			if (doc.ChildNodes.Count!=3)
    1.34 -			{
    1.35 -				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.")));
    1.36 -			}
    1.37 -
    1.38 -			return doc;
    1.39  		}
    1.40  					
    1.41  		private WarFoundryObject CreateObjectFromElement(XmlElement elem)
     2.1 --- a/dtds/warfoundry-cats.xsd	Sat Mar 14 20:38:16 2009 +0000
     2.2 +++ b/dtds/warfoundry-cats.xsd	Sat Mar 14 20:47:14 2009 +0000
     2.3 @@ -3,15 +3,16 @@
     2.4  xmlns="http://ibboard.co.uk/warfoundry/cats" elementFormDefault="qualified">
     2.5  <xs:complexType name="categoriestype">
     2.6    <xs:sequence>
     2.7 -    <xs:element name="cat" type="cattype" minOccurs="1" maxOccurs="unbounded"/>
     2.8 +    <xs:element name="cat" minOccurs="1" maxOccurs="unbounded">
     2.9 +      <xs:complexType>
    2.10 +        <xs:attribute name="id" type="xs:ID" />
    2.11 +        <xs:attribute name="name" type="xs:string" use="required"/>
    2.12 +        <xs:attribute name="minPoints" type="core:nonNegativeDecimal" default="0"/>
    2.13 +        <xs:attribute name="maxPoints" type="core:infiniteOrNonNegativeDecimal" default="-1"/>
    2.14 +        <xs:attribute name="minPercentage" type="core:percentage" default="0"/>
    2.15 +        <xs:attribute name="maxPercentage" type="core:percentage" default="100"/>
    2.16 +      </xs:complexType>
    2.17 +	</xs:element>
    2.18    </xs:sequence>
    2.19  </xs:complexType>
    2.20 -<xs:complexType name="cattype">
    2.21 -  <xs:attribute name="id" type="xs:ID" />   
    2.22 -  <xs:attribute name="name" type="xs:string" use="required"/>
    2.23 -  <xs:attribute name="minPoints" type="core:nonNegativeDecimal" default="0"/>
    2.24 -  <xs:attribute name="maxPoints" type="core:infiniteOrNonNegativeDecimal" default="-1"/>
    2.25 -  <xs:attribute name="minPercentage" type="core:percentage" default="0"/>
    2.26 -  <xs:attribute name="maxPercentage" type="core:percentage" default="100"/>
    2.27 -</xs:complexType>
    2.28  </xs:schema>
    2.29 \ No newline at end of file