Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
ericP committed Apr 24, 2019
1 parent 036bb66 commit a6166a4
Showing 1 changed file with 106 additions and 91 deletions.
197 changes: 106 additions & 91 deletions ShExPath.html
Expand Up @@ -132,141 +132,156 @@ <h2>Issue Example</h2>
}
</pre>
</section>
<section id="simple-access">
<h2>Simple Access</h2>
<section id="simple-access">
<h2>Simple Access</h2>
<p>
Elements can be addressed either by label or index.
For shape expressions, the label is the name of the shape expression.
Shape expression labels or indexes are prefixed by "<code>@</code>".
For triple constraints, the label is the name of the predicate for that triple constraints.
Elements of triple expressions may be selected by index within the triple expression.
</p>
<table class="example">
<thead>
<th style="min-width: 20em;">ShExPath</th> <th>value</th>
</thead>
<tbody>
<tr><td>/@&lt;#IssueShape&gt;/:category</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape, addressed by the <em>name</em> of the shape expression followed by the <em>name</em> of the <code>:category</code> property.</td></tr>
<tr><td>/@&lt;#IssueShape&gt;/2</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape, addressed by the <em>name</em> of the shape expression followed by the <em>index</em> of the <code>:category</code> property.</td></tr>
<tr><td>/@1/2</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape, addressed by the <em>index</em> of the shape expression followed by the <em>index</em> of the <code>:category</code> property.</td></tr>
</tbody>
</table>
<section id="context-tests">
<h3>Nested Expressions</h3>
<p>
Elements can be addressed either by label or index.
For shape expressions, the label is the name of the shape expression.
For triple constraints, the label is the name of the predicate for that triple constraints.
Elements of triple expressions may be selected by index within the triple expression.
A traversal through a schema, for instance, the results of a validation, can be expressed as a ShExPath.
Such a ShExPath can include shape references in value expressions.
These are can be appended to the triple expression path with a <code>/</code> separator.
</p>
<table class="example">
<thead>
<th style="min-width: 20em;">ShExPath</th> <th>value</th>
</thead>
<tbody>
<tr><td>/@&lt;#IssueShape&gt;/:category</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape, addressed by the <em>name</em> of the shape expression followed by the <em>name</em> of the <code>:category</code> property.</td></tr>
<tr><td>/@&lt;#IssueShape&gt;/2</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape, addressed by the <em>name</em> of the shape expression followed by the <em>index</em> of the <code>:category</code> property.</td></tr>
<tr><td>/1/2</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape, addressed by the <em>index</em> of the shape expression followed by the <em>index</em> of the <code>:category</code> property.</td></tr>
<tr><td>/@&lt;#IssueShape&gt;/:postedBy/@&lt;#UserShape&gt;/foaf:mbox</td><td>the <code>:postedBy</code> constraint in the <code>#IssueShape</code> shape, which then references the <code>:category</code> property in the <code>#UserShape</code>.</td></tr>
<tr><td>/@1/3/@2/2</td><td>the same path, but with ordinals.</td></tr>
</tbody>
</table>
</section>
</section>

<section id="context-tests">
<h2>Contenxt Tests</h2>
<p>
For added clarity and confidence, the ShExJ type of all shape expressions and triple expressions addressable can be tested.
If the expression type is specified and does not match the corresponding type in the schema, the path is invalid.
</p>

<section id="shape-expressions">
<h3>Shape Expressions</h3>
<p>
The axes <code>ShapeAnd</code>, <code>ShapeOr</code>, <code>ShapeNot</code>, <code>EachOf</code>, <code>OneOf</code>, <code>NodeConstraint</code> and <code>TripleConstraint</code> may be used to specify the expected expression type.
</p>
<table class="example">
<thead>
<th style="min-width: 20em;">ShExPath</th> <th>value</th>
</thead>
<tbody>
<tr><td>/@&lt;#UserShape&gt;/shapeAnd 2/foaf:mbox</td><td>the <code>foaf:mbox</code> constraint in <code>#UserShape</code>'s shape.
Note that <code>IRI /User\?id=[0-9]+/ {...}</code> compiles to a <code>ShapeAnd</code> with the first component a <code>NodeConstraint</code> and the second being a shape..
</td></tr>
</tbody>
</table>
</section>

<section id="triple-expressions">
<h3>Triple Expressions</h3>
<p>
The axes <code>EachOf</code>, <code>OneOf</code> and <code>TripleConstraint</code> may be used to specify the expected expression type.
</p>
<table class="example">
<thead>
<th style="min-width: 20em;">ShExPath</th> <th>value</th>
</thead>
<tbody>
<tr><td>/1/ShapeAnd 2/EachOf 2</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape, explicitly labeling the <em>index</em> axes.</td></tr>
<tr><td>/&lt;#UserShape&gt;/2/EachOf 1/OneOf 2</td><td>the <code>EachOf</code> containing <code>foaf:givenName</code> and <code>foaf:familyName</code> in the <code>#UserShape</code> shape.</td></tr>
<tr><td>/&lt;#UserShape&gt;/2/EachOf 1/EachOf 2</td><td class="error">invalid path for the given schema.</td></tr>
</tbody>
</table>
</section>
</section>
<section id="context-tests">
<h2>Context Tests</h2>
<p>
For added clarity and confidence, the ShExJ type of all shape expressions and triple expressions addressable can be tested.
If the expression type is specified and does not match the corresponding type in the schema, the path is invalid.
</p>

<section id="relative-shexpaths">
<h2>Relative ShExPaths</h2>
<section id="shape-expressions">
<h3>Shape Expressions</h3>
<p>
Evaluation of a ShExPath includes a context.
ShExPaths starting with a <code>/</code> force the context to be the schema.
When the schema is the context, indexes access entries in the ShExJ <code>.shapes</code> property.
The application may provide a context.
For instance validation results MAY be reported using relative ShExPaths.
The axes <code>ShapeAnd</code>, <code>ShapeOr</code>, <code>ShapeNot</code>, <code>EachOf</code>, <code>OneOf</code>, <code>NodeConstraint</code> and <code>TripleConstraint</code> may be used to specify the expected expression type.
</p>
<table class="example">
<thead>
<th style="min-width: 2em;">Context</th> <th style="min-width: 7em;">ShExPath</th> <th>value</th>
<th style="min-width: 20em;">ShExPath</th> <th>value</th>
</thead>
<tbody>
<tr><td>/@&lt;#IssueShape&gt;</td><td>:category</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape.</td ></tr>
<tr><td>/@&lt;#UserShape&gt;/shapeAnd 2/foaf:mbox</td><td>the <code>foaf:mbox</code> constraint in <code>#UserShape</code>'s shape.
Note that <code>IRI /User\?id=[0-9]+/ {...}</code> compiles to a <code>ShapeAnd</code> with the first component a <code>NodeConstraint</code> and the second being a shape..
</td></tr>
</tbody>
</table>
<p>
Relative ShExPaths can be concatonated to their context with <code>/</code> separator.
</p>
</section>

<section id="disambiguation">
<h2>Disambiguation</h2>
<section id="triple-expressions">
<h3>Triple Expressions</h3>
<p>
If more than one triple constraint has the same predicate, they can be indexed by the order they would be encountered in a depth-first search.
If the index is omitted, it is assumed to be 1.
The axes <code>EachOf</code>, <code>OneOf</code> and <code>TripleConstraint</code> may be used to specify the expected expression type.
</p>
<pre class="example">
&lt;BPObs&gt; {
:component { code: "systolic"; value: xsd:double };
:component { code: "diastolic"; value: xsd:double };
:component { code: "posture"; value: @&lt;Postures&gt; }?;
}
</pre>
<table class="example">
<thead>
<th style="min-width: 20em;">ShExPath</th> <th>value</th>
</thead>
<tbody>
<tr><td>/&lt;BPObs&gt;/:component 3</td><td>the third <code>:component</code> triple expression (the one expecting a code of "posture").</td></tr>
<tr><td>/&lt;BPObs&gt;/:component</td><td>the first <code>:component</code> triple expression (the one expecting a code of "systolic").</td></tr>
<tr><td>/1/ShapeAnd 2/EachOf 2</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape, explicitly labeling the <em>index</em> axes.</td></tr>
<tr><td>/&lt;#UserShape&gt;/2/EachOf 1/OneOf 2</td><td>the <code>EachOf</code> containing <code>foaf:givenName</code> and <code>foaf:familyName</code> in the <code>#UserShape</code> shape.</td></tr>
<tr><td>/&lt;#UserShape&gt;/2/EachOf 1/EachOf 2</td><td class="error">invalid path for the given schema.</td></tr>
</tbody>
</table>
</section>
</section>

<section id="grammar">
<h2>Grammar</h2>
<p>
[<a href="https://services.w3.org/yacker/uploads/ShExPath?lang=perl">Try it in yacker</a>], e.g. this <a href="https://services.w3.org/yacker/uploads/ShExPath?lang=perl&text=%2F%40%3Chttp%3A%2F%2Fa.example%2FShape1%3E%2FShapeAnd+1%2F1%2Fx%3Ay1+2%2FShapeOr+2%2F%40sch%3AShape2&amp;action=validate+text">nested validation result test</a>.
</p>
<pre>
<section id="relative-shexpaths">
<h2>Relative ShExPaths</h2>
<p>
Evaluation of a ShExPath includes a context.
ShExPaths starting with a <code>/</code> force the context to be the schema.
When the schema is the context, indexes access entries in the ShExJ <code>.shapes</code> property.
The application may provide a context.
For instance validation results MAY be reported using relative ShExPaths.
</p>
<table class="example">
<thead>
<th style="min-width: 2em;">Context</th> <th style="min-width: 7em;">ShExPath</th> <th>value</th>
</thead>
<tbody>
<tr><td>/@&lt;#IssueShape&gt;</td><td>:category</td><td>the <code>:category</code> constraint in the <code>#IssueShape</code> shape.</td ></tr>
</tbody>
</table>
<p>
Relative ShExPaths can be concatonated to their context with <code>/</code> separator.
</p>
</section>

<section id="disambiguation">
<h2>Disambiguation</h2>
<p>
If more than one triple constraint has the same predicate, they can be indexed by the order they would be encountered in a depth-first search.
If the index is omitted, it is assumed to be 1.
</p>
<pre class="example">
&lt;BPObs&gt; {
:component { code: "systolic"; value: xsd:double };
:component { code: "diastolic"; value: xsd:double };
:component { code: "posture"; value: @&lt;Postures&gt; }?;
}
</pre>
<table class="example">
<thead>
<th style="min-width: 20em;">ShExPath</th> <th>value</th>
</thead>
<tbody>
<tr><td>/&lt;BPObs&gt;/:component 3</td><td>the third <code>:component</code> triple expression (the one expecting a code of "posture").</td></tr>
<tr><td>/&lt;BPObs&gt;/:component</td><td>the first <code>:component</code> triple expression (the one expecting a code of "systolic").</td></tr>
</tbody>
</table>
</section>

<section id="grammar">
<h2>Grammar</h2>
<p>
[<a href="https://services.w3.org/yacker/uploads/ShExPath?lang=perl">Try it in yacker</a>], e.g. this <a href="https://services.w3.org/yacker/uploads/ShExPath?lang=perl&text=%2F%40%3Chttp%3A%2F%2Fa.example%2FShape1%3E%2FShapeAnd+1%2F1%2Fx%3Ay1+2%2FShapeOr+2%2F%40sch%3AShape2&amp;action=validate+text">nested validation result test</a>.
</p>
<pre>
ShExPathExpr ::= AbsolutePathExpr | RelativePathExpr
AbsolutePathExpr ::= "/" RelativePathExpr
RelativePathExpr ::= StepExpr ("/" StepExpr)*
StepExpr ::= ContextTest? Index
StepExpr ::= ContextTest? ExprIndex
ContextTest ::= ShapeExprContext | TripleExprContext
ShapeExprContext ::= "ShapeAnd" | "ShapeOr" | "ShapeNot"
| "NodeConstraint" | "Shape"
TripleExprContext ::= "EachOf" | "OneOf" | "TripleConstraint"
Index ::= NumericIndex | LabelIndex
NumericIndex ::= INTEGER
| "[" INTEGER "]"
LabelIndex ::= SchemaLabel NumericIndex?
| "[" SchemaLabel "]" NumericIndex?
SchemaLabel ::= ShapeExprLabel | TripleExprLabel
ShapeExprLabel ::= "@" (iri | BLANK_NODE_LABEL)
TripleExprLabel ::= iri | BLANK_NODE_LABEL
ExprIndex ::= ShapeExprIndex | TripleExprIndex
ShapeExprIndex ::= "@" (INTEGER | ShapeExprLabel)
ShapeExprLabel ::= iri | BLANK_NODE_LABEL
TripleExprIndex ::= INTEGER | TripleExprLabel
TripleExprLabel ::= (iri | BLANK_NODE_LABEL) INTEGER?
[136s] iri ::= IRIREF | prefixedName
[137s] prefixedName ::= PNAME_LN | PNAME_NS

@terminals
[18t] IRIREF ::= '&lt;' ([^#x00-#x20<>\"{}|^`\\] | UCHAR)* '&gt;'
[18t] IRIREF ::= '&lt;' ([^#x00-#x20&lt;&gt;\"{}|^`\\] | UCHAR)* '&gt;'
[140s] PNAME_NS ::= PN_PREFIX? ':'
[141s] PNAME_LN ::= PNAME_NS PN_LOCAL
[142s] BLANK_NODE_LABEL ::= '_:' (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)?
Expand Down

0 comments on commit a6166a4

Please sign in to comment.