4

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?

teach stem
  • 132
  • 6
  • I'm no ShExpert (sorry), but the specific error message that the validator provides is helpful. Just like `st:signal xsd:decimal` means that the value of the st:signal property is expected to be a literal with datatype xsd:decimal, it's expecting that the value for rdf:type will a literal that has datatype st:studyVariable. Of course, in the data, that value is actually the IRI st:studyVariable, not a literal at all. – Joshua Taylor Oct 22 '17 at 21:38
  • I think you'd want to use `a [st:studyVariable]` to indicate that you want the actual value. – Joshua Taylor Oct 22 '17 at 21:41

2 Answers2

5

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
}
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
4

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)

ericP
  • 1,675
  • 19
  • 21