A reference is a special layout that can be used to avoid directly embedding a value by instead embedding only an identifier to the value.
A reference layout can be built using the & character, followed by the type of reference.
For instance, we define here the Person type where each parent will be referenced in its default layout using the &Person layout.
Copy type Person {
name: required xs:string,
parent: multiple &Person
} A reference layout is exported into any type that can store both an IRI or blank node identifier. In most languages, it will be a string.
For instance, the above layout will be exported into the following JSON Schema:
Copy {
" type " : " object " ,
" properties " : {
" name " : {
" type " : " string "
},
" parent " : {
" type " : " array " ,
" item " : {
" type " : " string "
}
}
},
" required " : [
" name "
]
} When the language permits it, a more precise type will be used. For instance in Rust, the Id type of the treeldr-rust-prelude will be used by default, which is defined as follows:
As a consequence, the following Rust type definition is generated for Person: