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.md → https://schemas.rutdev.se/xsd/types/strings-1.0.xsd
- dates/dates-1.0.md → https://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), becomesxsd:simpleType/@nameorxsd:complexType/@namexsd_type- EithersimpleTypeorcomplexTypedescription- 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 lengthmaxLength- Maximum string lengthwhiteSpace- Whitespace handling:preserve,replace,collapsepattern- Regular expression patternenumeration- List of allowed values (generates multiplexsd:enumerationelements)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 decimalfractionDigits- 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, useunboundedfor 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.