Skip to content

Documentation / @sw-file-lib/xml

@sw-file-lib/xml ​

TypeScript libraries for reading, writing Stormworks files.

This package includes parser, serializer, and typed schemas for Stormworks XML files. For other packages, see GitHub Repository.

Get Started

Documentation ​

Modules ​

ModuleDescription
xml-schemaModule for working with Stormworks XML data.

Namespaces ​

NamespaceDescription
ComponentDefinitionSchemas-
MicrocontrollerSchemas-
VehicleSchemas-

Classes ​

ClassDescription
SwXmlParseErrorAn error thrown when there were unexpected conversion failures in conversion from fast-xml-parser result to internal node tree.
SwXmlStructureErrorAn error thrown when parsed XML nodes cannot be interpreted as the requested structure.
SwXmlNodeListA list of parsed Stormworks XML nodes.
SwXmlNodeA parsed Stormworks XML element.
XmlWriterA utility class for generating XML content programmatically.

Interfaces ​

InterfaceDescription
SwXmlStructureErrorDetailsAdditional metadata for XML structure errors.
XmlVec2Represents elements with x and y attributes in Stormworks XML data.
XmlVec3Represents elements with x, y, and z attributes in Stormworks XML data.
XmlRgbRepresents elements with r, g, and b attributes in Stormworks XML data.
XmlMat3Represents elements with 00, 01, 02, 10, 11, 12, 20, 21, and 22 attributes in Stormworks XML data.
TextValuePairRepresents elements with text and value attributes in Stormworks microcontroller data.
XmlVec2ImmutableRepresents elements with x and y attributes in Stormworks XML data.
XmlVec3ImmutableRepresents elements with x, y, and z attributes in Stormworks XML data.
XmlRgbImmutableRepresents elements with r, g, and b attributes in Stormworks XML data.
XmlMat3ImmutableRepresents elements with 00, 01, 02, 10, 11, 12, 20, 21, and 22 attributes in Stormworks XML data.
TextValuePairImmutableRepresents elements with text and value attributes in Stormworks microcontroller data.
XmlWriterOptionsOptions for configuring the behavior of an XmlWriter instance.

Type Aliases ​

Type AliasDescription
SwXmlParseErrorCodeError codes for SwXmlParseError.
SwXmlStructureErrorCodeError codes for SwXmlStructureError.
DuplicateChildElementModeHow to resolve duplicate child elements when reading an XML record.
ParseOptionsOptions used when parsing Stormworks XML files.
XmlAttributeValueValue types that can be used as XML attribute values.
XmlAttributesAn iterable of key-value pairs representing XML attributes.

Variables ​

VariableDescription
XmlVec2SchemaRepresents elements with x and y attributes in Stormworks XML data.
XmlVec3SchemaRepresents elements with x, y, and z attributes in Stormworks XML data.
XmlRgbSchemaRepresents elements with r, g, and b attributes in Stormworks XML data.
XmlMat3SchemaRepresents elements with 00, 01, 02, 10, 11, 12, 20, 21, and 22 attributes in Stormworks XML data.
TextValuePairSchemaRepresents elements with text and value attributes in Stormworks microcontroller data.

Functions ​

FunctionDescription
parseSwXmlParses a Stormworks XML document into a node tree.
parseComponentDefinitionXmlParses a Stormworks component definition XML document.
safeParseComponentDefinitionXmlParses a Stormworks component definition XML document without throwing schema errors.
serializeComponentDefinitionXmlSerializes a Stormworks component definition into an XML document.
safeSerializeComponentDefinitionXmlSerializes a Stormworks component definition into an XML document without throwing schema errors.
parseVehicleXmlParses a Stormworks vehicle XML document.
safeParseVehicleXmlParses a Stormworks vehicle XML document without throwing schema errors.
serializeVehicleXmlSerializes a Stormworks vehicle into an XML document.
safeSerializeVehicleXmlSerializes a Stormworks vehicle into an XML document without throwing schema errors.
parseMicrocontrollerXmlParses a standalone Stormworks microcontroller XML document rooted at <microprocessor>.
safeParseMicrocontrollerXmlParses a standalone Stormworks microcontroller XML document without throwing schema errors.
serializeMicrocontrollerXmlSerializes a standalone Stormworks microcontroller into an XML document rooted at <microprocessor>.
safeSerializeMicrocontrollerXmlSerializes a standalone Stormworks microcontroller into an XML document without throwing schema errors.
escapeXmlAttributeEscape special characters in a string for use in XML attribute values.

References ​

ComponentDefinitionSchema ​

Re-exports ComponentDefinitionSchema


ComponentDefinition ​

Re-exports ComponentDefinition


ComponentDefinitionImmutable ​

Re-exports ComponentDefinitionImmutable


MicroprocessorSchema ​

Re-exports MicroprocessorSchema


Microprocessor ​

Re-exports Microprocessor


MicroprocessorImmutable ​

Re-exports MicroprocessorImmutable


VehicleSchema ​

Re-exports VehicleSchema


Vehicle ​

Re-exports Vehicle


VehicleImmutable ​

Re-exports VehicleImmutable


SchemaError ​

Re-exports SchemaError


SchemaSerializeError ​

Re-exports SchemaSerializeError