PREFIX dc:   <http://purl.org/dc/terms/>
PREFIX st: <http://ns.inria.fr/sparql-template/>
PREFIX doc: <https://w3id.org/seas/documentation/html/loweringRule#>
TEMPLATE doc:imports (?ontology, ?ns){
    "- **Imports:** " str(?olink) st:call-template(doc:moreimports, ?ontology, ?ns) " \n"   # first time

            ", " str(?olink)  # rest

} WHERE { 
    ?ontology owl:imports ?o .
    BIND( IF( STRSTARTS( str(?o), str(?ns) ) , CONCAT( "[", STRAFTER(str(?o), str(?ns)), "](", str(?o), ")") , CONCAT( "[", str(IRI(?o)), "](", str(?o), ")" ) ) AS ?olink )
    FILTER( isIRI(?o) )
} ORDER BY ?o LIMIT 1