main.rqg 10.8 KB
Newer Older
Maxime Lefrançois's avatar
Maxime Lefrançois committed
1 2 3 4 5 6 7 8 9 10 11 12
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/>

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

Maxime Lefrançois's avatar
Maxime Lefrançois committed
15 16
TEMPLATE <ontology/main.rqg>( ?versionIRI ) { 

17
TEMPLATE <header.rqg>( st:call-template(<ontology/title.rqg>, ?onto ) , ?pathToStatic , true ) .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
18 19 20 21 22 23

""" 
<header id="g-header">
  <div class="g-container">
    <div class="g-block size-100">
      <div class="g-content g-particle">
24
        <h1><a href="{?onto}">{ st:call-template(<ontology/title.rqg>, ?onto ) }</a></h1>
Maxime Lefrançois's avatar
Maxime Lefrançois committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
        <dl>
          <dt>Latest version:</dt><dd><a href='{?onto}'>{?onto}</a></dd>
          {
            TEMPLATE { "<dt>Permanent IRI for this version (" ?versionInfo ")</dt><dd><a href='{?versionIRI}'>{?versionIRI}</a></dd>" }
            WHERE { ?onto owl:versionInfo ?versionInfo ;  owl:versionIRI ?versionIRI } . 
          }
          {
            TEMPLATE { "<dt>" fun:property(<en.properties>, 'previousversion') "</dt><dd><a href='{?onto}'>{?onto}</a></dd>" }
            WHERE {
              ?onto owl:priorVersion ?o  
            } .
          }
          {
            TEMPLATE { "<dt>" fun:property(<en.properties>, 'etsiSource') "</dt><dd>"  ?source "</dd>" }
            WHERE {
              ?onto dcterms:source ?source 
41
            } ORDER BY DESC(?source) .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
42 43 44 45 46
          }
          {
            TEMPLATE { "<dt>" fun:property(<en.properties>, 'publicationDate') "</dt><dd>"  ?date "</dd>" }
            WHERE {
              ?onto dcterms:issued ?date 
47
            } ORDER BY DESC(?date) .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
48 49 50 51 52
          }
          {
            TEMPLATE { "<dt>" fun:property(<en.properties>, 'modificationDate') "</dt><dd>"  ?date "</dd>" }
            WHERE {
              ?onto dcterms:modified ?date 
53 54 55
            } ORDER BY DESC(?date) .
          }
          {
56
            TEMPLATE <ontology/creators.rqg>( ?onto ) .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
57 58
          }
          {
59
            TEMPLATE <ontology/contributors.rqg>( ?onto ) .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
60
          }
61
          <dt>Ontology requirements and tests</dt><dd><a href='requirements'>requirements</a> and <a href='tests'>tests</a></dd>
Maxime Lefrançois's avatar
Maxime Lefrançois committed
62 63 64 65
          {

            TEMPLATE {
              before="<dt>{fun:property(<en.properties>, 'importedontologies')}</dt><dd>\n" ;
66
              """<a href="{?o}">&lt;{?o}&gt;</a>""" 
Maxime Lefrançois's avatar
Maxime Lefrançois committed
67 68 69 70 71 72 73 74 75
              ; separator="\n"
              ; after = "</dd>"
            } WHERE {
              ?onto owl:imports ?o
            } .
          }
          <dt>Prefix and namespace declaration:<dt>
          <dd>Turtle: <code>@prefix {?prefix} &lt;{?onto}&gt; .</code><dd>
          <dd>SPARQL: <code>PREFIX {?prefix} &lt;{?onto}&gt;</code><dd>
76 77 78 79 80 81 82 83 84 85 86
           <dt>Download serialization:</dt><dd>
            <span><a href="{ ?filename }.jsonld" target="_blank"><img src="https://img.shields.io/badge/Format-JSON--LD-blue.svg"/></a></span>
            <span><a href="{ ?filename }.n3" target="_blank"><img src="https://img.shields.io/badge/Format-N3-blue.svg"/></a></span>
            <span><a href="{ ?filename }.nt" target="_blank"><img src="https://img.shields.io/badge/Format-N--Triples-blue.svg"/></a></span>
            <span><a href="{ ?filename }.n3" target="_blank"><img src="https://img.shields.io/badge/Format-N_Triples-blue.svg"/></a></span>
            <span><a href="{ ?filename }.rdf" target="_blank"><img src="https://img.shields.io/badge/Format-RDF/XML-blue.svg"/></a></span>
            <span><a href="{ ?filename }.ttl" target="_blank"><img src="https://img.shields.io/badge/Format-Turtle-blue.svg"/></a></span>
           </dd>
           <dt>License:</dt><dd>
            <span><a href="https://forge.etsi.org/etsi-software-license" target="_blank"><img src="https://img.shields.io/badge/License-https://forge.etsi.org/etsi--software--license-blue.svg"/></a></span>
           </dd>
Maxime Lefrançois's avatar
Maxime Lefrançois committed
87 88 89 90 91 92 93 94 95 96 97
        </dl>
      </div>
    </div>
  </div>
</header> 
<section>
  <div class="container">
 {
TEMPLATE {

    TEMPLATE {
98 99 100 101
      IF( ?abstract != "" , "<h2>{ fun:property(<en.properties>, 'abstract') }</h2>\n{?abstract}\n" , "" )
    } WHERE { 
      BIND( st:call-template(<ontology/abstract.rqg>, ?onto) AS ?abstract )
    }.
Maxime Lefrançois's avatar
Maxime Lefrançois committed
102 103 104 105 106 107 108

    "<div id='toc2'>" BOX { 
      "\n<h2>{ fun:property(<en.properties>, 'toc') }</h2>"
      "\n<ol>" BOX {

        "\n<li><a href='#introduction'>{ fun:property(<en.properties>, 'introduction') }</a></li>"

109 110
        IF( st:call-template(<ontology/examples.rqg> ) != "" , "<li><a href='#examples'>{ fun:property(<en.properties>, 'examples') }</a></li>" , "" )
          
111 112
        "\n<li><a href='#namespacedeclarations'>{ fun:property(<en.properties>, 'namespaces') }</a></li>"

Maxime Lefrançois's avatar
Maxime Lefrançois committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
        TEMPLATE {
          "\n<li><a href='#classes'>{ fun:property(<en.properties>, 'classes') }</a></li>"
        }
        WHERE {
          {?class a owl:Class} UNION {?class a rdfs:Class}
        } LIMIT 1 .

        TEMPLATE {
          "\n<li><a href='#objectproperties'>{ fun:property(<en.properties>, 'objectproperties') }</a></li>"
        }
        WHERE {
          ?op a owl:ObjectProperty
        } LIMIT 1 .

        TEMPLATE {
          "\n<li><a href='#dataproperties'>{ fun:property(<en.properties>, 'dataproperties') }</a></li>"
        }
        WHERE {
          ?dp a owl:DatatypeProperty
        } LIMIT 1 .

        TEMPLATE {
          "\n<li><a href='#namedindividuals'>{ fun:property(<en.properties>, 'namedindividuals') }</a></li>"
        }
        WHERE {
          ?ni a owl:NamedIndividual
        } LIMIT 1 .

        TEMPLATE {
          "\n<li><a href='#annotationproperties'>{ fun:property(<en.properties>, 'annotationproperties') }</a></li>"
        }
        WHERE {
          ?ap a owl:AnnotationProperty
        } LIMIT 1 .

        TEMPLATE {
          "\n<li><a href='#generalaxioms'>{ fun:property(<en.properties>, 'generalaxioms') }</a></li>"
        }
        WHERE {
          {?ga a owl:AllDisjointClasses}
           UNION {
            { ?class a owl:Class}
            UNION { ?class a rdfs:Class}
            UNION { ?class a owl:Restriction }
            FILTER( ISBLANK( ?class) )
            { ?class rdfs:subClassOf []}
            UNION { ?class owl:equivalentClass []}
            }
        } LIMIT 1 .

163 164 165
        IF( st:call-template(<ontology/references.rqg> ) != "" , "<li><a href='#references'>{ fun:property(<en.properties>, 'references') }</a></li>" , "" )

        IF( st:call-template(<ontology/acknowledgements.rqg> ) != "" , "<li><a href='#acknowledgements'>{ fun:property(<en.properties>, 'acknowledgements') }</a></li>" , "" )
Maxime Lefrançois's avatar
Maxime Lefrançois committed
166 167 168 169 170 171 172 173 174 175

        "\n<li><a href='#toc'>Hierarchies of Terms</a></li>"
        

      } "\n</ol>"
    } "\n</div>"


    TEMPLATE {
      before = "<h2>{ fun:property(<en.properties>, 'introduction') }</h2>\n" ;
176
      TEMPLATE <ontology/description.rqg>( ?onto ) .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
177 178 179
      ; after = "\n"
    } .

180 181
    "\n\n\n" TEMPLATE <ontology/examples.rqg>( ) .

182 183
    "\n\n\n" TEMPLATE <ontology/namespaces.rqg>() .

184
    "\n\n\n" TEMPLATE <ontology/classes.rqg>( ?onto  ) 
Maxime Lefrançois's avatar
Maxime Lefrançois committed
185 186 187 188
    WHERE {
      {?c a owl:Class} UNION {?c a rdfs:Class}
    } LIMIT 1 . 
    
189
    "\n\n\n" TEMPLATE <ontology/objectProperties.rqg>( ?onto  ) 
Maxime Lefrançois's avatar
Maxime Lefrançois committed
190 191 192 193
    WHERE {
      ?op a owl:ObjectProperty
    } LIMIT 1 . 

194
    "\n\n\n" TEMPLATE <ontology/dataProperties.rqg>( ?onto  )
Maxime Lefrançois's avatar
Maxime Lefrançois committed
195 196 197 198
    WHERE {
      ?op a owl:DatatypeProperty
    } LIMIT 1 . 

199
    "\n\n\n" TEMPLATE <ontology/namedIndividuals.rqg>( ?onto  ) . 
Maxime Lefrançois's avatar
Maxime Lefrançois committed
200

201 202 203
    "\n\n\n" TEMPLATE <ontology/references.rqg>( ) .

    "\n\n\n" TEMPLATE <ontology/acknowledgements.rqg>( ) .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227

}.
         }
  </div>
</section>
<section>
  <div class="container">
    <nav id="toc">
      <h2 class="introductory" id="table-of-contents">Term hierarchy</h2>
        <ul class="nav nav-tabs" id="myTab" role="tablist">
          <li class="nav-item">
            <a class="nav-link active" id="classes-toc-tab" data-toggle="tab" href="#classes-toc" role="tab" aria-controls="classes-toc" aria-selected="true">Classes</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" id="objectproperties-toc-tab" data-toggle="tab" href="#objectproperties-toc" role="tab" aria-controls="profile" aria-selected="false">ObjectProperties</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" id="dataproperties-toc-tab" data-toggle="tab" href="#dataproperties-toc" role="tab" aria-controls="profile" aria-selected="false">DataProperties</a>
          </li>
        </ul>
        <div class="tab-content" id="myTabContent">
          <div class="tab-pane show active" id="classes-toc" role="tabpanel" aria-labelledby="classes-toc-tab">
{ 
    # toc
228
TEMPLATE <ontology/toc-bar.rqg>( ?onto,  ?class , rdfs:subClassOf ) 
Maxime Lefrançois's avatar
Maxime Lefrançois committed
229 230 231 232 233 234 235 236 237 238 239 240
DISTINCT WHERE {
  ?class a owl:Class 
  FILTER( ISURI(?class) ) 
  FILTER NOT EXISTS { ?class rdfs:subClassOf ?super FILTER( ISURI(?super) )  }
  FILTER( ?class != owl:Thing )
} ORDER BY ?class 
. 
}
          </div>
          <div class="tab-pane" id="objectproperties-toc" role="tabpanel" aria-labelledby="objectproperties-toc-tab">
{ 
    # toc
241
TEMPLATE <ontology/toc-bar.rqg>( ?onto,  ?property , rdfs:subPropertyOf )
Maxime Lefrançois's avatar
Maxime Lefrançois committed
242 243 244 245 246 247 248 249 250 251
WHERE {
  ?property a owl:ObjectProperty
  FILTER( ISURI(?property) ) 
  FILTER NOT EXISTS { ?property rdfs:subPropertyOf ?super FILTER( ISURI(?super) )  }
} ORDER BY ?property . 
}
          </div>
          <div class="tab-pane" id="dataproperties-toc" role="tabpanel" aria-labelledby="dataproperties-toc-tab">
{ 
    # toc
252
TEMPLATE <ontology/toc-bar.rqg>( ?onto,  ?property , rdfs:subPropertyOf )
Maxime Lefrançois's avatar
Maxime Lefrançois committed
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
WHERE {
  ?property a owl:DatatypeProperty
  FILTER( ISURI(?property) ) 
  FILTER NOT EXISTS { ?property rdfs:subPropertyOf ?super FILTER( ISURI(?super) )  }
} ORDER BY ?property . 
}
          </div>
        </div>
    </nav>
  </div>
</section>
"""


  TEMPLATE <footer.rqg>( ?pathToStatic , true  ) .

} FROM ?versionIRI
WHERE {
 BIND( fun:regex( str(?versionIRI), "^https://saref.etsi.org/([a-z4]+)/([^/]+)/$", 1 ) AS ?ext )
272
 BIND( IF( ?ext = "core" , "saref" , ?ext ) AS ?filename )
Maxime Lefrançois's avatar
Maxime Lefrançois committed
273 274 275 276 277 278
 BIND( IF( ?ext = "core" , "saref" , "s{SUBSTR(?ext,6)}" ) AS ?short )
 BIND( UCASE( ?short ) AS ?name )
 BIND( "{?short}:" AS ?prefix )
 BIND( fun:regex( str(?versionIRI), "^https://saref.etsi.org/([a-z4]+)/(v[0-9]+\\.[0-9]+\\.[0-9]+)/$", 2 ) AS ?versionInfo )
 BIND( IRI( fun:regex( str(?versionIRI), "^(https://saref.etsi.org/[a-z4]+/)", 1 ) ) AS ?onto )
 BIND( "../../static" AS ?pathToStatic )
279
 ?onto a owl:Ontology .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
280 281
}
#LIMIT 1