Example:
<#Thing> { }
<#CreativeWork> EXTENDS @<#Thing> DISCRIMINATOR {
a [schema:CreativeWork] ;
} {
schema:aggregateRating @<#AggregateRating> *;
schema:author (@<#Person> OR @<#Organization>) *;
schema:datePublished (@<#Date> OR @<#DateTime>) *;
schema:publisher (@<#Person> OR @<#Organization>) *;
}
<#Foo> EXTENDS @<#Thing> DISCRIMINATOR {
a [schema:Foo] ;
} {
...
*;
}
If you want to validate a node n
with shape <#Thing>
, it shows error messages only when a node conforms to the discriminator (a schema:CrativeWork
).
<#CreativeWork_OR_Foo>
DISCRIMINATOR {
a [schema:CreativeWork] ;
} CLOSED {
schema:aggregateRating @<#AggregateRating> *;
schema:author (@<#Person> OR @<#Organization>) *;
schema:datePublished (@<#Date> OR @<#DateTime>) *;
schema:publisher (@<#Person> OR @<#Organization>) *;
}
OR
DISCRIMINATOR {
a [schema:Foo] ;
} {
...
*;
}
<n1>@<#CreativeWork_OR_Foo>
Syntax:
ShapeExpr ::= ...
NodeConstraint
NOT ShapeExpr
ShapeExpr AND ShapeExpr
ShapeExpr OR ShapeExpr
Closed? EXTRA p1...pN (DISCRIMINATOR {TriplExpr})? { TripleExpr }
EXTENDS ShapeExpr Shape
TripleExpr ::= pred ShapeExpr
TripleExpr ; TripleExpr
TripleExpr | TripleExpr
ShapeExpr ::= ...
NodeConstraint
NOT ShapeExpr
ShapeExpr AND ShapeExpr
ShapeExpr OR ShapeExpr
Shape
EXTENDS ShapeExpr Shape
Shape ::=
EXTENDS Closed Extra p1...pN ShapeExpr | Triple Expr
TripleExpr ::= pred ShapeExpr
TripleExpr ; TripleExpr
TripleExpr | TripleExpr
public class Shape extends ShapeExpr implements AnnotedObject {
private boolean closed;
private Set<TCProperty> extra;
private TripleExpr tripleExpr;
private List<Annotation> annotations;
private List<ShapeExprRef> extended;
Basic semantics: Discriminator te1 te2
could be compiled to te1 ; te2
...Closed? EXTRA p1...pN (DISCRIMINATOR ShapeExpr)? { TripleExpr }
<S1> DISC { :p1 [1 2] } { :p1 [2 3] }
<n1> :p1 1 . # satisfied disc, failed
<n2> :p1 2 . # "
<n3> :p1 3 . # fails disc
<n4> :p1 1, 2 # passed
<n5> :p1 2, 3 # passes
<S1> DISC { :p1 [1 2] ; :p1 [2 3]? } { :p1 [2 3] }
<n4> :p1 1, 2 . # passes
<n5> :p1 1, 4 . # fails
<S1> DISC { :p1 [1 2] ; :p1 [2 3]? } { :p1 [2 3]; :q [ 1 ] }
<n4> :p1 1, 2; :q 1 . # passes
<n5> :p1 1, 2 . # disc. fails or all error messages?
<n5> :p1 1, 3 . # disc. fails or evaluate all?
When testing N@S
, recurse through S's
For any Shape, if there's a discriminator and it fails, fail with a DiscriminatorFailure
<S> (@<S1> OR @<S2>) AND @<S3>
<S1> DISCRIMINATOR { :p0 [0] } { :p1 [1] }
<S2> { :p2 [2] }
<S3> DISCRIMINATOR { :p3 [3] } { :p4 . }
<F1> @<F2>
@@ something like this?:
<S> DISCRIMINATOR { :p0 [0]; :p3 [3] } { :p1 [1] } AND { :p4 . }
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing