shexSpec / shex

ShEx language issues, including new features for e.g. ShEx2.1
24 stars 8 forks source link

Comparison and arithmetic constraints #24

Open labra opened 7 years ago

labra commented 7 years ago

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 commented 7 years ago

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