Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't a ShEx constant matching the same term in the data?

I have a ShEx schema expecting a specific type:

epri:VariableShape {
  a st:studyVariable ;
  st:subject [tax:~] ;
  st:signal xsd:decimal
}

which rejects data with that type

st:envFactorEMF a st:studyVariable ; # << this isn't recognized
  st:subject tax:1758 ;
  st:signal -.00043 .

(demo) Why would that be?

like image 738
teach stem Avatar asked Jan 04 '23 07:01

teach stem


2 Answers

The error message from the demo that you linked to actually describes the exact problem.

Error validating http://www.epri.com/studies/3002011786studyVariable as {"type":"NodeConstraint","datatype":"http://www.epri.com/studies/3002011786studyVariable"}: mismatched datatype: http://www.epri.com/studies/3002011786studyVariable is not a literal with datatype http://www.epri.com/studies/3002011786studyVariable

You're using a datatype constraint, which isn't what you want.

You need to use a [ st:studyVariable ], instead, since you want to specify a value set:

epri:VariableShape {
  a [ st:studyVariable ];
  st:subject [tax:~] ;
  st:signal xsd:decimal
}
like image 110
Joshua Taylor Avatar answered Mar 07 '23 07:03

Joshua Taylor


Joshua Taylor's answer is spot on but, since this is the most common mistake in ShEx, I thought I'd elaborate with a little ascii art.

ShEx datatypes are expressed as bare IRIs while value sets are expressed in []s. You had an rdf:type of st:studyVariable:

epri:VariableShape {
  a st:studyVariable ;   # <-- datatype
  st:subject [tax:~] ;   # <-- value set
  st:signal xsd:decimal  # <-- datatype
}

when you wanted a (small) value set of st:studyVariable:

epri:VariableShape {
  a [st:studyVariable] ; # <-- value set
  st:subject [tax:~] ;   # <-- value set
  st:signal xsd:decimal  # <-- datatype
}

(demo)

like image 30
ericP Avatar answered Mar 07 '23 07:03

ericP