sstenchlak / schema-generator

https://kodi-schema-generator.netlify.app/
0 stars 0 forks source link

Showing inheritance ancestors in the list of available CIM attributes and associations #10

Closed martinnec closed 3 years ago

martinnec commented 3 years ago

When showing the list of available CIM attributes and associations also inherited ones will be shown. The inheritance hierarchy can have many levels. The top levels consisting of elements from the basic vocabulary will not be considered.

The following SPARQL query returns the list of relevant inheritance ancestors.

PREFIX z: <https://slovník.gov.cz/základní/pojem/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

CONSTRUCT {
    <https://slovník.gov.cz/legislativní/sbírka/56/2001/pojem/osobní-automobil> rdfs:subClassOf ?ancestor .
    ?ancestor rdfs:subClassOf ?ancestorParent ;
        skos:prefLabel ?label ;
        skos:inScheme ?glossary ;
        skos:definition ?definition .
} WHERE {
    <https://slovník.gov.cz/legislativní/sbírka/56/2001/pojem/osobní-automobil> rdfs:subClassOf+ ?ancestor .
    FILTER NOT EXISTS {
        ?ancestor skos:inScheme <https://slovník.gov.cz/základní/glosář> .
    }

    OPTIONAL {
        ?ancestor rdfs:subClassOf ?ancestorParent .
        ?ancestorParent skos:inScheme [] .
        FILTER NOT EXISTS {
          ?ancestorParent skos:inScheme <https://slovník.gov.cz/základní/glosář> .
        }
    }

    ?ancestor 
        skos:prefLabel ?label ;
        skos:inScheme ?glossary .

    OPTIONAL { ?ancestor skos:definition ?definition }
}

An inherited attribute or association will be listed in the group for the respective inheritance ancestor. The set of all inheritance ancestors is reachable via https://slovník.gov.cz/legislativní/sbírka/56/2001/pojem/osobní-automobil rdfs:subClassOf * in the result. The ancestors will be ordered by the partial order given by the rest of the rdfs:subClassOf triples in the result, i.e. for A rdfs:subClassOf B, A will be before B in the list displayed to the user.