PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX fun: <http://w3id.org/sparql-generate/fn/>

BASE <https://saref.etsi.org/documentation/>

TEMPLATE <ontology/label.rqg>( ?onto,  ?s ) {
  TEMPLATE { ?label } WHERE { ?s skos:prefLabel ?label } LIMIT 1 .
  TEMPLATE { ?label ; separator = ", aka " } WHERE { ?s rdfs:label ?label FILTER NOT EXISTS{ ?s skos:prefLabel ?label } } .
  TEMPLATE { COALESCE( fun:prefixedIRI(?s) , "!! no label !!" ) } WHERE { FILTER NOT EXISTS{ ?s skos:prefLabel|rdfs:label ?label } } .
}