PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX fun: <http://w3id.org/sparql-generate/fn/>
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX dc: <http://purl.org/dc/elements/1.1/>

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

TEMPLATE <ontology/title.rqg>( ?ontology ) {
  TEMPLATE { ?title } WHERE { ?ontology dcterms:title|dc:title ?title } LIMIT 1 .
  TEMPLATE { ?title } WHERE { ?ontology rdfs:label ?title FILTER NOT EXISTS{ ?ontology dcterms:title|dc:title ?title } } LIMIT 1 .
  TEMPLATE { "!! no label !!" } WHERE { FILTER NOT EXISTS{ ?ontology dcterms:title|dc:title|rdfs:label ?title } } .
}