PREFIX st:   <http://ns.inria.fr/sparql-template/>
PREFIX fun: <http://w3id.org/sparql-generate/fn/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 

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

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

  COALESCE( ?html, fun:markdownToHTML(?md), 
    IF( st:call-template( <function/formatText.rqg>,  ?description_en ) != "" , st:call-template( <function/formatText.rqg>,  ?description_en ) , ?undef ), 
    IF( st:call-template( <function/formatText.rqg>,  ?description ) != "" , st:call-template( <function/formatText.rqg>,  ?description ) , ?undef ), 
    "" )
}
SOURCE <abstract.html> AS ?html
SOURCE <abstract.md> AS ?md
WHERE {
  OPTIONAL { 
    ?onto dcterms:abstract ?description_en .
    FILTER (LANG(?description_en)="en")
  }
  OPTIONAL { 
    ?onto dcterms:abstract ?description .
    FILTER ( DATATYPE(?description) = xsd:string )
  }
}
LIMIT 1 

