shex icon indicating copy to clipboard operation
shex copied to clipboard

Comparison and arithmetic constraints

Open labra opened this issue 9 years ago • 1 comments

At this moment, ShEx compact syntax has the possibility to associate production labels to triple constraints or triple expressions.

Although for ShEx 2.0, those production labels only serve for documentation purposes, their usage could serve to increase ShEx expressivity.

A ShEx processor could assign the value objects of the matched triple constraint to an internal variable that holds the production label and those labels could be used for comparison and even arithmetic expressions.

A possible example could be:

<Conference> { 
  $<startDate> schema:startDate xsd:dateTime ;
  $<endDate> schema:endDate xsd:dateTime;
 <startDate> < <endDate>
}

Another typical example could be:

<Rectangle> {
 $<width> :width xsd:float ;
 $<height> :height xsd:float ;
 $<area> :area xsd:float ;
 <area> = <height> * <width>
}

Given that ShEx supports XML Schema primitive datatypes, I would suggest that the language and built-in functions leverage those from XPath.

This approach would be similar to what SPARQL does in filter expressions.

labra avatar Jan 07 '17 11:01 labra

The accessors branch os shex.js has an initial implementation of this idea. See an example in the manifest.ttl

labra avatar Jan 07 '17 11:01 labra