Geonovum / MIM-Werkomgeving

Werkomgeving van MIM. Bevat werk en alle pre-publicatieversies.
https://geonovum.github.io/MIM-Werkomgeving/
7 stars 16 forks source link

Incorrect usage of `sh:datatype` in SPARQL query for "Primitief Datatype" #548

Closed elena-slavco closed 4 weeks ago

elena-slavco commented 1 month ago

Hi MIM Community,

We are working with MIM 1.2 and noticed that for SPARQL query for transformation of Primitief Datatype (Section 6.4.6.1), there is wrong domain for property sh:datatype .

CONSTRUCT {
  ?datatype a sh:NodeShape.
  ?datatype sh:datatype xsd:string.
  ?datatype mim:equivalent ?primitiefdatatype.
}

According to the SHACL specification, the sh:datatype property can only be defined for sh:PropertyShape, however in this SPARQL transformation it is defined for sh:NodeShape. See the image below: Screenshot 2024-05-29 093701 | =250x250

pmaria commented 1 month ago

Hi @elena-slavco,

Great that you are working with MIM!

According to the SHACL specification, the sh:datatype property can only be defined for sh:PropertyShape, however in this SPARQL transformation it is defined for sh:NodeShape.

I do not believe sh:datatype is formally defined to be only useable on sh:PropertyShape.

The diagram which you refer to is informal, and unfortunately does not reflect the domains and ranges defined in the SHACL ontology, where the domain for sh:datatype is unspecified, nor does it match the definitions in the SHACL for SHACL shapes, where sh:datatype is declared to be useable on any sh:Shape.

Furthermore, the formal definition of sh:datatype reads:

sh:datatype specifies a condition to be satisfied with regards to the datatype of each value node.

The formal definition of "value node", with regard to node shapes reads:

For node shapes the value nodes are the individual focus nodes, forming a set with exactly one member.

So, I see no issue with using sh:datatype on a sh:NodeShape (literals are also nodes, and can also be focus nodes).

A test in the SHACL playground confirms that this is possible:

image

elena-slavco commented 1 month ago

Hi @pmaria , Thank you very much for the detailed answer. Now it is clear!

I have some follow-up questions. In the query above we have created a NodeShape for datatype. In the queries transform types we will related the datatype to the subject. There are 2 queries:

  1. In the first query we see the use of rdfs:Datatype, but I havent seen the mapping to rdfs:Datatype anywhere in the MIM 1.2 queries.
  2. In the second query we specify that ?subject a sh:NodeShape. . Is this correct? In my case the ?modelelemente is an Attrubuusoort and sh:PropertyShape in owl, therefore I will not be able to connect the attribute with its datatype. I am currently working with MIM 1.1 and checking some MIM 1.2 for Datatypes.

Thank you for your help!

wouterbeek commented 4 weeks ago

Specifically the following query string:

CONSTRUCT {
  ?subject sh:datatype ?datatype
}
WHERE {
  ?modelelement mim:type ?type.
  ?type rdfs:subClassOf*/rdf:type mim:PrimitiefDatatype.
  ?subject mim:equivalent ?modelelement.
  ?datatype mim:equivalent ?type.
  ?datatype a rdfs:Datatype.
}

Notice that rdfs:Datatype pops up here, but will not be delivered by an EAPX file (which has no knowledge of RDFS).

@elena-slavco Can you move this rdfs:Datatype question to a new issue, and close the current issue as answered?