1. Introduction
This section is non-normative.
Realizing the value proposition of the Semantic Web lies in building useful and robust applications that can interoperate over linked data. Protocols such as [LDP] and [Solid] organize linked data graphs into resource hierarchies, providing a foundation upon which these robust and interoperable applications can be created.
Application interoperability depends on applications sharing semantics for relationships and data structures. Existing technologies fulfill portions of those dependencies:
-
RDF's foundation in unambiguous identifiers provides an infrastructure that allows for interoperability, but does not specifically encourage or enforce it.
-
Shape languages (e.g. [ShEx] and [SHACL]) provide machine-readable, enforceable data structure definitions on single resources.
For applications that operate on more complex and interconnected resources, Shape Trees express the layout of those resources and associate them with their respective shapes.
Shape trees marry RDF vocabularies, shapes, and resources into "little trees" that provide machine to machine interoperability, combining them into concepts that humans can easily comprehend, such as medical records, notes, notebooks, calendars, and financial records.
This allows one to treat a set of related resources as a single grouping, and apply that to a range of operations including access control, data organization, data validation, and data migration.
Shape trees are defined as an RDF graph structure that expresses a set of expected behaviors by agents that work with them. These semantics CAN be implemented by a server-side agent, or a client-side agent that pre-processes requests to a server. In the most typical use case, a server-side agent enforces the expected behaviors on data as it is manipulated by a client-side agent.
While shape trees are intended to adapt to different technology platforms that support the notion of containers and resources, examples in this specification will reflect usage in an [LDP] environment.
2. Shape Tree
A shape tree is a machine-readable template describing the expected layout of a tree of resources in a container-based ecosystem. A shape tree expresses a tree hierarchy by containing other shape trees. The terms used to express a shape tree are described using an [RDF] vocabulary.
A shape tree instance is a resource or set of resources assigned to and in conformance with a given shape tree. A resource in a shape tree instance is called a managed resource.
Every managed resource has an associated shape tree locator. A shape tree locator identifies the shape tree associated with a managed resource, and additional information needed to navigate nested hierarchies of managed resources.
The st:expectsType
property specifies that the
described managed resource be one of these three types:
st:ShapeTreeResource
| Regular RDF resource that is not a container |
st:ShapeTreeContainer
| RDF resource that contains other resources |
st:ShapeTreeNonRDFResource
| Non-RDF resource such as binaries or images |
The st:shape
property specifies that the
described managed resource conforms to the stated [ShEx] or [SHACL] shape.
Shape trees prescribe physical hierarchies and can reference other shape trees to form virtual hierarchies.
In a physical hierarchy, a shape tree expresses a managed resource that explicitly contains another managed resource via st:contains
.
If shape tree S1
st:contains
shape tree S2
, S1
describes a container that contains another managed resource described by S2
. For example, in [LDP], S1
describes
an [LDP] container which ldp:contains
nested
resources described by S2
.
Managed Resource | Associated Shape Tree |
---|---|
/project-1/
| ex:ProjectTree
|
-- /milestone-A/
| ex:MilestoneTree
|
---- /task-43/
| ex:TaskTree
|
---- /task-48/
| ex:TaskTree
|
------ /attachment-aa89
| ex:AttachmentTree
|
---- /task-61/
| ex:TaskTree
|
---- /issue-22/
| ex:IssueTree
|
------ /attachment-cd12
| ex:AttachmentTree
|
------ /attachment-ef55
| ex:AttachmentTree
|
---- /issue-31/
| ex:IssueTree
|
PREFIX st: <http://www.w3.org/ns/st#> PREFIX ex: <http://www.example.com/ns/ex#> <#ProjectTree> a st : ShapeTree ; st : expectsType st : ShapeTreeContainer ; st : shape ex : ProjectShape ; st : contains <#MilestoneTree> , st : AllowNone . <#MilestoneTree> a st : ShapeTree ; st : expectsType st : ShapeTreeContainer ; st : shape ex : MilestoneShape ; st : contains <#TaskTree> , <#IssueTree> ; st : AllowNone . <#TaskTree> a st : ShapeTree ; st : expectsType st : ShapeTreeContainer ; st : shape ex : TaskShape ; st : contains <#AttachmentTree> , st : AllowNone . <#IssueTree> a st : ShapeTree ; st : expectsType st : ShapeTreeContainer ; st : shape ex : IssueShape ; st : contains <#AttachmentTree> , st : AllowNone . <#AttachmentTree> a st : ShapeTree ; st : expectsType st : ShapeNonRDFResource .
In a virtual hierarchy, a shape tree defines one or more shape tree references via st:references
.
A shape tree reference identifies the shape tree to be referenced via st:hasShapeTree
, and the shape path through
which it is linked via st:traverseViaShapePath
.
A shape path is a string that defines a traversal of a shape schema. [SHEXPATH]
Managed Resource | Associated Shape Tree |
---|---|
/project-1
| ex:VirtualProjectTree
|
/milestone-A
| ex:VirtualMilestoneTree
|
/task-43
| ex:VirtualTaskTree
|
/task-48
| ex:VirtualTaskTree
|
/attachment-aa89
| ex:VirtualAttachmentTree
|
/task-61
| ex:VirtualTaskTree
|
/issue-22
| ex:VirtualIssueTree
|
/attachment-cd12
| ex:VirtualAttachmentTree
|
/attachment-ef55
| ex:VirtualAttachmentTree
|
/issue-31
| ex:VirtualIssueTree
|
PREFIX st: <http://www.w3.org/ns/st#> PREFIX ex: <http://www.example.com/ns/ex#> <#VirtualProjectTree> a st : ShapeTree ; st : expectsType st : ShapeTreeResource ; st : shape ex : ProjectShape ; st : references [ st : hasShapeTree <#VirtualMilestoneTree> ; st : traverseViaShapePath "@ex:ProjectShape/ex:hasMilestone" ] . <#VirtualMilestoneTree> a st : ShapeTree ; st : expectsType st : ShapeTreeResource ; st : shape ex : MilestoneShape ; st : references [ st : hasShapeTree <#VirtualTaskTree> ; st : traverseViaShapePath "@ex:MilestoneShape/ex:hasTask" ] , [ st : hasShapeTree <#VirtualIssueTree> ; st : traverseViaShapePath "@ex:IssueShape/ex:hasIssue" ] . <#VirtualTaskTree> a st : ShapeTree ; st : expectsType st : ShapeTreeResource ; st : shape ex : TaskShape ; st : references [ st : hasShapeTree <#VirtualAttachmentTree> ; st : traverseViaShapePath "@ex:AttachmentShape/ex:hasAttachment" ] . <#VirtualIssueTree> a st : ShapeTree ; st : expectsType st : ShapeTreeContainer ; st : shape ex : IssueShape ; st : references [ st : hasShapeTree <#VirtualAttachmentTree> ; st : traverseViaShapePath "@ex:AttachmentShape/ex:hasAttachment" ] . <#VirtualAttachmentTree> a st : ShapeTree ; st : expectsType st : ShapeNonRDFResource .
Let ST
be a shape tree.
Let STI
be a corresponding shape tree instance.
-
An {
ST
st:expectsType
T
} arc identifies the resource typeT
of a corresponding managed resourceR
inSTI
whereT
MUST be one ofst:ShapeTreeResource
,st:ShapeTreeContainer
, orst:ShapeTreeNonRDFResource
. -
An {
ST
rdfs:label
L
} arc indicates that there is exactly one corresponding managed resourceR
inSTI
and it has the nameL
. -
An {
ST
st:shape
SH
} arc indicates that managed resourceR
has exactly one node which conforms to shapeSH
. -
An {
ST
st:contains
ST2
} arc indicates a nested shape treeST2
. -
An {
ST
st:references
STR
} arc indicates that the shape tree identified in shape tree referenceSTR
, is referenced through the instance data ofSTI
.-
An {
STR
st:hasShapeTree
ST3
} arc indicates a shape tree referenced through the instance data ofSTI
-
An {
STR
st:traverseViaShapePath
SHPH
} arc identifies the shape path through which a shape tree instance ofST3
can be found via the instance data ofSTI
-
-
An {
ST
st:supports
ST4
} arc indicates thatST
provides supporting or supplementary context toST4
.
A { ST
st:hasShapeTreeDecoratorIndex
DI
} arc indicates the location of an index of SKOS hierarchies that describes ST
.
2.1. Shape Tree Schema
3. Shape Tree Locator
A shape tree locator associates a managed resource with one or more shape trees. No more than one shape tree locator may be associated with a managed resource.
For example, in [Solid] a shape tree locator would be stored in an auxiliary resource associated with a given managed resource.
A shape tree locator includes one or more shape tree locations via st:location
. Each shape tree location identifies a shape tree associated with the managed resource, the focus node for shape validation, and the information
needed to navigate the physical hierarchy in which that managed resource resides.
If there is more than one shape tree location, they are all applied to the managed resource associated with the shape tree locator.
Shape tree locations identify key contextual points in a physical hierarchy:
-
A shape tree root marks the primary, or parent shape tree in a physical hierarchy, and is set by the Plant Operation.
-
A shape tree instance root marks the primary, or parent shape tree instance in a physical hierarchy, and is set by the Plant Operation.
Property | Description |
---|---|
st:hasShapeTree
| Identifies the shape tree to be associated with the managed resource |
st:node
| Identifies the focus node for shape validation
in the associated managed resource, and is only valid when the
corresponding shape tree includes st:shape
|
st:shape
| Identifies the shape to which st:node must conform
|
st:hasRootShapeTree
| Identifies the shape tree root |
st:hasShapeTreeInstanceRoot
| Identifies the shape tree instance root |
A shape tree root, and its corresponding shape tree instance root can be planted within an existing managed hierarchy, alongside or within other shape tree roots and shape tree instance roots.
Shape tree locations in a given shape tree locator may have different focus nodes.
A shape tree location may be used to provide shape validation only,
in which case only the focus node and shape are provided, via st:node
and st:shape
, respectively.
PREFIX st: <http://www.w3.org/ns/st#> PREFIX ex: <http://www.example.com/ns/ex#> PREFIX project1: <https://storage.example.com/data/projects/project-1#> <#locator> a st : ShapeTreeLocator ; st : location [ st : node project1 : project ; st : shape ex : ProjectShape ; ] .
3.1. Shape Tree Locator Schema
4. Shape Tree Operations
Working with shape trees entails using several higher-level operations —
The key operations used to manage shape trees are:
These operations make use of reusable, internal algorithms defined in Shape Tree Algorithms.
4.1. Discover Shape Tree
Description | |||
---|---|---|---|
The discover shape tree operation entails discovering what, if any,
shape trees are managing a given container.
Inputs
| | ||
URI
| The URI of the resource to discover shape trees for
Outputs
| | |
LOCATORS
| Collection of st:ShapeTreeLocator subjects
|
-
Perform a HEAD on the provided
URI
to discover Shape Tree metadata URINote: This step SHOULD be performed by a client-side agent.
Discovering shape trees only applies to URIs of containers. A status code of 400 MUST be returned if no Link headers with a relation type which maps to the implementation’s notion of a container (e.g.
http://www.w3.org/ns/ldp#Container
in an LDP context) exists.Let
METAURI
be the URI of the shape tree metadata resource pertaining toURI
through the Link header with relationhttp://shapetrees.org/#ShapeTreeLocator
. -
Perform a GET on the discovered Shape Tree metadata resource (
METAURI
)Note: This step SHOULD performed by a client-side agent.
A 404 status code indicates that no shape trees manage this container, and so it MUST be considered an Unmanaged Container.
-
Collect any navigable shape trees
Note: This step SHOULD performed by a client-side agent.
If the
<#loc>
subject has one or morest:location
predicates, this container MUST be considered a Managed Container.Let
MC
be this managed container.The
st:hasShapeTree
of eachst:ShapeTreeLocator
subject specifies what shape tree managesMC
.The IRI of each
st:ShapeTreeLocator
describing a shape tree managingMC
SHOULD be returned.
4.2. Plant Shape Tree
Description | |||
---|---|---|---|
The plant operation marks a container (new or existing) as being
managed by one or more shape trees.
Inputs
| | ||
REQ
|
A POST or PUT HTTP request with the following characteristics:
Outputs
| | |
RESPONSE
| A HTTP response containing a Location header with the URI of the container
that the requested shape trees (LINKST ) are planted in
|
Note: A plant operation MAY be performed by either a client or server-side agent.
-
Let
TC
be the Target Container - The container that will contain instances of the planted shape tree. This container may or may not already exist. -
Let
PC
be the Parent Container - The container that will contain the new or existing target container representing the planted shape tree. WhenREQ
is a POST, this will be the location URL. For PUT, this will be the parent of the PUT container.
-
Preconditions
Note: This step SHOULD be performed by a client-side agent.
-
Ensure the Parent Container (
PC
) exists. If not, this operation MUST return a 404 status code. -
Discover any planted shape tree IRIs managing
PC
.-
Let
PARENTST
be the collection of dereferenced shape tree IRIs discovered forPC
-
-
If the Target Container (
TC
) already exists, discover any previously planted shape tree IRIs.-
Collect any existing shape tree IRIs and combine with the IRIs of the
LINKST
provided via the request Link header to represent the full collection of existing and proposed shape trees forTC
. -
Let
ALLST
be the collection of dereferenced shape tree IRIs representing both existing andLINKST
IRIs
-
-
-
Static Validation of Shape Trees for Conflicts
Note: This step MAY be performed by either a client or server-side agent.
-
Iterate
ALLST
to validate that none of the following conditions are met:-
any shape tree has a
st:expectsResourceType
with a value other thanst:ShapeTreeContainer
-
more than one shape tree has a
st:shape
value -
more than one shape tree has a
st:contains
value
-
If any of the above static validations fail, this operation MUST return a 400 status code.
-
-
Validate graph body
Note: This step MAY be performed by either a client or server-side agent.
Must detail how to differentiate between ShEx and SHACL validation
-
Let
VST
be the validating shape tree that is identified by the only shape tree inALLST
having ast:shape
value -
If
VST
is present and the plant operation (REQ
) includes an RDF graph body and ShEx validation is used and a Focus Node (LINKFN
) is not present, this operation MUST return a 422 status code -
Perform a validation of the RDF graph body of
REQ
using theVST
st:shape
shape, targeting the graph’sLINKFN
. If validation fails, this operation MUST return a 422 status code
-
-
Validate against parent container
Note: This step MAY be performed by either a client or server-side agent..
-
Determine if the Parent Container (
PC
) is a Managed Container by evaluating ifPARENTST
is not empty -
If
PC
is a Managed Container call the validate proposed resource algorithm with parameters:
Parameter Value Notes URI
PC
The parent container that will contain the target container STH
LINKTST
Link header with the relation of "http://shapetrees.org/#TargetShapeTree" RT
st:ShapeTreeContainer
The resource type being created/modified -
-
Create Target Container (
TC
), if necessaryNote: This step MAY be performed by either a client or server-side agent..
-
If
TC
does not exist, create it.
-
-
Update Shape Tree Meta Data for Target Container (
TC
)Note: This step MAY be performed by either a client or server-side agent..
-
Update Target Container
TC
Metadata (METAURI
)-
Iterate the collection of shape trees to be planted (
LINKST
), letLINKSTI
be the current shape tree in context. -
Call algorithm Update Container Metadata with parameters:
Parameter Value Notes TC
TC
The target container to that will contain instance data of the shape tree ROOTST
LINKSTI
The root shape tree at the top of the hierarchy ST
LINKSTI
The shape tree managing the target container ROOTPATH
TC
The target container to that will contain instance data of the shape tree -
-
-
Initialize Static Content
Note: This step MAY be performed by either a client or server-side agent..
-
Let
CST
be the shape tree having ast:contains
value (if one exists) from the list of shape trees that were plantedLINKST
-
Iterate any
st:contains
IRIs withinCST
, lettingCSTI
be the current IRI in context -
Let
CSTIST
be the shape tree resulting in dereferencing IRICSTI
-
If
CSTIST
has ardfs:label
value, letLABEL
be the value of rdfs:label forCSTIST
, and call algorithm Initialize Statics with parameters:
Parameter Value Notes PC
TC
The target container to that will contain instance data of the shape tree SST
CSTIST
The matching contained shape tree RST
CST
The shape tree containing a st:container
RC
TC
The target container to that will contain instance data of the shape tree -
4.3. Create Shape Tree Instance
Description | |||
---|---|---|---|
The create shape tree instance operation creates an instance of a shape
tree within a managed container.
Inputs
| | ||
REQ
|
A POST or PUT HTTP request with the following characteristics:
Outputs
| | |
RESPONSE
| A standard HTTP response |
-
Let
PC
be the Parent Container
-
Preconditions
Note: This step SHOULD be performed by a client-side agent.
-
Ensure the Parent Container (
PC
) exists. If not, return this operation MUST return a 404 status code. -
Discover any planted shape tree IRIs managing
PC
.-
Let
PARENTST
be the collection of dereferenced shape tree IRIs discovered forPC
-
-
-
Validate against parent container
Note: This step MAY be performed by either a client or server-side agent.
-
Determine if the Parent Container (
PC
) is a Managed Container by evaluating ifPARENTST
is not empty -
If
PC
is a Managed Container call the validate proposed resource algorithm with parameters:
Parameter Value Notes URI
PC
The parent container to that will contain the target container STH
LINKTST
The shape tree managing the target container RT
st:ShapeTreeContainer
orst:ShapeTreeResource
orst:ShapeTreeNonRDFResource
The resource type being created -
-
Create Resource
Note: This step MAY be performed by either a client or server-side agent..
-
Initialize Static Content
Note: This step MAY be performed by either a client or server-side agent.
-
Iterate any
st:contains
IRIs withinMCST
, lettingCSTI
be the current IRI in context -
Let
CSTIST
be the shape tree resulting in dereferencing IRICSTI
-
If
CSTIST
has ardfs:label
value, letLABEL
be the value ofrdfs:label
forCSTIST
, and call algorithm Initialize Statics with parameters:
Parameter Value Note PC
TC
The target container that will contain instance data of the shape tree SST
CSTIST
The matching shape tree RST
CST
The parent shape tree managing the parent container RC
TC
The target container that will contain instance data of the shape tree -
4.4. Update Shape Tree Instance
Description | |||
---|---|---|---|
The update shape tree instance operation updates an instance of a shape tree within a managed container.
Inputs
| | ||
REQ
|
A PUT or PATCH HTTP request with the following characteristics:
Outputs
| | |
RESPONSE
| A standard HTTP response |
-
Let
PC
be the Parent Container
-
Preconditions
Note: This step SHOULD be performed by a client-side agent.
-
Ensure the Parent Container (
PC
) exists. If not, this operation MUST return a 404 status code. -
Discover any planted shape tree IRIs managing
PC
.-
Let
PARENTST
be the collection of dereferenced shape tree IRIs discovered forPC
-
-
-
Validate against parent container
Note: This step MAY be performed by either a client or server-side agent.
-
Determine if the Parent Container (
PC
) is a Managed Container by evaluating ifPARENTST
is not empty -
If
PC
is a Managed Container call the validate proposed resource algorithm with parameters:
Parameter Value Notes URI
PC
The parent container that will contain the target container STH
LINKTST
The shape tree managing the target container RT
RT
The resource type being modified -
-
Update Resource
Note: This step MAY be performed by either a client or server side agent.
4.5. Delete Shape Tree Instance
Description | |||
---|---|---|---|
The delete shape tree instance operation deletes an instance of a shape tree within a managed container.
Inputs
| | ||
REQ
| A DELETE HTTP request
Outputs
| | |
RESPONSE
| A standard HTTP response |
-
Delete Resource
Note: This step MAY be performed by either a client or server-side agent.
4.6. Unplant Shape Tree
Description | |||
---|---|---|---|
The unplant shape tree operation unassigns the provided shape tree from the provided container. If there are no remaining shape trees managing the container, it would no longer be considered a managed container.
Inputs
| | ||
REQ
|
A DELETE HTTP request with the following characteristics:
Outputs
| | |
RESPONSE
| A standard HTTP response |
-
Let
PC
be the parent Container of the resource being deleted -
Let
TC
be the Container of the resource being deleted
-
Remove Shape Tree Metadata
Note: This step MAY be performed by either a client or server-side agent.
Call the remove shape tree metadata algorithm with parameters:
Parameter Value Notes URI
TC
The target container that the [shape tree] is being removed from ST
LINKST
The shape tree no longer managing the tc
5. Shape Tree Algorithms
The below algorithms detail key pieces of logic required for shape tree implementations.
5.1. Validate Proposed Resource Against Parent Container
Description | |||
---|---|---|---|
This algorithm is responsible for determining if a proposed resource
(which may more specifically be a container, resource, or non-RDF source) is
valid to be created within a given container.
Note: This algorithm MAY be performed by either a client or server-side agent. Inputs
| | ||
PC
| The URI of the Managed Container that will contain the proposed resource | ||
STH
| The target shape tree hint, from the request’s Link header with the relation of "http://shapetrees.org/#TargetShapeTree" | ||
RT
| The resource type of proposed resource (container, resource, non-RDF source)
Outputs
| | |
MCST
| The URI of the matching contains shape tree |
-
Determine if the Parent Container (
PC
) is a Managed Container by evaluating ifPARENTST
is not empty -
If
PC
is a Managed Container, letMCST
be the matching contained shape tree which is the result of calling the matching contained shape tree algorithm with parameters:Parameter Value Notes URI
PC
The parent container to discover shape trees for STH
STH
The shape tree hint provided as a Link header RT
RT
The resource type being created/modified -
If
RT
does not matchMCST
’sst:expectsType
value, this operation MUST return a 422 status code -
If
MCST
has ast:shape
value, and the plant operation (REQ
) includes an RDF graph body and ShEx validation is used and a Focus Node (LINKFN
) is not present, this operation MUST return a 422 status code -
Perform a validation of the RDF graph body of
REQ
using themcst
st:shape
shape, targeting the graph’sLINKFN
. If validation fails, this operation MUST return a 422 status code
5.2. Find Matching Contained Shape Tree
Description | |||
---|---|---|---|
This algorithm is responsible for determining which shape tree within a set
of shape trees mentioned in st:contains is
applicable for a given proposed resource.
Note: This algorithm MAY be performed by either a client or server-side agent. Inputs
| | ||
URI
| The URI of the Managed Container that will contain the proposed resource | ||
STH
| The target shape tree hint, from the request’s Link header with the relation of "http://shapetrees.org/#TargetShapeTree" | ||
RT
| The resource type of proposed resource (container, resource, non-RDF source)
Outputs
| | |
MCST
| A single shape tree IRI that should be used for validation |
-
Let
MST
be the shape trees managingURI
found by discovering the shape trees -
Let
CST
be the shape tree withinMST
with ast:contains
value(s) -
Let
CCST
be the candidate shape trees for matching - populated by eachst:contains
ofCST
-
If
STH
is specified-
and
STH
does NOT exist withinCCST
this algorithm MUST return a 400 status code -
and
STH
exists withinCCST
returnSTH
-
-
If
CCST
does not contain any ofst:AllowAll
,st:AllowResources
,st:AllowContainers
,st:AllowNonRDFSources
, this algorithm MUST return a status code of 422 -
If
st:AllowNone
exists withinCCST
, this algorithm MUST return a status code 422 -
If
st:AllowAll
exists withinCCST
, return null - indicating that while no match was found,PC
has been configured to allow resources of any type to be created without matching the shape tree -
If
st:AllowResources
exists withinCCST
:-
And the resource type (
RT
) is not a Resource, this algorithm MUST return a status code of 422 -
And the resource type (
RT
) is a Resource, return null - indicating that while no match was found,PC
has been configured to allow Resources to be created without matching the shape tree
-
-
If
st:AllowContainers
exists withinCCST
:-
And the resource type (
RT
) is not a Container, this algorithm MUST return a status code of 422 -
And the resource type (
RT
) is a Container, return null - indicating that while no match was found,PC
has been configured to allow Containers to be created without matching the shape tree
-
-
If
st:AllowNonRDFSources
exists withinCCST
:-
And the resource type (
RT
) is not a Non-RDF Source, this algorithm MUST return a status code of 422 -
And the resource type (
RT
) is a Non-RDF Source, return null - indicating that while no match was found,PC
has been configured to allow non-RDF Sources to be created without matching the shape tree
-
5.3. Initialize Static Content
Description | |||
---|---|---|---|
This algorithm is responsible for initializing static content that is implied
through the creation of its parent. When called, it recursively seeks out
resources to be statically created.
Note: This algorithm MAY be performed by either a client or server-side agent. Inputs
| | ||
PC
| The parent container that any statics would be created within | ||
SST
| The static shape tree to be initialized where an rdfs:label is set
| ||
RST
| The root shape tree that was planted at the top of this shape tree hierarchy | ||
RC
| The root container at the top of this shape tree hierarchy
Outputs
| | |
NONE |
-
Let
LABEL
be therdfs:label
value of the provided "static" shape tree (SST
) -
Create the expected resource using a PUT in order to have control of resource naming, letting
CR
be the resulting resource that was created-
Set the appropriate Link header with "type" relation based on the
st:expectsType
value ofSST
-
-
If the
st:expectsType
value ofSST
isst:ShapeTreeContainer
:-
Call algorithm Update Container Metadata with parameters:
Parameter Value Notes TC
CR
Created static resource ROOTST
RST
The root shape tree of the hierarchy ST
SST
The shape tree to assign to cr
ROOTPATH
RC
The root container at the top of this shape tree hierarchy -
If
SST
has any values forst:contains
:-
Iterate any
st:contains
IRIs withinSST
, lettingCSSTI
be the current IRI in context -
Let
CSSTIT
be the shape tree resulting in dereferencing IRICSSTI
-
If
CSSTIT
has ardfs:label
value then recursively call algorithm Initialize Statics with parameters:Parameter Value Notes PC
CR
Created static resource, now the parent SST
CSSTIT
A shape tree to be recursively planted RST
RST
The root shape tree of the hierarchy RC
RC
The root container at the top of this shape tree hierarchy
-
-
5.4. Update Container Metadata
Description | |||
---|---|---|---|
This algorithm is responsible for updating the shape tree metadata for a
container to reflect what shapetree(s) manage that container
and the container’s location relative to the broader hierarchy of shape trees.
Note: This algorithm MAY be performed by either a client or server-side agent. Inputs
| | ||
TC
| The URI of the Container to update metadata for | ||
ROOTST
| The root shape tree within a hierarchy of shape tree containers | ||
ST
| A shape tree that will manage TC
| ||
ROOTPATH
| Tthe URI of the root of this shape tree hierarchy, where ROOTST is planted
Outputs
| | |
NONE |
-
Perform a HEAD on Target Container
TC
Let
METAURI
be the URI of the shape tree metadata resource pertaining toTC
. -
Perform a GET on the Target Container’s Shape Tree metadata (
METAURI
)If a 404 is returned that indicates that no shape trees manage this container. Let
EG
be the existing metadata graph resulting from dereferencing and parsingMETAURI
. -
Populate the metadata graph with triples
Using
EG
, if it exists, otherwise a new graph, the following triples should be added:Subject Predicate Object Description <#generated UUID> rdf:type st:ShapeTreeLocator
Indicates the RDF class of the subject <#generated UUID> st:hasRootShapeTree
ROOTST Describes the shape tree planted at the root of this shape tree hierarchy <#generated UUID> st:hasShapeTree
ST Describes the shape tree planted at this container <#generated UUID> st:hasShapeTreeInstanceRoot
ROOTPATH Describes the URI to the root container of this shape tree hierarchy referenced st:ShapeTreeLocator
(e.g. <#loc>)st:location
<#generated UUID> Identifies the st:node
andst:shape
for validation as well as the corresponding node in the ShapeTree (st:hasShapeTree
), ShapeTree root in the resource hierarchy (st:hasShapeTreeInstanceRoot
) and root node in the ShapeTree (st:hasRootShapeTree
). -
Persist the above triples to
METAURI
.
5.5. Remove Shape Tree From Container Metadata
Description | |||
---|---|---|---|
This algorithm is responsible for updating the shape tree metadata for a
container to remove a shape tree from managing a container.
Note: This algorithm MAY be performed by either a client or server-side agent. Inputs
| | ||
TC
| The URI of the Container to update metadata for | ||
ST
| A shape tree that will no longer manage TC
Outputs
| | |
NONE |
-
Perform a HEAD on Target Container
TC
Let
METAURI
be the URI of the shape tree metadata resource pertaining toTC
. -
Perform a GET on the Target Container’s Shape Tree metadata (
METAURI
)If a 404 is returned that indicates that no shape trees manage this container. Let
EG
be the existing metadata graph resulting from dereferencing and parsingMETAURI
. -
Remove pertinent shape tree triples
Let
S
be the subject of typeShapeTreeLocator
with ast:hasShapeTree
matchingST
.Remove the subject
S
along with thest:hasShapeTreeLocator
referencingS
from the metadata graph. -
Persist the updated graph to
METAURI
.
6. Describing Shape Trees
While the RDF structure of shape trees enable machine readability, additional context is needed to make it human-friendly.
External SKOS graphs can be OPTIONALLY linked to describe the shape tree in human-readable terms.
-
Let
STR
be an RDF document containing one or more shape treesSTs
. -
The { <>
st:hasShapeTreeDecoratorIndex
IDX
} arc indicates that there is exactly onest:ShapeTreeDecoratorIndex
located atIDX
. -
The {
IDX
a
st:ShapeTreeDecoratorIndex
} arc indicates ast:ShapeTreeDecoratorIndex
that represents an index ofst:ShapeTreeDecoratorSet
. -
The {
IDX
st:hasSet
SET
} arc indicates linkage to one or morest:ShapeTreeDecoratorSet
. -
The {
SET
a
st:ShapeTreeDecoratorSet
} arc indicates ast:ShapeTreeDecoratorSet
that represents a SKOS graphs for a given language or interpretation. -
The {
SET
st:hasShapeTreeDecoratorResource
DECRESOURCE
} arc indicates linkage to a singlest:ShapeTreeDecoratorResource
. -
The {
SET
st:usesLanguage
LANG
} arc indicates the language used by the associatedDECRESOURCE
.
SKOS constructs such as skos:narrower
MAY be used to group or organize related shape trees.
7. Definitions
The following terms are used throughout this specification:-
Arc -- the directed relationship between two nodes in an RDF graph
-
Client-side Agent -- A software component interacting with a server. in the context of shape trees, a client-side agent may be responsible for data validation.
-
Container -- the generalized notion of a collection of resources; implementations of shape trees MAY use a container implementation such as [LDP] (ldp:Container, ldp:BasicContainer, etc.)
-
Ecosystem -- a software environment with resources organized in some hierarchical grouping that rely on shape tree concepts to better organize and validate structures of data
-
Focus Node -- the IRI to an RDF subject which is used to specify which subject within a document should be processed first. In the context of shape trees one usage is directing shape validation to the appropriate node in the graph.
-
Managed Container -- any container that has a shape tree planted in it. A Managed Container MAY be an Instance Root or hierarchically nested within the resource hierarchy.
-
Non-RDF Source -- the generalized notion of document not containing linked-data triples; this may include plain text or binary data.
-
RDF -- Resource Description Framework [rdf11-primer]
-
Resource -- the generalized notion of document containing linked-data; implementations of shape trees may use a resource implementation such as [LDP] (ldp:Resource, etc.)
-
Server-side Agent -- A server-side software component. Server-side agents that support shape trees are responsible for data validation.
-
Shape -- a schema definition allowing validation of an RDF subject. Example specifications supporting the notion of shapes include [ShEx] and [SHACL].
-
SKOS Graph -- an RDF graph conforming to [skos-reference] data model. For purposes of shape trees a SKOS Graph is used to describe a shape tree in human-readable terms.
-
Unmanaged Container -- any Container which is not described by a shape tree