Discriminated type alternatives for polymorphic values.
Unwraps a tuple of UnionShape branches to their eagerly-resolved ValueShape types.
Driving CRUD from union shapes, matched as sh:xone on write and sh:or on read
Resolves a union range to its concrete value-shape variants.
Picks the single variant compatible with a state value.
Picks the single variant compatible with a relational bound.
Picks every variant compatible with a retrieval model.
Creates a union of value shapes.
Union shape and factories.
Defines UnionShape and the union factory used to declare a polymorphic property that accepts more than one value type, as an exclusive disjunction (
sh:xone) of value-shape variants. The variants are mutually exclusive alternatives, matched in two regimes: a state value on persistence singles out exactly one variant (sh:xone) by value, while a model placeholder on retrieval matches at least one by kind (sh:or), requesting each it fits; extends-time narrowing pairs each child variant with a single parent variant. Variant order is preserved for deterministic error reporting and drives the indexed Union form through which union-typed slots are addressed in retrieval templates.The union design note covers how Blue drives full CRUD from union shapes, matched as
sh:xoneon write andsh:oron read.Inheritance
When a ResourceShape extends a parent via extends, a union-typed property may drop variants and tighten the variants it keeps, but never add new ones. Narrowing is the construction-time counterpart of the union's exclusive discrimination: each child variant must narrow exactly one parent variant, where narrowing is the value-shape override relation that governs non-union shapes — matching
kind(anddatatypeforstring/number, pluspatternforstringandintegralfornumber), only-tightening constraints, and, forreference/resource, a matching target shape or a subtype class. The pairing is order-independent and injective; either form is rejected when a child variant narrows no parent variant (unsatisfiable), several (ambiguous), or a parent already taken by another child variant (split). The child's form fixes the outcome:Single-variant narrowing (Form 1) — the child is a non-union value shape; it narrows its one parent variant and the result collapses to that merged shape, so the enclosing SetShape.shape is no longer a union.
Union subsetting (Form 2) — the child is a union; its variants each narrow a distinct parent variant, the paired variants are merged, unpaired parent variants are dropped, and the result stays a union.
The merged union's
modelre-indexes contiguously from0, following parent order. Dropping a parent variant renumbers every later variant — consumers must key off the shape's ownmodel, not assume positional alignment with an ancestor. Union-form templates ({"0": ..., "1": ...}) are interpreted against the current shape's variants; well-typed templates derived from Schema carry the correct indices automatically.See
SHACL § 4.6.4 sh:xone