Skip to content

Data Types

This directory contains data type definitions used across entity specifications. Types are organized by category and version, with directory names mapping directly to XML Schema URIs.

Directory Structure

types/
├── primitives/primitives-1.0.md    # XML Schema built-in types (xsd:)
├── strings/strings-1.0.md          # Restricted string types
├── dates/dates-1.0.md              # Date range types
├── coordinates/coordinates-1.0.md  # Coordinate types
└── enums/enums-1.0.md              # Enumeration types

URI Mapping

The directory and filename determine the generated XSD namespace:

  • Path: {category}/{category}-{version}.md
  • URI: https://schemas.rutdev.se/xsd/types/{category}-{version}.xsd

Examples: - strings/strings-1.0.mdhttps://schemas.rutdev.se/xsd/types/strings-1.0.xsd - dates/dates-1.0.mdhttps://schemas.rutdev.se/xsd/types/dates-1.0.xsd

Note: primitives/ references XML Schema built-in types and does not generate a separate XSD file.

YAML Specification Format

Each type file contains a YAML block defining one or more types. The format supports two XSD constructs: simpleType and complexType.

Common Fields

  • name - Type name (PascalCase), becomes xsd:simpleType/@name or xsd:complexType/@name
  • xsd_type - Either simpleType or complexType
  • description - Human-readable description (not included in XSD)

simpleType (Restricted Types)

Used for enumerations and restricted string types.

- name: TypeName
  xsd_type: simpleType
  base: xsd:string           # Base type for restriction
  description: "..."
  facets:                    # XSD restriction facets
    minLength: 1
    maxLength: 255
    whiteSpace: collapse
    pattern: "[A-Z]+"
    enumeration:             # For enum types
      - Value1
      - Value2

XSD Output:

<xsd:simpleType name="TypeName">
    <xsd:restriction base="xsd:string">
        <xsd:minLength value="1" />
        <xsd:maxLength value="255" />
        <xsd:whiteSpace value="collapse" />
    </xsd:restriction>
</xsd:simpleType>

complexType (Composite Types)

Used for structured types with child elements.

- name: TypeName
  xsd_type: complexType
  description: "..."
  elements:                  # Child elements in sequence
    - name: fieldName
      type: xsd:date         # XSD type reference
    - name: optionalField
      type: xsd:string
      minOccurs: 0           # Optional element (default: 1)

XSD Output:

<xsd:complexType name="TypeName">
    <xsd:sequence>
        <xsd:element name="fieldName" type="xsd:date" />
        <xsd:element name="optionalField" type="xsd:string" minOccurs="0" />
    </xsd:sequence>
</xsd:complexType>

Facet Reference

Supported XSD restriction facets:

  • minLength - Minimum string length
  • maxLength - Maximum string length
  • whiteSpace - Whitespace handling: preserve, replace, collapse
  • pattern - Regular expression pattern
  • enumeration - List of allowed values (generates multiple xsd:enumeration elements)
  • minInclusive - Minimum numeric value (inclusive)
  • maxInclusive - Maximum numeric value (inclusive)
  • minExclusive - Minimum numeric value (exclusive)
  • maxExclusive - Maximum numeric value (exclusive)
  • totalDigits - Maximum total digits for decimal
  • fractionDigits - Maximum fraction digits for decimal

Element Reference

Supported element attributes:

  • name - Element name (required)
  • type - XSD type reference, e.g., xsd:string, xsd:date (required)
  • minOccurs - Minimum occurrences (default: 1, use 0 for optional)
  • maxOccurs - Maximum occurrences (default: 1, use unbounded for lists)

Type Categories

Primitives

XML Schema built-in types referenced directly. Not used to generate XML schema files since the types are already defined in XML.

Strings

Restricted string types with max lengths et c.

Multilingual types (use with maxOccurs="unbounded"): MultilingualText, MultilingualShortString, MultilingualLongString

Type Registry

Entity directories contain a type-registry.yaml that maps prefixes to type sources. This enables:

  • Bare type names: Entity properties use PascalCase type names without prefixes
  • Automatic prefix resolution: Generator finds which spec file defines each type
  • Shared versions: All entities in a directory use the same type schema versions

See specs/types/type-registry.md for registry format and specs/entities/README.md for entity property documentation.