status | author | version |
---|---|---|
experimental |
joseph gardner |
draft-2 |
This RFC defines Tripl, a Domain-Specific Language (DSL) for expressing RDF triples with a simplified syntax for ontology mapping. The language prioritizes human-readable syntax, short URIs, and automatic resolution of predicates via a well-known path for mappings. Tripl is designed to work with RDF-based data and provides a mechanism for linking short names to full URIs through a centralized mapping system. This approach improves flexibility by allowing custom property mappings to be stored in external files.
- 1. Introduction
- 2. Syntax Overview
- 3. Mapping Mechanism
- 4. Example Usage
- 5. Error Handling and Validation
- 6. Security Considerations
- 7. IANA Considerations
- 8. References
This document specifies Tripl, a DSL for expressing RDF triples with an emphasis on simplicity and readability. In RDF, data is represented as triples consisting of a subject, predicate, and object, which together define relationships between resources. Tripl aims to make defining these triples easier, without the need to focus on full URI paths. The language allows short names for predicates to be mapped to their full URIs, keeping it concise and accessible while ensuring flexibility and extensibility. This approach makes working with RDF data more intuitive and user-friendly.
Tripl is ideal for use cases such as knowledge representation and linked data where a human-readable abstraction of RDF data is desirable.
The @base
directive is used to specify the base URI for the document. All identifiers MUST be resolved relative to this base URI unless explicitly overridden by a full URI.
Example:
@base http://example.com/
This implies that any identifier like book123
would be resolved as http://example.com/book123
.
Mappings link short names (e.g., title
, creator
) to full URIs, allowing human-readable predicates in RDF triples. They are retrieved from a .well-known
path relative to the base URI:
<base URI>/.well-known/tripl.json
Triples in Tripl are expressed in the form:
subject predicate object
- Subject and object MUST be either URIs or literals (enclosed in quotes).
- Predicate SHOULD be a short name that will be resolved based on the mappings defined in the
propertyMapping
file.
Example Triple:
book123 title "The Great Gatsby"
Here, book123
will resolve to http://example.com/book123
, and title
will be resolved using the mappings in the mapping.json
file.
Literals are enclosed in double quotes and represent data values. These are distinct from URIs.
Example:
book123 date "1925-04-10"
Here, "1925-04-10"
is a literal value.
The system MUST look for a configuration file at the .well-known
path relative to the @base
URI. The configuration file MUST be named tripl.json
.
The tripl.json
file MUST contain a propertyMapping
property, which points to an external file where predicate mappings are defined. This file SHOULD be a JSON file.
Example configuration:
{
"propertyMapping": "http://example.com/.well-known/mapping.json"
}
The tripl.json
configuration file is the primary entry point for the system. It contains directives such as propertyMapping
, which refers to the location of the predicate mappings.
- The
propertyMapping
key MUST contain a URI that points to the location of the external mapping file.
The external mapping file referred to by propertyMapping
SHOULD be a JSON file containing a list of key-value pairs, where the key is the short name of the predicate and the value is the full URI.
Example mapping.json
:
{
"title": "http://purl.org/dc/elements/1.1/title",
"creator": "http://purl.org/dc/elements/1.1/creator",
"name": "http://purl.org/dc/elements/1.1/name",
"date": "http://purl.org/dc/elements/1.1/date",
"identifier": "http://purl.org/dc/elements/1.1/identifier"
}
The mapping file is OPTIONAL, but if it exists, the system MUST automatically apply these mappings during processing.
@base http://example.com/
# The system will automatically load mappings from .well-known/tripl.json
book123 title "The Great Gatsby"
book123 creator author1
book123 date "1925-04-10"
book123 identifier "9780743273565"
book124 title "To Kill a Mockingbird"
book124 creator author2
book124 date "1960-07-11"
book124 identifier "9780061120084"
author1 name "F. Scott Fitzgerald"
author2 name "Harper Lee"
{
"propertyMapping": "http://example.com/mapping.json"
}
{
"title": "http://purl.org/dc/elements/1.1/title",
"creator": "http://purl.org/dc/elements/1.1/creator",
"name": "http://purl.org/dc/elements/1.1/name",
"date": "http://purl.org/dc/elements/1.1/date",
"identifier": "http://purl.org/dc/elements/1.1/identifier"
}
In this example, the tripl.json
configuration points to the external mapping.json
file, which contains the mappings for predicates. The triples will resolve the short names (e.g., title
, creator
, name
) to the corresponding full URIs.
The system MUST handle errors gracefully:
- If the
@base
URI is not specified, an error MUST be raised. - If the
tripl.json
configuration file is missing or malformed, the system SHOULD issue a warning and fall back to default configurations or throw an error depending on the configuration. - If the
propertyMapping
URI points to a non-existent or malformed file, the system SHOULD raise an error indicating the problem.
- Data Integrity: The
tripl.json
andmapping.json
files SHOULD be served from trusted sources (e.g., HTTPS) to ensure the integrity of the mappings. - URI Validation: Full URIs MUST be validated to ensure they conform to proper URI structure to prevent injection attacks.
This RFC does not require any IANA (Internet Assigned Numbers Authority) actions. The .well-known
path is already a recognized convention for various metadata files on the web.
- RDF 1.1 Concepts and Abstract Syntax – W3C Recommendation
- RDF Vocabulary Description Language (RDF Schema) – W3C Recommendation
- Uniform Resource Identifier (URI): Generic Syntax – RFC 3986
- The document is processed starting with the
@base
URI. - The system checks for the existence of the
.well-known/tripl.json
configuration file. - The system loads the
propertyMapping
URI from thetripl.json
file and retrieves the predicate mappings.