This document describes WShEx (Wikibase Shape Expressions), a language inspired by ShEx to describe and validate Wikibase entities.
WShEx is based on Shape Expressions ([[SHEX]]) and uses a similar syntax. The main difference is that while ShEx describes and validates RDF, WShEx describes and validates Wikibase entities.
Wikibase is the software toolkit on which Wikidata has been implemented. Although the Wikibase data model offers an RDF serialization, it contains several built-in features like labels, descriptions, aliases, qualifiers, references or ranks which are not directly supported by RDF.
WShEx supports those Wikibase features as part of the language, which makes it more concise and usable to describe Wikibase entities.
[[[#WShExRole]]] presents the role of WShEx sa a language that describes Wikibase entities directly, which is different to Entity Schemas in ShEx, which describes the RDF serializatoin of Wikibase entities. Both languages are complementary and it is possible to convert one to the other.
In this document we will employ the following aliases for namespaces
wd | http://www.wikidata.org/entity/ |
wdt | http://www.wikidata.org/prop/direct/ |
p | http://www.wikidata.org/prop/ |
ps | http://www.wikidata.org/prop/statement/ |
pq | http://www.wikidata.org/prop/qualifier/ |
xsd | http://www.w3.org/2001/XMLSchema# |
The following example declares a <Researcher> shape with several triple constraints.
We include both the WShEx schema (first column) and the equivalent ShEx schema (also called Entity Schema by the Wikibase community)
This section contains a primer about the WShEx language using several examples.
All the examples are represented using the WShEx compact syntax and the equivalent Entity Schema representation using ShEx compact syntax
A triple constraint contains a declaration about a wikibase statement. It has a predicate, a value expression and a cardinality.
<http://www.wikidata.org/entity/P[number]>
?
: zero or one (optional cardinality)
+
: one or more
*
: zero or more
{min,max}
: between min and max values