Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#46 closed defect (released)

Resolve problems using custom restrictions of decimal and double

Reported by: ibboard Owned by: ibboard
Priority: major Milestone:
Component: WarFoundry-API Version:
Keywords: Cc:
Blocked By: Blocking:

Description

The WarFoundry-Core.xsd file defines some custom simple types that are used for attributes that can be zero or more, or infinite (which is internally represented as "-1" and is easier to handle than INF).

Currently uses of the types have been replaced with use of the default types (e.g. xs:double) to avoid the errors, but this should be fixed. The only one that works is Percentage, which also uses double but specifies a min and max.

An example stack trace is:

WARN  [20:03:36]: LogNotifierHandler.Warn() - Line: 48 - WarFoundryLoader: Conversion from schema type http://ibboard.co.uk/warfoundry/core:infiniteOrNonNegativeInteger (type code Decimal) to String is not supported
System.InvalidCastException: Conversion from schema type http://ibboard.co.uk/warfoundry/core:infiniteOrNonNegativeInteger (type code Decimal) to String is not supported
  at System.Xml.Schema.XmlAtomicValue.get_Value () [0x0026a] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml.Schema/XmlAtomicValue.cs:418 
  at System.Xml.Schema.XmlSchemaValidator.AssessAttributeLocallyValid (System.Xml.Schema.XmlSchemaAttribute attr, System.Xml.Schema.XmlSchemaInfo info, System.Xml.Schema.XmlValueGetter getter) [0x000af] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs:830 
  at System.Xml.Schema.XmlSchemaValidator.AssessAttributeElementLocallyValidType (System.String localName, System.String ns, System.Xml.Schema.XmlValueGetter getter, System.Xml.Schema.XmlSchemaInfo info) [0x00053] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs:803 
  at System.Xml.Schema.XmlSchemaValidator.ValidateAttribute (System.String localName, System.String ns, System.Xml.Schema.XmlValueGetter attributeValue, System.Xml.Schema.XmlSchemaInfo info) [0x000ca] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml.Schema/XmlSchemaValidator.cs:378 
  at Mono.Xml.Schema.XmlSchemaValidatingReader.Read () [0x00202] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/Mono.Xml.Schema/XmlSchemaValidatingReader.cs:730 
  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x0035c] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml/XmlDocument.cs:991 
  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00192] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml/XmlDocument.cs:919 
  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00192] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml/XmlDocument.cs:919 
  at System.Xml.XmlDocument.ReadNode (System.Xml.XmlReader reader) [0x0004c] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml/XmlDocument.cs:844 
  at System.Xml.XmlDocument.Load (System.Xml.XmlReader xmlReader) [0x00019] in /usr/src/packages/BUILD/mono-2.2/mcs/class/System.XML/System.Xml/XmlDocument.cs:708 
  at IBBoard.WarFoundry.API.Factories.Xml.WarFoundryXmlFactory.CreateXmlDocumentFromStream (System.IO.Stream stream) [0x00013] in /home/ibboard/eclipse/IBBoard.WarFoundry.API/api/Factories/Xml/WarFoundryXmlFactory.cs:290 
  at IBBoard.WarFoundry.API.Factories.Xml.WarFoundryXmlFactory.GetRootElementFromStream (System.IO.Stream stream, IBBoard.WarFoundry.API.Factories.Xml.WarFoundryXmlElementName elementName) [0x00000] in /home/ibboard/eclipse/IBBoard.WarFoundry.API/api/Factories/Xml/WarFoundryXmlFactory.cs:64 
  at IBBoard.WarFoundry.API.Factories.Xml.WarFoundryXmlFactory.CreateRaceFromStream (ICSharpCode.SharpZipLib.Zip.ZipFile file, System.IO.Stream dataStream) [0x00000] in /home/ibboard/eclipse/IBBoard.WarFoundry.API/api/Factories/Xml/WarFoundryXmlFactory.cs:138 
  at IBBoard.WarFoundry.API.Factories.AbstractNativeWarFoundryFactory.CreateRaceFromFile (ICSharpCode.SharpZipLib.Zip.ZipFile file) [0x00000] in /home/ibboard/eclipse/IBBoard.WarFoundry.API/api/Factories/AbstractNativeWarFoundryFactory.cs:121 
  at IBBoard.WarFoundry.API.Factories.AbstractNativeWarFoundryFactory.DoCreateObjectsFromFile (ICSharpCode.SharpZipLib.Zip.ZipFile file) [0x00038] in /home/ibboard/eclipse/IBBoard.WarFoundry.API/api/Factories/AbstractNativeWarFoundryFactory.cs:93 
  at IBBoard.WarFoundry.API.Factories.AbstractWarFoundryFactory`1[System.Object].CreateObjectsFromFile (System.IO.FileInfo file) [0x00000] 
  at IBBoard.WarFoundry.API.WarFoundryLoader.LoadObject (System.IO.FileInfo file, IWarFoundryFactory factory) [0x0002f] in /home/ibboard/eclipse/IBBoard.WarFoundry.API/api/WarFoundryLoader.cs:343 
  at IBBoard.WarFoundry.API.WarFoundryLoader.LoadRaces (System.Collections.Generic.Dictionary`2 raceFiles) [0x00021] in /home/ibboard/eclipse/IBBoard.WarFoundry.API/api/WarFoundryLoader.cs:316 

Change History (5)

comment:1 Changed 11 years ago by ibboard

Tried defining unitType as

<xs:complexType name="unittype">
  <xs:all>
    <xs:element name="stats" type="statstype" minOccurs="1" />
    <xs:element name="unitEquipment" type="unitequipmenttype" />
    <xs:element name="unitAbilities" type="unitabilitiestype" minOccurs="0" />
    <xs:element name="requirements" type="requirementstype" minOccurs="0" />
    <xs:element name="contains" type="containstype" minOccurs="0" />
    <xs:element name="extraData" type="extradatatype" minOccurs="0" />
    <xs:element name="notes" type="xs:string" minOccurs="0" />
  </xs:all>
  <xs:attribute name="id" type="xs:ID" />
  <xs:attribute name="typeName" type="xs:string" use="required"/>
  <xs:attribute name="cat" type="xs:string" use="required"/>
  <xs:attribute name="unitPoints" type="core:nonNegativeDecimal" default="0"/>
  <xs:attribute name="points" type="core:nonNegativeDecimal" use="required"/>
  <xs:attribute name="minNum" type="xs:nonNegativeInteger" default="0"/>
  <xs:attribute name="maxNum" type="core:infiniteOrNonNegativeInteger" default="-1"/>
  <xs:attribute name="minSize" type="xs:positiveInteger" default="5"/>
  <xs:attribute name="maxSize" type="core:infiniteOrNonNegativeInteger" default="-1"/>
  <xs:attribute name="baseSize" type="xs:nonNegativeInteger" default="0"/>
</xs:complexType>

in race schema (maxNum and maxSize use core:infiniteOrNonNegativeIntger instead of core:integer)
and errors still occur.

Tried adding ID as well as name to types in Core schema and errors still occur.

Tried adding maxExclusive/maxInclusive elements in Core schema and errors still occur.

Tried adding debug source for Mono, but still can't step in to doc.Load() method (which is incredibly useful in Eclipse) or catch and inspect the cast exception as it is thrown.

comment:2 Changed 11 years ago by ibboard

Resolution: fixed
Status: newclosed

(In r75) Fixes #47 - remove magic numbers

  • Create "infinity" in core types
  • Redefine special core types without trying to use non-existant INF for Integers
  • Use new types in Cats and Race
  • Remove special handling of INF when parsing an integer attribute

Closes #46 - Resolve problems using custom restrictions of decimal and double

  • New schemas seem to work without exceptioning

comment:3 Changed 10 years ago by ibboard

released: 1

Mark released changes as released

comment:4 Changed 10 years ago by ibboard

released: 1yes

Mark released fixes as released using radio values

comment:5 Changed 10 years ago by ibboard

Resolution: fixedreleased

Mark fix as released under a previous version

Note: See TracTickets for help on using tickets.