Expand description
Assembly Kit table definition parsing and schema generation.
This module handles the parsing of Assembly Kit schema files (table structure definitions) and their conversion to RPFM’s internal schema format. It supports three different Assembly Kit versions used across Total War games.
§Assembly Kit Schema Formats
Different Total War games use different schema file formats:
- Version 0 (Empire, Napoleon):
.xsdXML schema files with basic type and constraint information - Version 1 (Shogun 2):
TWaD_*.xmlfiles with enhanced metadata - Version 2 (Rome 2+):
TWaD_*.xmlfiles with full relationship data and field descriptions
§Main Types
§Version 1 & 2 Formats
RawDefinition: Represents a complete table definition with all fieldsRawField: Individual field definition with type, constraints, and relationship infoRawRelationshipsTable: Foreign key relationships between tablesRawRelationship: Single foreign key relationship
§Version 0 Format (Legacy)
RawDefinitionV0: XSD schema root structureElement: XSD element with type and constraint informationIndex: Database index definition (used to derive relationships)
§Functionality
The main operations this module provides:
- Batch Reading:
RawDefinition::read_all()reads all table definitions from a directory - Individual Reading:
RawDefinition::read()parses a single definition file - Field Filtering:
RawDefinition::get_non_localisable_fields()separates translatable fields - Schema Conversion:
From<&RawDefinition>forDefinitionconverts to RPFM format
§Version 0 Processing
Version 0 (Empire/Napoleon) uses a two-pass approach:
- First pass: Parse XSD files and extract basic field information and primary keys
- Second pass: Analyze index definitions to derive foreign key relationships
This is necessary because Version 0 uses database-style indexes rather than explicit foreign key declarations.
§Type Mapping
Assembly Kit types are mapped to RPFM field types:
yesno→Booleansingle→F32,double→F64integer→I32,autonumber/card64→I64colour→ColourRGBtext/expression→StringU8/StringU16(or optional variants)
Structs§
- Annotation
- Contains annotation metadata for XSD elements.
- AppInfo
- Contains application-specific information within XSD annotations.
- Complex
Type - Defines a complex type containing nested element sequences.
- Element
- Represents an XSD element definition from Assembly Kit v0 schema files.
- Index
- Defines a database index on a table column.
- MaxLength
- Specifies the maximum length constraint for a string field.
- RawDefinition
- Raw table definition parsed from Assembly Kit schema files.
- RawDefinition
V0 - Version 0 (Empire/Napoleon) XSD schema root structure.
- RawField
- Individual field definition from Assembly Kit schema.
- RawRelationship
- Single foreign key relationship definition.
- RawRelationships
Table - Foreign key relationships table from Assembly Kit.
- Restriction
- Defines restrictions/constraints on an XSD simple type.
- Sequence
- Represents an ordered sequence of XSD elements.
- Simple
Type - Defines a simple type with restrictions in XSD schemas.