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>( ?onto ) {
  TEMPLATE { ?title } WHERE { ?onto dcterms:title|dc:title ?title } LIMIT 1 .
  TEMPLATE { ?title } WHERE { ?onto rdfs:label ?title FILTER NOT EXISTS{ ?onto dcterms:title|dc:title ?title } } LIMIT 1 .
  TEMPLATE { "!! no label !!" } WHERE { FILTER NOT EXISTS{ ?onto dcterms:title|dc:title|rdfs:label ?title } } .
}