lucmoreau / ProvToolbox

Java toolkit to create and convert W3C PROV data model representations, and build provenance-enabled applications in a variety of programming languages (java, python, typescript, javascript)
Other
75 stars 42 forks source link

Variables for time of activity cause parsing error #171

Closed aweinert closed 3 years ago

aweinert commented 3 years ago

The following template fails to parse using InteropFramework#readDocument(_, ProvFormat.PROVN, _):

document
  prefix var <http://openprovenance.org/var#>
  activity(-, var:startTime, var:endTime, -)                                        
endDocument

The error log indicates

14:24:45,267  WARN Utility:35 - line 3:11 mismatched input '-' expecting QUALIFIED_NAME
14:24:45,279  WARN Utility:35 - line 3:14 missing OPEN_SQUARE_BRACE at 'var:startTime'
14:24:45,280  WARN Utility:35 - line 3:29 rule QUALIFIED_NAME failed predicate: { !PROV_NParser.qnameDisabled }?
14:24:45,280  WARN Utility:35 - line 3:30 rule QUALIFIED_NAME failed predicate: { !PROV_NParser.qnameDisabled }?
14:24:45,283  WARN Utility:35 - line 3:31 rule QUALIFIED_NAME failed predicate: { !PROV_NParser.qnameDisabled }?
14:24:45,283  WARN Utility:35 - line 3:32 no viable alternative at character ':'
14:24:45,285  WARN Utility:35 - line 3:27 mismatched input ',' expecting EQUAL
14:24:45,285  WARN Utility:35 - line 3:33 mismatched input 'endTime' expecting QUALIFIED_NAME
14:24:45,285  WARN Utility:35 - line 3:42 mismatched input '-' expecting QUALIFIED_NAME

We would like to bind start- and end-times to templated activities, but this parsing error prevents us from doing so. The error also occurs when parsing that template at openprovenance.org.

trungdong commented 3 years ago

You should specify var:startTime and var:endTime as the values for the attributes tmpl:startTime and tmpl:endTime in a template, respectively. (See https://openprovenance.org/prov-template/#variable-table)

An example can be found here: https://github.com/openprov/templates/tree/master/org/openprovenance/picaso/project

PROV-DM and, hence, PROV-N specified that those arguments must have dateTime values. Therefore, putting a qualified name in those places will make the statement invalid.

aweinert commented 3 years ago

Thanks for the help and the explanation, using the following template works as expected:

document
  prefix var <http://openprovenance.org/var#>
  activity(-, -, -, [tmpl:startTime='var:startTime', tmpl:endTime='var:endTime'])
endDocument