ShEx

Shapes Language Expressivity Questionnaire

This is a questionnaire to guide development of the ShEx (Shape Expressions) language. Your responses will be given as input to the RDF Data Shapes WG as requirements for SHACL (though this questionnaire is not a product of Working Group). You will primarily be asked to rate the importance of language features to your own work as well as estimate how important they are to other potential users (i.e. the utility of the language to a broader audience).

See a rough tally of the results to date.

If you cannot use this on-line questionnaire, you may send your answers by email to public-rdf-shapes@w3.org.

Identification

Identification

What is your email address? (required)
Enter a secret to store and revisit your stored results:
Your input (apart from email and secret) will be publicly associated with your name unless you check this: .

This questionnaire will likely change in response to input. You can revisit your submission with your email address and secret to update your answers or respond to changes in the questionnaire. Please leave this checked if you want to be notified about substantial changes to this questionnaire:

What is your name?
What organization do you work for?
How do you expect to use an RDF validation language?

Introduction

ShEx enables description and validation of RDF data through declarations of expected properties, their cardinalities, and the type and structure of their objects (and, less frequenly, subjects). ShEx is analogous to W3C XML Schema and RelaxNG for XML, JSON-schema for JSON, and DDL for SQL.

As an example, imagine an issue tracking interface where an Issue is submitted by some person and potentially assigned to the same person or someone else. These issues can have a status of unassigned or assigned.

inst:Issue1 inst:User2 inst:User4 ex:state ex:assigned ex:reportedBy ex:assignedTo mailto:bob@... foaf:name Bob Smith foaf:mbox mailto:joe@... foaf:name Joe Smith foaf:mbox

To capture this in ShEx, we create "shapes" to describe the different nodes in the graph: (Mousing over the the following list items items will highlight the corresponding elements in the example text.)

  • exactly one ex:state with a value of ex:unassigned or ex:assigned,
  • exactly one ex:reportedBy which references a user.
  • an optional (indicated by a ?) ex:assignedTo which references a user.

The user referenced by the ex:assignedTo property must have:

  • exactly one foaf:name with a value of an RDF Literal with a datatype of xsd:string,
  • one or more (indicated by a +) foaf:mboxes with a value of an RDF IRI (as opposed to a blank node or literal).
schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = iface:IssueShape

iface:IssueShape {
    ex:state (ex:unassigned ex:assigned),
    ex:reportedBy @iface:PersonShape,
    ex:assignedTo @iface:PersonShape?
}

iface:PersonShape {
    foaf:name xsd:string,
    foaf:mbox IRI+
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

inst:Issue1 a ex:Issue ;
    ex:state        ex:assigned ;
    ex:reportedBy   inst:User2 ;
    ex:assignedTo   inst:User2 .

inst:User2 a foaf:Person ;
    foaf:name       "Bob Smith" ;
    foaf:mbox       <mailto:bob@example.org> ;
    foaf:mbox       <mailto:rs@example.org> .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

inst:Issue3 a ex:Issue ;
    ex:state        ex:unsinged ;
    ex:assignedTo   inst:User4 .

inst:User4 a foaf:Person ;
    foaf:name       "Joe Smith", "Joseph Smith" ;
    foaf:mbox       <mailto:joe@example.org> .

Note that ShEx has the same tokens (syntactic representations of IRIs, PNames, BNodes, Literals) as Turtle and SPARQL.

The process of validating an RDF graph against a schema involves matching a focus node, a node in an RDF graph, against a shape in the schema.

The process of validating an RDF graph against a schema can be thought of matching a node in an RDF graph against a shape in the schema. So far, we've introduced (hover over items to see examples):

  • cardinality (how many arcs with a given predicate are expected): optional, one or more
  • shape references
  • enumerations of permissible values
  • literal datatype (note that "Bob Smith" is a literal with a datatype xsd:string)
  • RDF node type (e.g. IRI, previously known as URI reference)

Let's see how much more language you want or need:

Or

Suppose a person must either have a foaf:name or one or more given names and a family name (and a foaf:mbox, included here to show the syntax):

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start=iface:PersonShape

iface:PersonShape {
    ( foaf:name xsd:string
      | foaf:givenName xsd:string+,
        foaf:familyName xsd:string),
    foaf:mbox IRI+
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

inst:User5 a foaf:Person ;
    foaf:name       "Bob Smith" ;
    foaf:mbox       <mailto:rs@example.org>  .
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

inst:User6 a foaf:Person ;
    foaf:givenName       "Bob", "Robert" ;
    foaf:familyName       "Smith" ;
    foaf:mbox       <mailto:rs@example.org>  .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

inst:User7 a foaf:Person ;
    foaf:givenName       "Joe Smith", "Joseph Smith" ;
    foaf:mbox       <mailto:joe@example.org> .

When saying "or", we need to specify whether we permit more than one alternative to match.

  • logical or - Languages based on boolean logic (e.g. OWL or prolog/datalot) typically permit more than one alternative to match. It may be difficult to define coverage if more than one alternative matches the instance data.
  • exclusive or - Grammar languages like BNF, yacc and regular expressions permit only one alternative to match. Note that this can only have more than two alternatives, only one of which may match. (Some schema languages call this choice (in XML Schema or RelaxNG) or oneOf.)

In the example schema above, this would mean that combining individually valid subgraphs, one with a name and one with a given and family name, would result in an invalid graph:

failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

inst:User8 a foaf:Person ;
    foaf:name       "Joe Smith" ;
    foaf:givenName  "Joe" ;
    foaf:familyName "Smith" ;
    foaf:mbox       <mailto:joe@example.org> .

One can simulate logical or with exclusive or (extra parentheses added for clarity):

schema
iface:PersonShape {
    ( (foaf:name xsd:string,
       foaf:givenName xsd:string*,
       foaf:familyName xsd:string?),
     |(foaf:givenName xsd:string+,
       foaf:familyName xsd:string)),
    foaf:mbox IRI+
}

One can simulate exclusive or with logical or and negation, indicated here with !.

schema
iface:PersonShape {
    (  (foaf:name xsd:string,
        !foaf:givenName xsd:string,
        !foaf:familyName xsd:string)),
      |(!foaf:name xsd:string,
        foaf:givenName xsd:string+,
        foaf:familyName xsd:string)),
    foaf:mbox IRI+
}

Associativity

We also need to decide "is OR associative, is (A | B) | C the same as A | (B | C) and A | B | C?" Recalling that if OR is exclusive, only one choice is permitted to match, a non-associative OR in this example would fail the inner OR (both sides match) and then pass the outer because its right-most choice matches. A more complex semantics captures the fact that too many alternatives matched in a subordinate OR and no OR above that may pass:

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>

start = iface:PersonShape

iface:PersonShape {
    foaf:name xsd:string,
  | foaf:givenName xsd:string,
    foaf:familyName xsd:string,
  | vcard:fn xsd:string
}
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>

inst:User8 a foaf:Person ;
    foaf:name       "Joe Smith" ;
    foaf:givenName  "Joe" ;
    foaf:familyName "Smith" ;
    vcard:fn        "Joe Smith" .
importance to me importance to others intuitiveness comments/use cases
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
Negation

Shapes or alternatives may be discriminated by the triples that are NOT permitted, as we saw in the previous example. In another use case, a service may permit arbitrary triples except those that it uses for provenance, e.g. dc:creator:

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>

start=iface:IssueShape

iface:IssueShape {
    ex:state (ex:unassigned ex:assigned),
   !dc:creator . # '.' means "any term"
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>

inst:Issue1 a ex:Issue ;
    ex:state     ex:assigned .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>

inst:Issue3 a ex:Issue ;
    ex:state     ex:unassigned ;
    dc:creator   "bjohnson77" .

Note that negation could be handled by having an upper cardinality of 0. Semantics for negation are trivial if the constraint on the value is not itself a shape, e.g. "!dc:creator ." above. The complexities of negation with recursion are described below in the geeky details for recursion.

importance to me importance to others intuitiveness comments/use cases
highlow highlow highlow
highlow highlow highlow
Reverse property restrictions

So far, shapes have constrained only those arcs which have the focus node as the subject, so-called "arcs out". If we reverse the arcs (indicated by the ^) connecting issues to users (and changing assignments to resolutions) we can say that a resolved issue must be ex:reported by someone and ex:resolved by someone. Note that reverse arc restrictions frequently correlate to regular arc restrictions on another shape.

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = iface:IssueShape

iface:IssueShape {
    ex:state (ex:resolved),
   ^ex:reported @iface:UserShape,
   ^ex:resolved @iface:UserShape
}
iface:UserShape {
    foaf:name xsd:string,
    ex:reported @iface:IssueShape*,
    ex:resolved @iface:IssueShape*
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Issue1 ex:state ex:resolved .

inst:User1
    foaf:name "Bob Smith" ;
    ex:reported inst:Issue1 .

inst:User2
    foaf:name "Alice Allison" ;
    ex:resolved inst:Issue1, inst:Issue3 .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Issue1 ex:state ex:resolved .

inst:User1
    ex:name "Bob Smith" ;
    ex:reported inst:Issue1 .

inst:User2
    ex:name "Alice Allison" ;
    ex:reported inst:Issue1 ;
    ex:resolved inst:Issue3 .
importance to me importance to others intuitiveness comments/use cases
highlow highlow highlow
Multi-occurence

Our examples so far have involved schema in which a property may appear only once in a given shape. The use of general predicates like part_of, hasTopping, hasMember encourages schemas that require multiple instances of a property, but with different constraints. (These are modeled as qualified cardinality restrictions in OWL.) Here we use multi-occurence to require that an iface:ResolvedIssueShape have one or more ex:contributions of shape iface:SubmissionShape and one or more of shape iface:ResolutionShape (somewhat like the popular stackoverflow site).

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = iface:ResolvedIssueShape

iface:ResolvedIssueShape {
    ex:contribution @iface:SubmissionShape+,
    ex:contribution @iface:ResolutionShape+
}
iface:SubmissionShape {
    rdf:type (ex:Problem),
    ex:text xsd:string
}
iface:ResolutionShape {
    rdf:type (ex:Solution),
    ex:text xsd:string
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>

inst:Issue1
    ex:contribution
        inst:Post1, inst:Post2, inst:Post3 .

inst:Post1 a ex:Problem ;
    ex:text "toaster smokes too much" .

inst:Post2 a ex:Problem ;
    ex:text "and emits flames" .

inst:Post3 a ex:Solution ;
    ex:text "don't butter before toasting" .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>

inst:Issue1
    ex:contribution inst:Post1, inst:Post2 .

inst:Post1 a ex:Problem ;
    ex:text "toaster smokes too much" .

inst:Post2 a ex:Problem ;
    ex:text "and emits flames" .
importance to me importance to others intuitiveness comments/use cases
highlow highlow highlow
Coverage/Closed Schema/Closed Shapes

Some of the above examples have had extra triples that aren't described in the schema. For instance, the first example included:

inst:Issue1 a ex:Issue .

This section is about detecting instance triples that do not correspond to something in the schema.

motivations

A service may only be willing to, or only have means to, store expected triples. For example, a service which is backed by a conventional relational store will only be able to store the triples which correspond to columns in the relational schema. Another example would be when a service identifies the triples upon which it acts and data producers want to see if their output should be completely understood by the service.

Without some sort of closure or coverage, it's impossible to detect spelling errors on properties with a minimum cardinality of 0:

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = iface:IssueShape

iface:IssueShape { ex:text xsd:string? }
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>

inst:Issue1 ex:text "smells bad" .
failing data (under closed shapes)
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>

inst:Issue1 ex:txet "smell sbad" .

Three solutions have emerged to catch errors like this: closed shapes, closed schema, and some sort of API to report either the coverage or the remaining triples.

closed shapes

A closed shape requires that every focus node which is matched against it have only those properties included in the shape. This catches the spelling error above, as well as prohibiting additional triples involving the subject node. It only controls triples that have the focus node as a subject; so it would permit the last two triples here:

passing data (closed or open shapes)
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>

inst:Issue1 ex:text "I have issues" .
inst:Foo ex:bar inst:Baz . # permitted
inst:Foo ex:bip inst:Issue1 . # permitted

closed shape annotations

A simple model for closed annotations would be to assert that all of the shapes in a validation operation are closed or open. This lets the closed-ness be a parameter of either the schema or the validation instantiation. A more complex model would involve a syntactic way to mark closed or open shapes in the schema. This would permit e.g. an IssueShape to be closed while a UserShape is open:

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = iface:IssueShape

iface:IssueShape CLOSED {
    ex:state (ex:resolved),
    ex:reportedBy @iface:UserShape,
}
iface:UserShape OPEN {
    foaf:name xsd:string
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Issue1
    ex:state ex:resolved ;
    ex:reportedBy inst:User1 .

inst:User1
    foaf:name "Bob Smith" ;
    foaf:shoeSize 7 .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Issue1
    ex:state ex:resolved ;
    foaf:shoeSize 7 ;
    ex:reportedBy inst:User1 .

inst:User1
    foaf:name "Bob Smith" .

closed schema

The above definition for closed shapes does not address the scenario where a node fulfills multiple roles and we simply wish to assert that every triple in the graph corresponds to a rule in the schema.

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = iface:IssueShape

iface:IssueShape {
  ex:reportedBy @iface:UserShape,
  ex:assignedTo @iface:EmployeeShape
}
iface:UserShape {
  foaf:name xsd:string,
  foaf:nick xsd:string
}
iface:EmployeeShape {
  foaf:name xsd:string,
  foaf:homepage IRI
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Issue1 ex:reportedBy inst:User2 .
inst:Issue1 ex:assignedTo inst:Emp7 .

inst:User2 foaf:name "Bob Smith" .
inst:User2 foaf:nick "bsmith" .

inst:Emp7 foaf:name "Bob Smith" .
inst:Emp7 foaf:homepage <.../bsmith> .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Issue1 ex:reportedBy inst:User2 .
inst:Issue1 ex:assignedTo inst:User2 .

inst:User2 foaf:name "Bob Smith" .
inst:User2 foaf:nick "bsmith" .
inst:User2 foaf:homepage <.../bsmith> .

A solution to this is to "close the schema" instead of the shapes. This involves making sure that every triple that was rejected for one reason was matched by some other rule. The foaf:homepage triple rejected by a closed evaluation of iface:UserShape would be matched by iface:EmployeeShape. The above failing example would match under closed schema.

coverage

Like closed-schema, coverage relies on tracking the triples that were matched during validation, but instead of rejecting something that has extra triples, you just report them. Here we report them by coloring them an alarming pink. From an API perspective, this involves subtracting the triples that were matched from the graph that was validated. This requires that a solution have an unambiguous subgraph which it has matched. Here, extra triples marked with the allRemainingData class, include triples attached directly and indirectly to focus nodes as well as completely isolated triples:

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = iface:IssueShape

iface:IssueShape {
  ex:reportedBy @iface:UserShape
}
iface:UserShape {
  foaf:name xsd:string
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

inst:Issue1 ex:reportedBy inst:User2 .
inst:Issue1 rdfs:label "some issue" .

inst:User2 foaf:name "Bob Smith" .
inst:User2 foaf:account inst:Account3 .
inst:Account3 foaf:accountName "BobSmith738" .

inst:Foo ex:bar <.../blah> .
importance to me importance to others intuitiveness comments/use cases
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
Recursion

The ability to reference a shape from another implies the possibility of recursion. Here is a relatively direct recursion (issue to contributor to comment and back to issue), though recursion could easily pass through multiple complex patterns and not be immediately apparent.

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = iface:IssueShape

iface:IssueShape {
  ex:assignedTo @iface:ContributorShape
}
iface:ContributorShape {
  foaf:name xsd:string,
  ex:posted @iface:CommentShape
}
iface:CommentShape {
  ex:issue @iface:IssueShape,
  ex:text xsd:string
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Issue1 ex:assignedTo inst:User2 .

inst:User2 foaf:name "Bob Smith" .
inst:User2 ex:posted inst:Post7 .

inst:Post7 ex:issue inst:Issue1 .
inst:Post7 ex:text "peanut butter smokes too" .

In order to detect cycles, we can keep a set of pairs of focus node and shape, shortcutting a cycle when we recursively validating the same focus node as the same shape. This is more complex when either direct negation or exclusive-or means the cycle has an odd number of negations.

schema
PREFIX ex: <http://ex.example/#>
start=<T>
<T> { ex:q . | ex:r @<T> }
passing data (example)
PREFIX ex: <http://ex.example/#>
ex:b ex:q ex:z .
ex:b ex:r ex:c .
ex:c ex:q ex:z .
ex:c ex:r ex:b .

Not that the solutions at the bottom of the cyclic XOR example assert that:

<http://ex.example/#b> matches <T>: assuming <http://ex.example/#c> fails <T>
<http://ex.example/#c> matches <T>: assuming <http://ex.example/#b> fails <T>
          

We could say that potentially recursive schemas are forbidden. We could require that recursive data be detected at run-time. Another option is to not define the behavior and let the market suggest which imlementations offer the most useful solution. Finally, we can use an algorithm that keeps track of the (focus node, shape) pairs involved in cycles and documents which solutions are mutually exclusive, as it seen in the bottom of the cyclic XOR example.

importance to me importance to others intuitiveness comments/use cases
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
Langtag

language tag restrictions

We may want to say that the object of some predicate has a particular language tag or no language tag at all. Here @<langtag> controls the permitted language tag and @ with nothing following indicates that there should be no language tag:

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start=iface:PersonShape

iface:ItemShape {
    ex:formName   xsd:string@en,
    ex:formNumber xsd:string@
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Item6
    ex:formName    "HVAC entry"@en ;
    ex:formNumber  "27B-6" .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Item6
    ex:formName    "HVAC entry" ;
    ex:formNumber  "27B-6" .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Item6
    ex:formName    "HVAC entry"@en ;
    ex:formNumber  "27B-6"@en .

language tag uniqueness

Some vocabularies permit repeated properties but require that the language tags on those properties be unique. For instance, SKOS requires that there be no more than one skos:prefLabel for a given language. A feature like language tag uniqueness would permit ShEx to capture this expressivity. Here I use @! to assert a requirement of uniqueness:

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start=iface:PersonShape

iface:PersonShape {
    foaf:name xsd:string@!+
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:User6 foaf:name  "石田"@jp, "Ishida"@en .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:User7 foaf:name  "石田"@jp, "いしだ"@jp .
importance to me importance to others intuitiveness comments/use cases
highlow highlow highlow
highlow highlow highlow
W3C XML Schema Facets

W3C XML Schema defines a list of constraining facets to describe lexical forms and numeric ranges.

pattern

Patterns have been proposed with a form like ~<pattern>. This could be used with or without datatype:

schema
PREFIX iface: <http://myco.example/interface#>
PREFIX ex: <http://ex.example/#>
PREFIX foaf: <http://xmlns.com/foaf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start=iface:PersonShape

iface:ItemShape {
    ex:phoneNumber  ~\+[0-9]{1,3}\.[0-9.]{5-20},
    ex:formNumber   ex:trackingNumber~[0-9]{1,3}-[0-9]
}
passing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Item6
    ex:phoneNumber  "+33.6.12.34.56.78" ;
    ex:formNumber   "27B-6"^^ex:trackingNumber .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Item6
    ex:phoneNumber  "06.12.34.56.78" ;
    ex:formNumber   "27B-6"^^ex:trackingNumber .
failing data
PREFIX inst: <http://example.org/instances/#>
PREFIX foaf: <http://xmlns.com/foaf/>

inst:Item6
    ex:phoneNumber  "+33.6.12.34.56.78" ;
    ex:formNumber   "27B-6" .

other facets

Below is a laundry list of all of the facets. Check any that you think are useful.

importance to me importance to others intuitiveness comments/use cases
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow
highlow highlow highlow

Thank you

Please indicate here if you would like to notified about ShEx implementations: or review tests:.
Please record any additional comments and submit your responses.

Comments

Please list any additional comments:


Eric Prud'hommeaux
$Id: ShExpressivity.html,v 1.28 2015/05/04 14:07:17 eric Exp $