PREFIX st:   <http://ns.inria.fr/sparql-template/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX fun: <http://w3id.org/sparql-generate/fn/>
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 foaf: <http://xmlns.com/foaf/0.1/>
PREFIX schema: <http://schema.org/>

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

TEMPLATE <ontology/person.rqg>( ?onto,  ?person ) { 

  IF( ISURI(?person) && BOUND(?givenName) , "<a href='{?person}'>{ ?givenName } { ?familyName }</a>", "" )
  IF( ISURI(?person) && !BOUND(?givenName), "<a href='{?person}'>&lt;{ ?person }&gt;</a>", "" )
  IF( ISBLANK(?person) && BOUND(?givenName), "<span>{ ?givenName } { ?familyName }</span>", "" )
  IF( ISBLANK(?person) && !BOUND(?givenName), "Violation of ETSI TS 103 673 Clause 9.4.3.3", "" )

  TEMPLATE <ontology/affiliation.rqg>( ?onto,  ?affiliation )
  WHERE {
    ?person schema:affiliation ?affiliation
  } .  

} WHERE {
  OPTIONAL {
    ?person a schema:Person ;
      schema:givenName ?givenName ;
      schema:familyName ?familyName 
  }
}
