-
-
Notifications
You must be signed in to change notification settings - Fork 0
Datatypes and Facets
This document provides a full explanation of Named Datatypes, XSD datatype restrictions, and inline attribute-level facets in uml2semantics.
These features allow precise expression of lexical, syntactic, and numeric constraints directly from TSV inputs.
uml2semantics supports two parallel mechanisms for datatype constraints:
-
Named Datatypes defined in
Datatypes.tsv -
Inline facet restrictions inside
Attributes.tsv
Both approaches generate OWL 2 DatatypeRestriction constructs using XSD datatypes and facets.
Named datatypes allow domain-specific restricted datatypes such as:
- LEI20 (Legal Entity Identifier – 20 chars)
- BIC11 (Bank Identifier Code – 11 chars)
- CurrencyAmount
- MonthYearDatatype (xsd:gYearMonth restricted)
- CountryCode (2-char ISO code)
These centralise constraints and avoid repetition across attributes.
| Column | Description |
|---|---|
| Curie | CURIE for the datatype, e.g. iso:LEI20
|
| Name | Human-readable label |
| BaseDatatype | Must be an XSD primitive (e.g. xsd:string, xsd:integer, xsd:gYearMonth) |
| Definition | Optional explanatory text |
| Pattern | Optional regex pattern |
| MinLength | Minimum string length |
| MaxLength | Maximum string length |
| MinInclusive | Numeric or lexical lower bound |
| MaxInclusive | Numeric or lexical upper bound |
| MinExclusive | Exclusive lower bound |
| MaxExclusive | Exclusive upper bound |
| TotalDigits | Total number of digits allowed |
| FractionDigits | Allowed number of decimal digits |
Any combination of facets may be used, as long as they are valid for the BaseDatatype.
Curie Name BaseDatatype Pattern MinLength MaxLength
iso:LEI20 LEI20 xsd:string [A-Z0-9]{20} 20 20
Datatype: LEI20
EquivalentTo:
xsd:string
[ pattern "[A-Z0-9]{20}",
minLength 20,
maxLength 20 ]
iso:LEI20 a rdfs:Datatype ;
owl:equivalentClass [
a rdfs:Datatype ;
owl:onDatatype xsd:string ;
owl:withRestrictions (
[ xsd:pattern "[A-Z0-9]{20}" ]
[ xsd:minLength "20"^^xsd:integer ]
[ xsd:maxLength "20"^^xsd:integer ]
)
] .
Curie Name BaseDatatype MinInclusive MaxInclusive FractionDigits
iso:Percent PercentDatatype xsd:decimal 0 100 2
Datatype: PercentDatatype
EquivalentTo:
xsd:decimal
[ minInclusive 0,
maxInclusive 100,
fractionDigits 2 ]
Curie Name BaseDatatype Pattern
iso:MonthYear MonthYearType xsd:gYearMonth [0-9]{4}-[0-9]{2}
This enforces a strict lexical structure such as 2024-09.
Inline facets allow constraints to be specified directly in the attribute definition without creating a named datatype.
These inline restrictions are only emitted when the attribute range is an XSD primitive (e.g. xsd:string).
Class Name ClassEnumOrPrimitiveType MinMultiplicity MaxMultiplicity MinLength MaxLength Pattern
Account OwnerId xsd:string 1 1 16 16 [A-Z0-9]+
Generates a property with a restricted datatype.
Datatype: xsd:string
[ minLength 16,
maxLength 16,
pattern "[A-Z0-9]+" ]
And the property:
DataProperty: OwnerId
Range: xsd:string[minLength 16, maxLength 16, pattern "[A-Z0-9]+"]
If an attribute targets a named datatype (from Datatypes.tsv), any inline
facet columns on that attribute are ignored. Inline facets only apply when
the attribute range is an xsd: primitive.
Example:
If you need an attribute-specific restriction, point the attribute at an
xsd: primitive and use inline facets, or create a separate named datatype.
Class Name ClassEnumOrPrimitiveType Pattern MinLength MaxLength MinInclusive MaxInclusive
Acct OwnerTransactionId xsd:string [A-Z0-9]+(/[A-Z0-9]+)? 16 16
DataProperty: OwnerTransactionId
Range:
xsd:string
[ pattern "[A-Z0-9]+(/[A-Z0-9]+)?",
minLength 16,
maxLength 16 ]
graph TD
DT[Datatypes.tsv] --> ND[Named Datatypes]
A[Attributes.tsv] --> IF[Inline Facets]
ND --> DC[Datatype Restrictions]
IF --> DC
DC --> OWL[OWL Ontology Output]
- Prefer Named Datatypes when a constraint is reused.
- Use inline facets for attribute-specific restrictions.
- Ensure patterns are XML Schema–compatible.
- Use
gYearMonthfor year-month environment fields. - Keep numeric constraints consistent with business vocabularies.
- Avoid overlapping or contradictory restrictions.
- Named datatypes with facet columns must specify
BaseDatatype. If facets are present andBaseDatatypeis empty, the converter raises an error instead of defaulting toxsd:string.
- Return to TSV-Specification
- Go to Choice-Patterns
- Go to CLI-Usage
- Back to Home