Closed xuemduan closed 4 months ago
same comment as in #3
If we have a real example:
{
"$id": "https://example.com/arrays.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"name": "test",
"description": "A representation of a person, company, organization, or place",
"type": "object",
"properties": {
"fruits": {
"type": "array",
"items": {
"type": "string"
}
},
"street": {
"type": "array",
"prefixItems": [
{ "type": "number" },
{ "type": "string" },
{ "enum": ["Street", "Avenue", "Boulevard"] },
{ "enum": ["NW", "NE", "SW", "SE"] }
]
}
}
}
The structure we need is:
<http://example.com/NodeShape/test> a sh:NodeShape ;
sh:property <http://example.com/PropertyShape/fruits>,
<http://example.com/PropertyShape/street> ;
sh:targetClass <http://example.com/test> .
<http://example.com/PropertyShape/fruits> a sh:PropertyShape ;
sh:path <http://example.com/fruits> .
<http://example.com/PropertyShape/street> a sh:PropertyShape ;
sh:node <http://example.com/NodeShape/street> .
<http://example.com/NodeShape/street> a sh:NodeShape ;
sh:property <http://example.com/PropertyShape/streetP0>,
<http://example.com/PropertyShape/streetP1>,
<http://example.com/PropertyShape/streetP2>,
<http://example.com/PropertyShape/streetP3> .
<http://example.com/PropertyShape/streetP0> a sh:PropertyShape ;
sh:path <http://example.com/streetP0> .
<http://example.com/PropertyShape/streetP1> a sh:PropertyShape ;
sh:path <http://example.com/streetP1> .
<http://example.com/PropertyShape/streetP2> a sh:PropertyShape ;
sh:path <http://example.com/streetP2> .
<http://example.com/PropertyShape/streetP3> a sh:PropertyShape ;
sh:path <http://example.com/streetP3> .
@xuemduan In this case that you only have one items property, like the example that you writed down, you would add all the constrains to Property Shape no?
<http://example.com/PropertyShape/fruits> a sh:PropertyShape ;
sh:path <http://example.com/fruits> .
sh:datatype xsd:string ;
Or should I create a P0 for the item?
@xuemduan In this case that you only have one items property, like the example that you writed down, you would add all the constrains to Property Shape no?
<http://example.com/PropertyShape/fruits> a sh:PropertyShape ; sh:path <http://example.com/fruits> . sh:datatype xsd:string ;
Or should I create a P0 for the item?
No, I think one property shape is enough for this situation. We discussed today that if the array property does not have prefixItems which means that the array only has one type inside, then the RDF will be constructed directly using the property (like :subject :fruites :value1; :fruites :value2), in this case, we only need one property shape with all constraints. For the array property which has prefixItems would be same with what you do now(i.e. create P0, P1, etc. )
@xuemduan @dachafra I've fixed both issues. Whenever you can, please check if it's alright now.
@xuemduan @dachafra I've fixed both issues. Whenever you can, please check if it's alright now.
It works well now:)
Thank you very much @osm0512
The array type property needs to be translated to a property first, then based on its items to see whether needs to create more shapes, but the current translation directly creates a node shape which is not correct.
For example, if we have
what we need to create is just