Skip to main content

No project description provided

Project description

RDFrame | SHACL profiles | CQL profiles

About

This library serves two purposes.

  1. Development of X -> SPARQL mappings, currently in two flavours
    1. SHACL interpreted for display, + endpoint definitions as RDF -> SPARQL
    2. CQL to SPARQL i.e. a developer would write Python to implement mappings a particular way and can have a tight REPL process including visualising examples.
  2. End user generation/specification of profiles which use the above. i.e. a user would only use the web interface to specify profiles or specific CQL queries to achieve a desired outcome.

RDFrame GUI components

Prez SHACL version

  1. Runtime values - Data specified at runtime when using for example the URI of an object to retrieve information about; the URI of a container object from which member items are listed; limit and offset values for use in pagination.

  2. Endpoint Definition. This specifies the class(es) of object(s) to be returned from an endpoint, along with information about ordering, and pagination.

    1. Where a sh:target / sh:select is used, variables can be defined in the sh:select using a $. These values will be populated at runtime with, in priority order:
      1. Runtime values
      2. Default values specified with the endpoint definition. At present custom properties have been used to define default limit and offset values. This
  3. Profile Definition. Used to specifiy which properties of focus objects should be returned.

  4. SPARQL query. This is generated from the above three inputs.

  5. Example data. This is any RDF data which can be used to test or demonstrate use of the profile/endpoint definition.

  6. Results. The result of applying the generated SPARQL query against the Example data.

CQL version

Description forthcoming - available at /cql

Patterns to address common use cases

The current set of SHACL profiles are tailored towards a set of known use cases for Prez.

1.1 List objects based on their relationship to a container object.

Endpoint definition requirements:

  1. The container object's URI, either specified as a runtime value.
  2. sh:target / sh:select statement
  3. sh:targetClass

The sh:targetClass is required due to a limitation with using sh:select as a string. The sh:targetClass is required in order to generate the Construct part of the generated SPARQL query. The sh:select subquery is only validated and inserted - there is no programmatic extraction of components.

Properties of the focus objects to include/exclude are specified in a profile (see 3.1 -> 3.3).

1.1.1 Add triples to the CONSTRUCT part of the query from the FOCUS NODE selection

Optionally, triples can be added to the CONSTRUCT part of the query from the FOCUS NODE selection. Triples to add can be defined via sh:rule / with sh:subject sh:predicate sh:object. If a Literal is used as the range for any of these (sh:subject sh:predicate sh:object), and the Literal starts with a '?', it will be translated into a variable in the generated SPARQL query. Note: by default only the CLASS of an object is included from the focus node selection. This is the only provided mechanism to provide additional triples from the SELECT subquery which is used for focus node selection. Properties for inclusion can be specified in the profile (via SHACL property shapes).

1.2 List objects based on their class.

Endpoint definition requirements:

  1. sh:targetClass - the class of object to be listed.

Properties of the focus objects to include/exclude are specified in a profile (see 3.1 -> 3.3).

2.1 Describe an object given its URI

Endpoint definition requirements:

  1. A runtime value for the object for example: {"object": "http://my-object-uri"}
  2. sh:targetNode "$object" within the endpoint definition.

Properties of the focus objects to include/exclude are specified in a profile (see 3.1 -> 3.3).

3.1 Include all properties of a focus node

Includes all direct properties of a given focus node i.e. as a triple pattern <focus_uri> ?p ?o

There does not appear to be a relevant concept to borrow from SHACL that provides a mechanism to specify the retrieval of all predicate values from a given focus node. As this is a common use case when displaying data, for conciseness an extension property has been created:

http://example.com/shacl-extension#allPredicateValues

This property is used in place of specified path values under sh:path, for example:

ex:OpenNodeShape
    a              sh:NodeShape ;
    sh:property [
        sh:path shext:allPredicateValues ;
    ] ;

3.2 Include specified properties of a focus node

Specifying properties to include implies all properties NOT specifically included are to be excluded.

Specified property paths can be included using SHACL Propety Paths

These can either be specified directly using sh:path on a property shape, or multiple property paths can be specified using sh:union.

3.2.1 Include specified properties simple - single property path

Profile requirement:

  1. sh:path <property path expression>

3.2.2 Include specified properties complex - multiple property paths

Profile requirement:

  1. sh:path ( sh:union ( <property path expression 1> <property path expression 2> ...) )
    

3.3 Exclude specified properties of a focus node

Specifying properties to exclude implies all direct properties NOT excluded are to be included.

Profile requirement:

  1. Property shapes includes a sh:maxCount of 0

NB: the current assumption is that a user can either include specified

Use of patterns in Prez endpoints

3.4 Include blank node property chains

Although the SHACL vocabulary provides for ways to identify blank nodes, it does not appear there is a concise way to specify that property chains including blank nodes should be included in the description of a focus node. For this reason a custom property has been created. This property can be included on the nodeshape in a profile. The property is http://example.com/shacl-extension#bnode-depth. The range of the property is the number of blank node (object/subject pairs) to follow. It is used as follows:

ex:OpenNodeShape
    a sh:NodeShape ;
    shext:bnode-depth 2 ;
.

4.1 Include specific object values

Profile requirement:

  1. Specify object values using sh:hasValue for a single value or sh:in with an RDF list for multiple values.

Use of patterns in Prez endpoints

The following table shows where different patterns are used in the proposed Prez endpoint definitions.

Endpoint Endpoint Definition Pattern Profile Definition Patterns
Catprez Catalog Listing 1.2 List objects based on their class.
Catprez Catalog Object 2.1 Describe an object given its URI 3.1 Include all properties of a focus node
3.4 Include blank node property chains
Catprez Resource Listing 1.1 List objects based on their relationship to a container object. 3.2.2 Include specified properties complex - multiple property paths
Catprez Resource Object 2.1 Describe an object given its URI 3.1 Include all properties of a focus node
3.4 Include blank node property chains
Vocprez Vocabulary Listing 1.2 List objects based on their class.
Vocprez Vocabulary Object 2.1 Describe an object given its URI 3.1 Include all properties of a focus node
3.4 Include blank node property chains
Vocprez Vocabulary Object Children Page 1/2 1.1 List objects based on their relationship to a container object. 3.1 Include all properties of a focus node
Vocprez Vocabulary Concept Object 2.1 Describe an object given its URI 3.1 Include all properties of a focus node
3.4 Include blank node property chains
3.2.2 Include specified properties complex - multiple property paths
Vocprez Collection Listing 1.2 List objects based on their class.
Vocprez Collection Object 2.1 Describe an object given its URI 3.1 Include all properties of a focus node
3.4 Include blank node property chains
Vocprez Collection Concept Object 2.1 Describe an object given its URI 3.1 Include all properties of a focus node
3.4 Include blank node property chains
Spaceprez Dataset Listing 1.2 List objects based on their class.
Spaceprez Dataset Object 2.1 Describe an object given its URI 3.1 Include all properties of a focus node
3.4 Include blank node property chains
Spaceprez Feature Collection Listing 1.1 List objects based on their relationship to a container object.
Spaceprez Feature Collection Object 2.1 Describe an object given its URI 3.3 Exclude specified properties of a focus node
3.4 Include blank node property chains
Spaceprez Feature Listing 1.1 List objects based on their relationship to a container object.
Spaceprez Feature Object 2.1 Describe an object given its URI 3.1 Include all properties of a focus node
3.4 Include blank node property chains

Appendix - why use sh:union and property shapes?

Direct and Precise: sh:union and property paths allow direct referencing of specific properties, offering clear and granular control over displayed properties. They support SPARQL property path syntax for complex property relationships, and using sh:union, they can be specified together in a single RDF List.

  • sh:inversePath
  • sh:alternativePath
  • sh:path As these property paths are used in the profile, they are about the selection of properties after a set of focus nodes has been selected, as such the most common use cases are where a union of properties is required, rather than a logical and. sh:union can be mapped directly to SPARQL union, giving a clear and direct mapping from the profile to the SPARQL query.

As these are specified off of a property node, sh:minCount and sh:maxCount are also available, and can be used to indicate optional properties (sh:minCount 0) or to indicate that a property should be excluded (sh:maxCount 0).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdframe-0.1.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

rdframe-0.1.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file rdframe-0.1.0.tar.gz.

File metadata

  • Download URL: rdframe-0.1.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.6 Linux/6.2.0-37-generic

File hashes

Hashes for rdframe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3ddf94be9b8469e8176532de1089ae13a0cf286944eff00ec263c367380e0f19
MD5 c6522004e5af8529209c476f2b13167c
BLAKE2b-256 25fb6a9d701e85be5a96fd11cae61023a81509f7cb02d2320cefc397ba9325d9

See more details on using hashes here.

Provenance

File details

Details for the file rdframe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rdframe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.6 Linux/6.2.0-37-generic

File hashes

Hashes for rdframe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f6618375d06f223c8a6224b0e2f35308cc01b39cdad9739fee77f03d1be600d
MD5 843065c197c0d6cc07e2f94c6d8ac585
BLAKE2b-256 4a1be17a9e1907e30592b6258eaa6990149fb3783e9098ec54fb34607327e53f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page