Shape Expressions (ShEx) is a
data model
A data model is an abstract model that organizes elements of data and standardizes how they relate to one another and to the properties of real-world entities. For instance, a data model may specify that the data element representing a car be c ...
ling language for validating and describing a
Resource Description Framework The Resource Description Framework (RDF) is a World Wide Web Consortium (W3C) standard originally designed as a data model for metadata. It has come to be used as a general method for description and exchange of graph data. RDF provides a variety of ...
(RDF).
It was proposed at the 2012 RDF Validation Workshop
as a high-level, concise language for RDF validation.
The shapes can be defined in a human-friendly compact syntax called ShExC or using any RDF
serialization formats like
JSON-LD or
Turtle
Turtles are an order of reptiles known as Testudines, characterized by a special shell developed mainly from their ribs. Modern turtles are divided into two major groups, the Pleurodira (side necked turtles) and Cryptodira (hidden necked ...
.
ShEx expressions can be used both to describe RDF and to automatically check the conformance of RDF data.
The syntax of ShEx is similar to
Turtle
Turtles are an order of reptiles known as Testudines, characterized by a special shell developed mainly from their ribs. Modern turtles are divided into two major groups, the Pleurodira (side necked turtles) and Cryptodira (hidden necked ...
and
SPARQL
SPARQL (pronounced " sparkle" , a recursive acronym for SPARQL Protocol and RDF Query Language) is an RDF query language—that is, a semantic query language for databases—able to retrieve and manipulate data stored in Resource Description ...
while the semantics is inspired by regular expression languages like
RelaxNG.
Example
PREFIX :
PREFIX schema:
PREFIX xsd:
:Person
The previous example declares that nodes conforming to shape
Person
must have one property
schema:name
with a string value and zero or more properties
schema:knows
whose values must conform with shape
Person
.
Implementations
shex.js JavaScript
shaclex Scala library with support for
Jena (framework)
Apache Jena is an open source Semantic Web framework for Java. It provides an API to extract data from and write to RDF graphs. The graphs are represented as an abstract "model". A model can be sourced with data from files, databases, URLs or ...
and
RDF4J
Eclipse RDF4J (formerly OpenRDF Sesame) is an open-source framework for storing, querying, and analysing RDF data. It was created by the Dutch software company Aduna as part of "On-To-Knowledge", a semantic web project that ran from 1999 to 200 ...
PyShEx Python
shexjava Java
Ruby ShEx Ruby
ShEx.ex Elixir
Online playgrounds and demos
Online demo based o
shex.jsrdfshape online demo based o
shaclex
References
Further reading
; Specification
*
*
See also
*
SHACL
Shapes Constraint Language (SHACL) is a World Wide Web Consortium (W3C) standard language for describing Resource Description Framework (RDF) graphs. SHACL has been designed to enhance the semantic and technical interoperability layers of ontolog ...
*
Wikidata
Wikidata is a collaboratively edited multilingual knowledge graph hosted by the Wikimedia Foundation. It is a common source of open data that Wikimedia projects such as Wikipedia, and anyone else, can use under the CC0 public domain licen ...
*
XML schema
An XML schema is a description of a type of Extensible Markup Language, XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed ...
s
{{Semantic Web
Resource Description Framework
Data modeling languages
Declarative programming languages
RDF data access
Semantic Web
World Wide Web Consortium standards
SPARQL