Add SaveGameValidator and improve validation.

This commit is contained in:
Michael Vehrs 2010-01-23 08:57:16 +00:00
parent 762520404a
commit 104afa1f03
11 changed files with 603 additions and 485 deletions

View File

@ -704,10 +704,23 @@
</java>
</target>
<!-- Validates a savegame files specified as property file
("-Dsavegame=whatever.fsg", for example). If file is a directory,
all savegame files in that directory will be validated. -->
<target name="validate-savegame" depends="build"
description="Validates a savegame, or directory of savegames.">
<condition property="savegame" else="">
<isset property="savegame" />
</condition>
<java classname="net.sf.freecol.tools.SaveGameValidator" classpath="build/" >
<arg value="${savegame}" />
</java>
</target>
<!-- Creates installer strings. -->
<target name="installer-translations" depends="build"
description="Creates properties files for installer translations.">
<java classname="net.sf.freecol.tools.InstallerTranslations" classpath="build/" />
<java classname="net.sf.freecol.tools.InstallerTranslations" classpathref="test.run.classpath" />
</target>
<target name="pmd">

View File

@ -1,58 +1,58 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
This file is part of FreeCol.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="data-common.xsd">
<xs:annotation>
<xs:documentation>
Include common data model type definitions.
</xs:documentation>
</xs:annotation>
</xs:include>
<xs:element name="equipment">
<xs:annotation>
<xs:documentation>
List of unit's equipment
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="xLength" type="xs:int">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
This file is part of FreeCol.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
<xs:documentation>
Number of elements in the list
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="data-common.xsd">
<xs:annotation>
<xs:documentation>
Include common data model type definitions.
</xs:documentation>
</xs:annotation>
</xs:include>
<xs:element name="equipment">
<xs:annotation>
<xs:documentation>
List of unit's equipment
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="xLength" type="xs:int">
<xs:annotation>
<xs:documentation>
Number of elements in the list
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##local">
<xs:annotation>
<xs:documentation>
Equipment type list with attributes "x0", "x1",
"x2" etc.
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:attribute>
<xs:anyAttribute namespace="##local" processContents="skip">
<xs:annotation>
<xs:documentation>
Equipment type list with attributes "x0", "x1",
"x2" etc.
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -36,23 +36,23 @@
<xs:element name="goodsContainer">
<xs:complexType>
<xs:sequence>
<xs:element name="storedGoods">
<xs:element name="storedGoods" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="goods"></xs:element>
<xs:element ref="goods"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="oldStoredGoods">
<xs:element name="oldStoredGoods" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="goods"></xs:element>
<xs:element ref="goods"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="ID" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="ID" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>

View File

@ -1,63 +1,63 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
This file is part of FreeCol.
This file is part of FreeCol.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="data-common.xsd" />
<xs:include schemaLocation="data-common.xsd" />
<xs:element name="historyEvent">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="strings">
<xs:complexType>
<xs:attribute name="xLength" type="xs:int" use="required"></xs:attribute>
<xs:anyAttribute namespace="##local"></xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="id" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="turn" type="xs:int" use="required"></xs:attribute>
<xs:attribute name="type" type="HistoryEventType" use="required"></xs:attribute>
</xs:complexType>
<xs:element name="historyEvent">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="strings">
<xs:complexType>
<xs:attribute name="xLength" type="xs:int" use="required"/>
<xs:anyAttribute namespace="##local" processContents="skip"/>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="id" type="xs:string" use="required"/>
<xs:attribute name="turn" type="xs:int" use="required"/>
<xs:attribute name="type" type="HistoryEventType" use="required"/>
</xs:complexType>
</xs:element>
<xs:simpleType name="HistoryEventType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="DISCOVER_NEW_WORLD" />
<xs:enumeration value="DISCOVER_REGION" />
<xs:enumeration value="MEET_NATION" />
<xs:enumeration value="CITY_OF_GOLD" />
<xs:enumeration value="FOUND_COLONY" />
<xs:enumeration value="ABANDON_COLONY" />
<xs:enumeration value="CONQUER_COLONY" />
<xs:enumeration value="COLONY_DESTROYED" />
<xs:enumeration value="COLONY_CONQUERED" />
<xs:enumeration value="DESTROY_SETTLEMENT" />
<xs:enumeration value="DESTROY_NATION" />
<xs:enumeration value="FOUNDING_FATHER" />
<xs:enumeration value="DECLARE_INDEPENDENCE" />
<xs:enumeration value="INDEPENDENCE" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="HistoryEventType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="DISCOVER_NEW_WORLD" />
<xs:enumeration value="DISCOVER_REGION" />
<xs:enumeration value="MEET_NATION" />
<xs:enumeration value="CITY_OF_GOLD" />
<xs:enumeration value="FOUND_COLONY" />
<xs:enumeration value="ABANDON_COLONY" />
<xs:enumeration value="CONQUER_COLONY" />
<xs:enumeration value="COLONY_DESTROYED" />
<xs:enumeration value="COLONY_CONQUERED" />
<xs:enumeration value="DESTROY_SETTLEMENT" />
<xs:enumeration value="DESTROY_NATION" />
<xs:enumeration value="FOUNDING_FATHER" />
<xs:enumeration value="DECLARE_INDEPENDENCE" />
<xs:enumeration value="INDEPENDENCE" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
</xs:schema>

View File

@ -1,78 +1,82 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
This file is part of FreeCol.
This file is part of FreeCol.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="data-common.xsd" />
<xs:include schemaLocation="data-unit.xsd" />
<xs:include schemaLocation="data-common.xsd" />
<xs:include schemaLocation="data-unit.xsd" />
<xs:element name="indianSettlement">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="isVisited">
<xs:complexType>
<xs:attribute name="player" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="alarm">
<xs:complexType>
<xs:attribute name="player" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="value" type="xs:int" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element ref="missionary"></xs:element>
<xs:element name="units">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="unit"></xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="ownedUnits" type="unitElementType">
</xs:element>
<xs:element ref="goods"></xs:element>
</xs:choice>
<xs:attribute name="ID" type="object-id" use="required"></xs:attribute>
<xs:attribute name="tile" type="object-id" use="required"></xs:attribute>
<xs:attribute name="owner" type="object-id" use="required"></xs:attribute>
<xs:attribute name="convertProgress" type="xs:int" use="optional"
default="0"></xs:attribute>
<xs:attribute name="lastTribute" type="xs:int" use="optional"
default="0"></xs:attribute>
<xs:attribute name="isCapital" type="xs:boolean" use="optional"
default="false"></xs:attribute>
<xs:attribute name="learnableSkill" type="xs:string"
use="optional"></xs:attribute>
<xs:attribute name="wantedGoods0" type="xs:string" use="optional"></xs:attribute>
<xs:attribute name="wantedGoods1" type="xs:string" use="optional"></xs:attribute>
<xs:attribute name="wantedGoods2" type="xs:string" use="optional"></xs:attribute>
</xs:complexType>
<xs:element name="indianSettlement">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="isVisited">
<xs:complexType>
<xs:attribute name="player" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="alarm">
<xs:complexType>
<xs:attribute name="player" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:int" use="required"/>
</xs:complexType>
</xs:element>
<xs:element ref="missionary"/>
<xs:element name="units">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="unit"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="ownedUnits">
<xs:complexType>
<xs:attribute name="ID" type="object-id"/>
</xs:complexType>
</xs:element>
<xs:element ref="goodsContainer"/>
</xs:choice>
<xs:attribute name="ID" type="object-id" use="required"/>
<xs:attribute name="tile" type="object-id" use="required"/>
<xs:attribute name="owner" type="object-id" use="required"/>
<xs:attribute name="convertProgress" type="xs:int" use="optional"
default="0"/>
<xs:attribute name="lastTribute" type="xs:int" use="optional"
default="0"/>
<xs:attribute name="isCapital" type="xs:boolean" use="optional"
default="false"/>
<xs:attribute name="learnableSkill" type="xs:string"
use="optional"/>
<xs:attribute name="wantedGoods0" type="xs:string" use="optional"/>
<xs:attribute name="wantedGoods1" type="xs:string" use="optional"/>
<xs:attribute name="wantedGoods2" type="xs:string" use="optional"/>
<xs:attribute name="name" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
</xs:schema>
</xs:schema>

View File

@ -48,7 +48,7 @@
</xs:annotation>
</xs:attribute>
<xs:anyAttribute namespace="##local">
<xs:anyAttribute namespace="##local" processContents="skip">
<xs:annotation>
<xs:documentation>
ID of father with the names "x0", "x1", "x2"
@ -112,7 +112,7 @@
<xs:attribute name="attackedByPrivateers" type="xs:boolean"
use="optional" default="false"/>
<xs:attribute name="entryLocation" type="xs:string" use="optional"/>
<xs:attribute name="currentFather" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>

View File

@ -1,149 +1,150 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:annotation>
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
This file is part of FreeCol.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="data-common.xsd" />
<xs:element name="region">
<xs:annotation>
<xs:documentation>Region reveal information</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="children">
<xs:complexType>
<xs:attribute name="xLength" type="xs:int" use="required"/>
<xs:anyAttribute namespace="##local" processContents="skip">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
This file is part of FreeCol.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="data-common.xsd" />
<xs:element name="region">
<xs:annotation>
<xs:documentation>Region reveal information</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="children">
<xs:complexType>
<xs:attribute name="xLength" type="xs:int" use="required"></xs:attribute>
<xs:anyAttribute namespace="##local">
<xs:annotation>
<xs:documentation>
Value enumeration x0, x1, x2, x3 etc.
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="ID" type="object-id" use="required">
<xs:annotation>
<xs:documentation>
Object ID
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="nameKey" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>
Key used to retrieve description from Messages
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="claimable" type="xs:boolean" use="optional"
default="false">
<xs:annotation>
<xs:documentation>
Whether this Region is claimable. Ocean Regions
and non-leaf Regions
should not be claimable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="discoverable" type="xs:boolean" use="optional"
default="false">
<xs:annotation>
<xs:documentation>
Whether this Region is discoverable. The Eastern
Ocean regions should not
be discoverable. In general, non-leaf
regions should not be
discoverable. The Pacific Ocean is an
exception, however.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="prediscovered" type="xs:boolean"
use="optional" default="false">
<xs:annotation>
<xs:documentation>
Whether the Region is already discovered when the
game starts.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="scoreValue" type="xs:int" use="optional"
default="0">
<xs:annotation>
<xs:documentation>
How much discovering this Region contributes to
your score. This
should be zero unless the Region is discoverable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type" type="RegionType" use="required">
<xs:annotation>
<xs:documentation>
Object ID
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="discoveredIn" type="xs:int" use="optional"
default="-1">
<xs:annotation>
<xs:documentation>
Which Turn the Region was discovered in.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="discoveredBy" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
Which Player the Region was discovered by.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="parent" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
The parent Region of this Region.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
Value enumeration x0, x1, x2, x3 etc.
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="ID" type="object-id" use="required">
<xs:annotation>
<xs:documentation>
Object ID
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="nameKey" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>
Key used to retrieve description from Messages
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="claimable" type="xs:boolean" use="optional"
default="false">
<xs:annotation>
<xs:documentation>
Whether this Region is claimable. Ocean Regions
and non-leaf Regions
should not be claimable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="discoverable" type="xs:boolean" use="optional"
default="false">
<xs:annotation>
<xs:documentation>
Whether this Region is discoverable. The Eastern
Ocean regions should not
be discoverable. In general, non-leaf
regions should not be
discoverable. The Pacific Ocean is an
exception, however.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="prediscovered" type="xs:boolean"
use="optional" default="false">
<xs:annotation>
<xs:documentation>
Whether the Region is already discovered when the
game starts.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="scoreValue" type="xs:int" use="optional"
default="0">
<xs:annotation>
<xs:documentation>
How much discovering this Region contributes to
your score. This
should be zero unless the Region is discoverable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type" type="RegionType" use="required">
<xs:annotation>
<xs:documentation>
Object ID
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="discoveredIn" type="xs:int" use="optional"
default="-1">
<xs:annotation>
<xs:documentation>
Which Turn the Region was discovered in.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="discoveredBy" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
Which Player the Region was discovered by.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="parent" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
The parent Region of this Region.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:simpleType name="RegionType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="OCEAN" />
<xs:enumeration value="COAST" />
<xs:enumeration value="LAKE" />
<xs:enumeration value="RIVER" />
<xs:enumeration value="LAND" />
<xs:enumeration value="MOUNTAIN" />
<xs:enumeration value="DESERT" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RegionType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="OCEAN" />
<xs:enumeration value="COAST" />
<xs:enumeration value="LAKE" />
<xs:enumeration value="RIVER" />
<xs:enumeration value="LAND" />
<xs:enumeration value="MOUNTAIN" />
<xs:enumeration value="DESERT" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
</xs:schema>

View File

@ -28,7 +28,7 @@
<xs:include schemaLocation="data-indianSettlement.xsd" />
<xs:include schemaLocation="data-tileitemcontainer.xsd" />
<xs:include schemaLocation="data-playerExploredTile.xsd" />
<xs:include schemaLocation="data-unit.xsd" />
<xs:element name="tile">
<xs:complexType>
@ -37,6 +37,7 @@
<xs:element ref="indianSettlement" />
<xs:element ref="tileitemcontainer" />
<xs:element ref="playerExploredTile" />
<xs:element ref="units" />
</xs:choice>
<xs:attribute name="ID" type="object-id" use="required" />

View File

@ -1,72 +1,72 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
This file is part of FreeCol.
This file is part of FreeCol.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="data-common.xsd" />
<xs:include schemaLocation="data-common.xsd" />
<xs:element name="tradeRoute">
<xs:element name="tradeRoute">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="tradeRouteStop">
<xs:complexType>
<xs:choice>
<xs:element name="cargo">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="tradeRouteStop">
<xs:complexType>
<xs:choice>
<xs:element name="cargo">
<xs:complexType>
<xs:attribute name="xLength" type="xs:int" use="required"></xs:attribute>
<xs:anyAttribute namespace="##local">
<xs:annotation>
<xs:documentation>
Cargo Type _index_ inside attributes "x0", "x1", "x2" etc.
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="location" type="object-id" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="ID" type="object-id" use="required">
<xs:annotation>
<xs:documentation>Object ID</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="owner" type="object-id" use="required">
<xs:annotation>
<xs:documentation>
ID of the player
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>
Trade route name
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="xLength" type="xs:int" use="required"/>
<xs:anyAttribute namespace="##local" processContents="skip">
<xs:annotation>
<xs:documentation>
Cargo Type _index_ inside attributes "x0", "x1", "x2" etc.
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="location" type="object-id" use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="ID" type="object-id" use="required">
<xs:annotation>
<xs:documentation>Object ID</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="owner" type="object-id" use="required">
<xs:annotation>
<xs:documentation>
ID of the player
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>
Trade route name
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
</xs:schema>

View File

@ -1,131 +1,148 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
elementFormDefault="qualified">
<xs:annotation>
<xs:documentation>
Copyright (C) 2002-2007 The FreeCol Team
This file is part of FreeCol.
This file is part of FreeCol.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
FreeCol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
You should have received a copy of the GNU General Public License
along with FreeCol. If not, see http://www.gnu.org/licenses
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="data-common.xsd">
<xs:annotation>
<xs:documentation>
Include common data model type definitions.
</xs:documentation>
</xs:annotation>
</xs:include>
<xs:include schemaLocation="data-common.xsd">
<xs:annotation>
<xs:documentation>
Include common data model type definitions.
</xs:documentation>
</xs:annotation>
</xs:include>
<xs:include schemaLocation="data-goodsContainer.xsd"/>
<xs:include schemaLocation="data-equipment.xsd"/>
<xs:include schemaLocation="data-tileimprovement.xsd"/>
<xs:include schemaLocation="data-goodsContainer.xsd"/>
<xs:include schemaLocation="data-equipment.xsd"/>
<xs:include schemaLocation="data-tileimprovement.xsd"/>
<xs:element name="unit" type="unitElementType">
<xs:annotation>
<xs:documentation>
Represents all pieces that can be moved on the
map-board. This includes: colonists, ships, wagon trains e.t.c.
<xs:element name="unit" type="unitElementType">
<xs:annotation>
<xs:documentation>
Represents all pieces that can be moved on the
map-board. This includes: colonists, ships, wagon trains e.t.c.
Every Unit is owned by a Player and has a Location.
</xs:documentation>
</xs:annotation>
Every Unit is owned by a Player and has a Location.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:element>
<xs:element name="missionary" type="unitElementType">
<xs:element name="units">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="unit"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="missionary" type="unitElementType">
<xs:annotation>
<xs:documentation>
Unit specialization used in Indian settlements.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="unitElementType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="goodsContainer"/>
<xs:element ref="equipment"/>
<xs:element ref="units"/>
<xs:element ref="tileimprovement">
<xs:annotation>
<xs:documentation>
Unit specialization used in Indian settlements.
</xs:documentation>
<xs:documentation>
The TileImprovement this Unit is working on.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:element>
</xs:choice>
<xs:complexType name="unitElementType">
<xs:attribute name="ID" type="object-id" use="required">
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="unitType" type="xs:string" use="required"/>
<xs:attribute name="movesLeft" type="xs:int" use="required"/>
<xs:attribute name="state" type="UnitState" use="required"/>
<xs:attribute name="role" type="UnitRole" use="required"/>
<xs:attribute name="owner" type="object-id" use="required"/>
<xs:attribute name="turnsOfTraining" type="xs:int" use="required"/>
<xs:attribute name="workType" type="xs:string" use="required"/>
<xs:attribute name="experience" type="xs:int" use="required"/>
<xs:attribute name="treasureAmount" type="xs:int" use="required"/>
<xs:attribute name="hitpoints" type="xs:int" use="required"/>
<xs:attribute name="attrition" type="xs:int" use="required"/>
<xs:attribute name="student" type="xs:string" use="optional"/>
<xs:attribute name="teacher" type="xs:string" use="optional"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="goodsContainer"></xs:element>
<xs:element ref="equipment"></xs:element>
<xs:element ref="tileimprovement"></xs:element>
</xs:choice>
<xs:attribute name="indianSettlement" type="xs:string"
use="optional"/>
<xs:attribute name="workLeft" type="xs:integer" use="required"/>
<xs:attribute name="ID" type="object-id" use="required">
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="optional"></xs:attribute>
<xs:attribute name="unitType" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="movesLeft" type="xs:int" use="required"></xs:attribute>
<xs:attribute name="state" type="UnitState" use="required"></xs:attribute>
<xs:attribute name="role" type="UnitRole" use="required"></xs:attribute>
<xs:attribute name="owner" type="object-id" use="required"></xs:attribute>
<xs:attribute name="turnsOfTraining" type="xs:int" use="required"></xs:attribute>
<xs:attribute name="workType" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="experience" type="xs:int" use="required"></xs:attribute>
<xs:attribute name="treasureAmount" type="xs:int" use="required"></xs:attribute>
<xs:attribute name="hitpoints" type="xs:int" use="required"></xs:attribute>
<xs:attribute name="attrition" type="xs:int" use="required"></xs:attribute>
<xs:attribute name="student" type="xs:string" use="optional"></xs:attribute>
<xs:attribute name="teacher" type="xs:string" use="optional"></xs:attribute>
<xs:attribute name="entryLocation" type="object-id" use="optional"/>
<xs:attribute name="location" type="object-id" use="optional"/>
<xs:attribute name="destination" type="object-id" use="optional"/>
<xs:attribute name="indianSettlement" type="xs:string"
use="optional"></xs:attribute>
<xs:attribute name="workLeft" type="xs:integer" use="required"></xs:attribute>
<xs:attribute name="tradeRoute" type="object-id" use="optional"/>
<xs:attribute name="currentStop" type="xs:int" use="optional"/>
<xs:attribute name="entryLocation" type="object-id" use="optional"></xs:attribute>
<xs:attribute name="location" type="object-id" use="optional"></xs:attribute>
<xs:attribute name="visibleGoodsCount" type="xs:int" use="optional"/>
<xs:attribute name="tradeRoute" type="object-id" use="optional"></xs:attribute>
<xs:attribute name="currentStop" type="xs:int" use="optional"></xs:attribute>
<xs:attribute name="visibleGoodsCount" type="xs:int" use="optional"></xs:attribute>
</xs:complexType>
</xs:complexType>
<xs:simpleType name="UnitState">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="ACTIVE" />
<xs:enumeration value="FORTIFIED" />
<xs:enumeration value="SENTRY" />
<xs:enumeration value="IN_COLONY" />
<xs:enumeration value="IMPROVING" />
<xs:enumeration value="TO_EUROPE" />
<xs:enumeration value="IN_EUROPE" />
<xs:enumeration value="TO_AMERICA" />
<xs:enumeration value="FORTIFYING" />
<xs:enumeration value="SKIPPED" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="UnitState">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="ACTIVE" />
<xs:enumeration value="FORTIFIED" />
<xs:enumeration value="SENTRY" />
<xs:enumeration value="IN_COLONY" />
<xs:enumeration value="IMPROVING" />
<xs:enumeration value="TO_EUROPE" />
<xs:enumeration value="IN_EUROPE" />
<xs:enumeration value="TO_AMERICA" />
<xs:enumeration value="FORTIFYING" />
<xs:enumeration value="SKIPPED" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="UnitRole">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="DEFAULT" />
<xs:enumeration value="PIONEER" />
<xs:enumeration value="MISSIONARY" />
<xs:enumeration value="SOLDIER" />
<xs:enumeration value="SCOUT" />
<xs:enumeration value="DRAGOON" />
<xs:enumeration value="default" />
<xs:enumeration value="pioneer" />
<xs:enumeration value="missionary" />
<xs:enumeration value="soldier" />
<xs:enumeration value="scout" />
<xs:enumeration value="dragoon" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="UnitRole">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="DEFAULT" />
<xs:enumeration value="PIONEER" />
<xs:enumeration value="MISSIONARY" />
<xs:enumeration value="SOLDIER" />
<xs:enumeration value="SCOUT" />
<xs:enumeration value="DRAGOON" />
<xs:enumeration value="default" />
<xs:enumeration value="pioneer" />
<xs:enumeration value="missionary" />
<xs:enumeration value="soldier" />
<xs:enumeration value="scout" />
<xs:enumeration value="dragoon" />
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -0,0 +1,82 @@
/**
* Copyright (C) 2002-2007 The FreeCol Team
*
* This file is part of FreeCol.
*
* FreeCol is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* FreeCol is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FreeCol. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.freecol.tools;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import net.sf.freecol.common.io.FreeColSavegameFile;
import org.xml.sax.SAXParseException;
public class SaveGameValidator {
private static FileFilter fsgFilter = new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith(".fsg");
}
};
public static void main(String[] args) throws Exception {
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
File schemaLocation = new File("schema/data/data-savedGame.xsd");
Schema schema = factory.newSchema(schemaLocation);
Validator saveGameValidator = schema.newValidator();
List<File> allFiles = new ArrayList<File>();
for (String name : args) {
File file = new File(name);
if (file.exists()) {
if (file.isDirectory()) {
for (File fsg : file.listFiles(fsgFilter)) {
allFiles.add(fsg);
}
} else if (fsgFilter.accept(file)) {
allFiles.add(file);
}
}
}
for (File file : allFiles) {
System.out.println("Processing file " + file.getPath());
try {
FreeColSavegameFile mapFile = new FreeColSavegameFile(file);
saveGameValidator.validate(new StreamSource(mapFile.getSavegameInputStream()));
System.out.println("Successfully validated " + file.getName());
} catch(SAXParseException e) {
System.out.println(e.getMessage()
+ " at line=" + e.getLineNumber()
+ " column=" + e.getColumnNumber());
}
}
}
}