Mercurial > repos > snowblizz-super-API-ideas
changeset 267:3f14a792fd41
Re #274: Crash when missing unit member ID
* Add key and keyref for member type
Re #290: Migrate to using key/keyref definitions instead of ID/IDREF type
* Move keyref and key for equipment slot to correct place to be valid
* Add aliased xmlns for schema to allow for use in XPath, which doesn't use default namespace
* Disable warning reporting until Mono Bug 613684 is fixed (https://bugzilla.novell.com/show_bug.cgi?id=613684)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 12 Jun 2010 19:49:32 +0000 |
parents | a3c1bf57fd3f |
children | d8e4eeb761c7 |
files | api/Factories/Xml/WarFoundryXmlFactoryUtils.cs schemas/race.xsd |
diffstat | 2 files changed, 28 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlFactoryUtils.cs Sat Jun 05 18:57:46 2010 +0000 +++ b/api/Factories/Xml/WarFoundryXmlFactoryUtils.cs Sat Jun 12 19:49:32 2010 +0000 @@ -63,7 +63,7 @@ { settings = new XmlReaderSettings(); settings.ValidationType = ValidationType.Schema; - settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings; + //settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings; settings.ProhibitDtd = true; settings.ValidationEventHandler+= new ValidationEventHandler(ValidationEventMethod); XmlSchemaSet cache = new XmlSchemaSet(); @@ -82,7 +82,14 @@ private static void ValidationEventMethod(object sender, ValidationEventArgs e) { - throw new InvalidFileException("Problem validating against schema for WarFoundry data: " + e.Message, e.Exception); + if (e.Severity == XmlSeverityType.Error) + { + throw new InvalidFileException("Problem validating against schema for WarFoundry data: " + e.Message, e.Exception); + } + else + { + //TODO: Fire some kind of warning event + } } private static void AddSchemaToCache(XmlSchemaSet cache, string xmlNamespace, string schemaLocation)
--- a/schemas/race.xsd Sat Jun 05 18:57:46 2010 +0000 +++ b/schemas/race.xsd Sat Jun 12 19:49:32 2010 +0000 @@ -1,6 +1,6 @@ <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:core="http://ibboard.co.uk/warfoundry/core" xmlns:cats="http://ibboard.co.uk/warfoundry/cats" -targetNamespace="http://ibboard.co.uk/warfoundry/race" xmlns="http://ibboard.co.uk/warfoundry/race" elementFormDefault="qualified"> +targetNamespace="http://ibboard.co.uk/warfoundry/race" xmlns="http://ibboard.co.uk/warfoundry/race" xmlns:race="http://ibboard.co.uk/warfoundry/race" elementFormDefault="qualified"> <xs:element name="race"> <xs:complexType> <xs:sequence> @@ -8,7 +8,16 @@ <xs:element name="units"> <xs:complexType> <xs:sequence> - <xs:element name="unit" maxOccurs="unbounded" type="unit"/> + <xs:element name="unit" maxOccurs="unbounded" type="unit"> + <xs:keyref name="equipSlotRef" refer="equipSlotKey"> + <xs:selector xpath="race:unitEquipment/race:unitEquipmentItem"/> + <xs:field xpath="@equipmentSlot"/> + </xs:keyref> + <xs:key name="equipSlotKey"> + <xs:selector xpath="race:equipmentSlots/race:equipmentSlot"/> + <xs:field xpath="@name"/> + </xs:key> + </xs:element> </xs:sequence> </xs:complexType> </xs:element> @@ -60,6 +69,14 @@ <xs:attribute name="system" type="xs:string" use="required"/> <xs:anyAttribute processContents="lax"/> </xs:complexType> + <xs:keyref name="memberTypeRef" refer="memberTypeKey"> + <xs:selector xpath="race:units/race:unit/race:unitMembers/race:unitMember"/> + <xs:field xpath="@typeID"/> + </xs:keyref> + <xs:key name="memberTypeKey"> + <xs:selector xpath="race:memberTypes/race:memberType"/> + <xs:field xpath="@id"/> + </xs:key> </xs:element> <!--Reusable complex types --> @@ -81,10 +98,6 @@ </xs:element> </xs:sequence> </xs:complexType> - <xs:key name="equipSlotName"> - <xs:selector xpath="equipmentSlot"/> - <xs:field xpath="@name"/> - </xs:key> </xs:element> <xs:element name="unitEquipment" minOccurs="0"> <xs:complexType> @@ -107,10 +120,6 @@ <xs:attribute name="costRounding" type="costroundingtype" default="UpToHalf"/> <xs:anyAttribute processContents="lax"/> </xs:complexType> - <xs:keyref name="equipmentSlot" refer="equipSlotName"> - <xs:selector xpath="."/> - <xs:field xpath="@equipmentSlot"/> - </xs:keyref> </xs:element> </xs:sequence> <xs:anyAttribute processContents="lax"/>