Skip to main content

Module table_definition

Module table_definition 

Source
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): .xsd XML schema files with basic type and constraint information
  • Version 1 (Shogun 2): TWaD_*.xml files with enhanced metadata
  • Version 2 (Rome 2+): TWaD_*.xml files with full relationship data and field descriptions

§Main Types

§Version 1 & 2 Formats

§Version 0 Format (Legacy)

  • RawDefinitionV0: XSD schema root structure
  • Element: XSD element with type and constraint information
  • Index: Database index definition (used to derive relationships)

§Functionality

The main operations this module provides:

  1. Batch Reading: RawDefinition::read_all() reads all table definitions from a directory
  2. Individual Reading: RawDefinition::read() parses a single definition file
  3. Field Filtering: RawDefinition::get_non_localisable_fields() separates translatable fields
  4. Schema Conversion: From<&RawDefinition> for Definition converts to RPFM format

§Version 0 Processing

Version 0 (Empire/Napoleon) uses a two-pass approach:

  1. First pass: Parse XSD files and extract basic field information and primary keys
  2. 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:

  • yesnoBoolean
  • singleF32, doubleF64
  • integerI32, autonumber/card64I64
  • colourColourRGB
  • text/expressionStringU8/StringU16 (or optional variants)

Structs§

Annotation
Contains annotation metadata for XSD elements.
AppInfo
Contains application-specific information within XSD annotations.
ComplexType
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.
RawDefinitionV0
Version 0 (Empire/Napoleon) XSD schema root structure.
RawField
Individual field definition from Assembly Kit schema.
RawRelationship
Single foreign key relationship definition.
RawRelationshipsTable
Foreign key relationships table from Assembly Kit.
Restriction
Defines restrictions/constraints on an XSD simple type.
Sequence
Represents an ordered sequence of XSD elements.
SimpleType
Defines a simple type with restrictions in XSD schemas.