Commit 952a67ae authored by Maxime Lefrançois's avatar Maxime Lefrançois

better html documentation

parent 8e62f383
......@@ -28,12 +28,23 @@ package fr.emse.gitlab.saref.managers;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.StringWriter;
import org.apache.commons.io.FileUtils;
import org.apache.jena.atlas.io.IndentedWriter;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.vocabulary.OWL2;
import org.apache.jena.vocabulary.RDF;
import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationValue;
import org.semanticweb.owlapi.model.OWLLiteral;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.parameters.Imports;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -127,7 +138,76 @@ public class VersionSiteManager extends SAREFRepositoryVersionErrorLogger {
private void generateHTMLFile() throws SAREFPipelineException {
Dataset dataset = DatasetFactory.create();
dataset.addNamedModel(version.getIRI(), version.getModel());
Model model = ModelFactory.createDefaultModel();
model.add(version.getModel());
OWLOntology ontology = ontologyManager.loadOntology(version, errorLogger);
ontology.classesInSignature(Imports.INCLUDED).forEach(c->{
if(ontology.isDeclared(c)) {
return;
}
Resource r = model.getResource(c.getIRI().toString());
model.add(r, RDF.type, OWL2.Class);
ontology.annotationAssertionAxioms(c.getIRI(), Imports.INCLUDED).forEach(axiom->{
Property p = model.getProperty(axiom.getProperty().getIRI().toString());
OWLAnnotationValue value = axiom.getValue();
if(value instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral) value;
model.add(r, p, literal.getLiteral());
}
});;
});
ontology.objectPropertiesInSignature(Imports.INCLUDED).forEach(op->{
if(ontology.isDeclared(op)) {
return;
}
Resource r = model.getResource(op.getIRI().toString());
model.add(r, RDF.type, OWL2.ObjectProperty);
ontology.annotationAssertionAxioms(op.getIRI(), Imports.INCLUDED).forEach(axiom->{
Property p = model.getProperty(axiom.getProperty().getIRI().toString());
OWLAnnotationValue value = axiom.getValue();
if(value instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral) value;
model.add(r, p, literal.getLiteral());
}
});;
});
ontology.dataPropertiesInSignature(Imports.INCLUDED).forEach(dp->{
if(ontology.isDeclared(dp)) {
return;
}
Resource r = model.getResource(dp.getIRI().toString());
model.add(r, RDF.type, OWL2.DatatypeProperty);
ontology.annotationAssertionAxioms(dp.getIRI(), Imports.INCLUDED).forEach(axiom->{
Property p = model.getProperty(axiom.getProperty().getIRI().toString());
OWLAnnotationValue value = axiom.getValue();
if(value instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral) value;
model.add(r, p, literal.getLiteral());
}
});;
});
ontology.individualsInSignature(Imports.INCLUDED).forEach(i->{
if(ontology.isDeclared(i)) {
return;
}
Resource r = model.getResource(i.getIRI().toString());
model.add(r, RDF.type, OWL2.NamedIndividual);
ontology.annotationAssertionAxioms(i.getIRI(), Imports.INCLUDED).forEach(axiom->{
Property p = model.getProperty(axiom.getProperty().getIRI().toString());
OWLAnnotationValue value = axiom.getValue();
if(value instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral) value;
model.add(r, p, literal.getLiteral());
}
});;
});
dataset.addNamedModel(version.getIRI(), model);
String htmlFileName = String.format("%s.html", repository.getOntologyFileName());
File file = new File(ontoDir, htmlFileName);
try (IndentedWriter writer = new IndentedWriter(new FileOutputStream(file))) {
......
......@@ -6,22 +6,22 @@ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/abstract.rqg>( ?ontology ) {
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 ),
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 {
?ontology dcterms:abstract ?description_en .
?onto dcterms:abstract ?description_en .
FILTER (LANG(?description_en)="en")
}
OPTIONAL {
?ontology dcterms:abstract ?description .
?onto dcterms:abstract ?description .
FILTER ( DATATYPE(?description) = xsd:string )
}
}
......
......@@ -2,7 +2,7 @@ PREFIX schema: <http://schema.org/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/affiliation.rqg>( ?affiliation ) {
TEMPLATE <ontology/affiliation.rqg>( ?onto, ?affiliation ) {
IF( ISURI(?affiliation) && BOUND(?name) , " (<a href='{?affiliation}'>{ ?name }</a>)", "" )
IF( ISURI(?affiliation) && !BOUND(?name), " (<a href='{?affiliation}'>&lt;{ ?affiliation }&gt;</a>)", "" )
......
......@@ -2,6 +2,6 @@ BASE <https://saref.etsi.org/documentation/>
BASE <https://saref.etsi.org/documentation/>
FUNCTION <ontology/backlink.rqg>(?anchor, ?name ){
FUNCTION <ontology/backlink.rqg>( ?onto, ?anchor, ?name ){
"<span class='backlink'> back to <a href='#toc'>ToC</a> or <a href='#{?anchor}'>{?name} ToC</a></span>"
}
\ No newline at end of file
......@@ -13,22 +13,22 @@ PREFIX iter: <http://w3id.org/sparql-generate/iter/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/class.rqg>( ?class ) {
TEMPLATE <ontology/class.rqg>( ?onto, ?class ) {
"""
<div class='description'><dl>{st:incr()}
{ TEMPLATE <ontology/classDescriptionSubjectObject.rqg>( ?class, "isequivalentto", owl:equivalentClass) . }
{ TEMPLATE <ontology/classDescriptionSubject.rqg>( ?class, 'hassuperclasses', rdfs:subClassOf) . }
{ TEMPLATE <ontology/classDescriptionObject.rqg>( ?class, "hassubclasses", rdfs:subClassOf) . }
{ TEMPLATE <ontology/classDescriptionObject.rqg>( ?class, "isindomainof", rdfs:domain) . }
{ TEMPLATE <ontology/classDescriptionObject.rqg>( ?class, "isinrangeof", rdfs:range) . }
{ TEMPLATE <ontology/classDescriptionSubjectObject.rqg>( ?class, "isdisjointwith", owl:disjointWith) . }
{ TEMPLATE <ontology/classDescriptionSubjectObject.rqg>( ?onto, ?class, "isequivalentto", owl:equivalentClass) . }
{ TEMPLATE <ontology/classDescriptionSubject.rqg>( ?onto, ?class, 'hassuperclasses', rdfs:subClassOf) . }
{ TEMPLATE <ontology/classDescriptionObject.rqg>( ?onto, ?class, "hassubclasses", rdfs:subClassOf) . }
{ TEMPLATE <ontology/classDescriptionObject.rqg>( ?onto, ?class, "isindomainof", rdfs:domain) . }
{ TEMPLATE <ontology/classDescriptionObject.rqg>( ?onto, ?class, "isinrangeof", rdfs:range) . }
{ TEMPLATE <ontology/classDescriptionSubjectObject.rqg>( ?onto, ?class, "isdisjointwith", owl:disjointWith) . }
"""
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, "hasmembers") }</dt><dd>" ;
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?member ) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?member ) .
; separator = ", "
; after = "</dd>"
}
......@@ -40,7 +40,7 @@ WHERE {
# # keys
# TEMPLATE {
# before = "\n<dt>{ fun:property(<en.properties>, "haskeys") }</dt><dd>" ;
# TEMPLATE <ontology/propertyDescription.rqg>( <en.properties> , ?key ) .
# TEMPLATE <ontology/propertyDescription.rqg>( ?onto , ?key ) .
# ; separator = ", "
# ; after = "</dd>"
# } WHERE {
......
......@@ -12,9 +12,9 @@ PREFIX prov: <http://www.w3.org/ns/prov#>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/classDescriptionObject.rqg>( ?class, ?propertyName, ?property ) {
TEMPLATE <ontology/classDescriptionObject.rqg>( ?onto, ?class, ?propertyName, ?property ) {
before = "\n<dt>{ fun:property(<en.properties>, ?propertyName) }</dt><dd>" ;
TEMPLATE <ontology/classDescription.rqg>( ?object , true ) .
TEMPLATE <ontology/classDescription.rqg>( ?onto, ?object , true ) .
; separator = "<br/>"
; after = "</dd>"
}
......
......@@ -12,9 +12,9 @@ PREFIX prov: <http://www.w3.org/ns/prov#>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/classDescriptionSubject.rqg>( ?class, ?propertyName, ?property ) {
TEMPLATE <ontology/classDescriptionSubject.rqg>( ?onto, ?class, ?propertyName, ?property ) {
before = "\n<dt>{ fun:property(<en.properties>, ?propertyName) }</dt><dd>" ;
TEMPLATE <ontology/classDescription.rqg>( ?object , true ) .
TEMPLATE <ontology/classDescription.rqg>( ?onto, ?object , true ) .
; separator = "<br/> "
; after = "</dd>"
}
......
......@@ -12,9 +12,9 @@ PREFIX prov: <http://www.w3.org/ns/prov#>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/classDescriptionSubjectObject.rqg>( ?class , ?propertyName, ?property ) {
TEMPLATE <otology/classDescriptionSubject.rqg>( ?onto, ?class , ?propertyName, ?property ) {
before = "\n<dt>{ fun:property(<en.properties>, ?propertyName) }</dt><dd>" ;
TEMPLATE <ontology/classDescription.rqg>( ?object , true ) .
TEMPLATE <ontology/classDescription.rqg>( ?onto, ?object , true ) .
; separator = "<br/>"
; after = "</dd>"
}
......
......@@ -13,7 +13,7 @@ PREFIX iter: <http://w3id.org/sparql-generate/iter/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <classes.rqg>( ?onto ) {
TEMPLATE <ontology/classes.rqg>( ?onto ) {
"""\n<div id='classes'>
<h2>{fun:property(<en.properties>, 'classes')}</h2>
......@@ -22,7 +22,7 @@ TEMPLATE <classes.rqg>( ?onto ) {
BOX {
# toc
TEMPLATE <ontology/toc.rqg>( ?class )
TEMPLATE <ontology/toc.rqg>( ?onto, ?class )
WHERE {
{?class a owl:Class} UNION {?class a rdfs:Class}
FILTER( ISURI(?class) && STRSTARTS( str(?class), str(?onto) ) )
......@@ -33,26 +33,26 @@ TEMPLATE <classes.rqg>( ?onto ) {
"\n<div id='{fun:prefixedIRI(?class)}' class='entity'>" BOX {
"<a name='{?class}'></a>"
"\n<h3>"
TEMPLATE <ontology/label.rqg>( ?class ) .
TEMPLATE <ontology/label.rqg>( ?onto, ?class ) .
TEMPLATE {
' <span class="alert alert-danger" role="alert"> &#9888; { fun:property(<en.properties>, 'deprecated') }</span>'
} WHERE {
?class owl:deprecated true .
} .
<ontology/backlink.rqg>("classes", "Class")
<ontology/backlink.rqg>( ?onto, "classes", "Class")
"</h3>"
"\n<p><strong>IRI:</strong> { ?class }</p>"
TEMPLATE {
before = "\n<div class='comment'><p>\n" ;
TEMPLATE <function/formatText.rqg>(?comment) .
TEMPLATE <function/formatText.rqg>( ?comment) .
; separator = "<br/>" ; after = "</p></div>"
}
WHERE {
?class rdfs:comment ?comment .
} .
TEMPLATE <ontology/class.rqg>( ?class ) .
TEMPLATE <ontology/class.rqg>( ?onto, ?class ) .
}"\n</div>"
......
......@@ -5,14 +5,14 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/contributors.rqg>( ?ontology ) {
TEMPLATE <ontology/contributors.rqg>( ?onto ) {
IF(?contributors != "" , "<dt>{fun:property(<en.properties>, 'contributors')}</dt><dd>\n{ ?contributors } </dd>", "" )
}
SOURCE <contributors.html> AS ?html
SOURCE <contributors.md> AS ?md
WHERE {
OPTIONAL { ?ontology dcterms:contributor ?contributor . }
BIND( COALESCE( str( ?html ) , fun:markdownToHTML(?md), st:call-template( <ontology/contributors_schema.rqg>, ?ontology ) ) AS ?contributors )
OPTIONAL { ?onto dcterms:contributor ?contributor . }
BIND( COALESCE( str( ?html ) , fun:markdownToHTML(?md), st:call-template( <ontology/contributors_schema.rqg>, ?onto ) ) AS ?contributors )
}
LIMIT 1
......@@ -2,10 +2,10 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/contributors_schema.rqg>( ?ontology ) {
TEMPLATE <ontology/person.rqg>( ?contributor ) .
TEMPLATE <ontology/contributors_schema.rqg>( ?onto ) {
TEMPLATE <ontology/person.rqg>( ?onto, ?contributor ) .
; separator = "<br/>\n"
}
WHERE {
?ontology dcterms:contributor ?contributor .
?onto dcterms:contributor ?contributor .
}
\ No newline at end of file
......@@ -5,14 +5,14 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/creators.rqg>( ?ontology ) {
TEMPLATE <ontology/creators.rqg>( ?onto ) {
IF(?creators != "" , "<dt>{fun:property(<en.properties>, 'creators')}</dt><dd>\n{ ?creators } </dd>", "<dt>{fun:property(<en.properties>, 'creators')}</dt><dd>\nViolation of ETSI TS 103 673 Clause 9.4.3.3</dd>" )
}
SOURCE <creators.html> AS ?html
SOURCE <creators.md> AS ?md
WHERE {
OPTIONAL { ?ontology dcterms:creator ?creator . }
BIND( COALESCE( str( ?html ) , fun:markdownToHTML(?md), st:call-template( <ontology/creators_schema.rqg>, ?ontology ) ) AS ?creators )
OPTIONAL { ?onto dcterms:creator ?creator . }
BIND( COALESCE( str( ?html ) , fun:markdownToHTML(?md), st:call-template( <ontology/creators_schema.rqg>, ?onto ) ) AS ?creators )
} LIMIT 1
......@@ -2,10 +2,10 @@ PREFIX dcterms: <http://purl.org/dc/terms/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/creators_schema.rqg>( ?ontology ) {
TEMPLATE <ontology/person.rqg>( ?creator ) .
TEMPLATE <ontology/creators_schema.rqg>( ?onto ) {
TEMPLATE <ontology/person.rqg>( ?onto, ?creator ) .
; separator = "<br/>\n"
}
WHERE {
?ontology dcterms:creator ?creator .
?onto dcterms:creator ?creator .
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ PREFIX schema: <http://schema.org/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <dataProperties.rqg>( ?onto ) {
TEMPLATE <ontology/dataProperties.rqg>( ?onto ) {
"""\n<div id='dataproperties'>
<h2>{ fun:property(<en.properties>, 'dataproperties') }</h2>"""
......@@ -22,7 +22,7 @@ TEMPLATE <dataProperties.rqg>( ?onto ) {
BOX {
# toc
TEMPLATE <ontology/toc.rqg>( ?dp )
TEMPLATE <ontology/toc.rqg>( ?onto, ?dp )
WHERE {
?dp a owl:DatatypeProperty
FILTER( ISURI(?dp) && STRSTARTS( str(?dp), str(?onto) ) )
......@@ -33,26 +33,26 @@ TEMPLATE <dataProperties.rqg>( ?onto ) {
"\n<div id='{fun:prefixedIRI(?dp)}' class='entity'>" BOX {
"<a name='{?dp}'></a>"
"\n<h3>"
TEMPLATE <ontology/label.rqg>( ?dp ) .
TEMPLATE <ontology/label.rqg>( ?onto, ?dp ) .
TEMPLATE {
' <span class="alert alert-danger" role="alert"> &#9888; { fun:property(<en.properties>, 'deprecated') }</span>'
} WHERE {
?dp owl:deprecated true .
} .
<ontology/backlink.rqg>("dataproperties", "Data Property")
<ontology/backlink.rqg>( ?onto, "dataproperties", "Data Property")
"</h3>"
"\n<p><strong>IRI:</strong> { ?dp }</p>"
TEMPLATE {
before = "\n<div class='comment'><p>\n" ;
TEMPLATE <function/formatText.rqg>(?comment) .
TEMPLATE <function/formatText.rqg>( ?comment) .
; separator = "<br/>" ; after = "</p></div>"
}
WHERE {
?dp rdfs:comment ?comment .
} .
TEMPLATE <ontology/dataProperty.rqg>( ?dp ) .
TEMPLATE <ontology/dataProperty.rqg>( ?onto, ?dp ) .
} "\n</div>"
......
......@@ -14,7 +14,7 @@ PREFIX schema: <http://schema.org/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
TEMPLATE <ontology/dataProperty.rqg>( ?onto, ?dp ) {
# See https://www.w3.org/TR/owl2-quick-reference/#Properties
# Data Property Axioms
......@@ -32,7 +32,7 @@ TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
# equivalent properties
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'hasequivalentproperties') }</dt><dd>" ;
TEMPLATE <ontology/propertyDescription.rqg>( ?dp2 ) .
TEMPLATE <ontology/propertyDescription.rqg>( ?onto, ?dp2 ) .
; separator = ", "
; after = "</dd>"
} DISTINCT WHERE {
......@@ -44,7 +44,7 @@ TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
# hassuperproperties
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'hassuperproperties') }</dt><dd>" ;
TEMPLATE <ontology/propertyDescription.rqg>( ?dp2 ) .
TEMPLATE <ontology/propertyDescription.rqg>( ?onto, ?dp2 ) .
; separator = ", "
; after = "</dd>"
} DISTINCT WHERE {
......@@ -54,7 +54,7 @@ TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
# hassubproperties
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'hassubproperties') }</dt><dd>" ;
TEMPLATE <ontology/propertyDescription.rqg>( ?dp2 ) .
TEMPLATE <ontology/propertyDescription.rqg>( ?onto, ?dp2 ) .
; separator = ", "
; after = "</dd>"
} DISTINCT WHERE {
......@@ -64,7 +64,7 @@ TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
# property domain
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'hasdomain') }</dt><dd>" ;
TEMPLATE <ontology/classDescription.rqg>( ?c , true ) .
TEMPLATE <ontology/classDescription.rqg>( ?onto, ?c , true ) .
; separator = ", "
; after = "</dd>"
} DISTINCT WHERE {
......@@ -74,7 +74,7 @@ TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
# property domain includes
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'domainIncludes') }</dt><dd>" ;
TEMPLATE <ontology/classDescription.rqg>( ?c , true ) .
TEMPLATE <ontology/classDescription.rqg>( ?onto, ?c , true ) .
; separator = ", "
; after = "</dd>"
} DISTINCT WHERE {
......@@ -84,7 +84,7 @@ TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
# property range
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'hasrange') }</dt><dd>" ;
TEMPLATE <ontology/dataRangeDescription.rqg>( ?c ) .
TEMPLATE <ontology/dataRangeDescription.rqg>( ?onto, ?c ) .
; separator = ", "
; after = "</dd>"
} DISTINCT WHERE {
......@@ -94,7 +94,7 @@ TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
# property range includes
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'rangeIncludes') }</dt><dd>" ;
TEMPLATE <ontology/dataRangeDescription.rqg>( ?c ) .
TEMPLATE <ontology/dataRangeDescription.rqg>( ?onto, ?c ) .
; separator = ", "
; after = "</dd>"
} DISTINCT WHERE {
......@@ -104,7 +104,7 @@ TEMPLATE <ontology/dataProperty.rqg>( ?dp ) {
# disjoint properties
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'isdisjointwith') }</dt><dd>" ;
TEMPLATE <ontology/propertyDescription.rqg>( ?dp2 ) .
TEMPLATE <ontology/propertyDescription.rqg>( ?onto, ?dp2 ) .
; separator = ", "
; after = "</dd>"
} DISTINCT WHERE {
......
......@@ -14,11 +14,11 @@ BASE <https://saref.etsi.org/documentation/>
# See https://www.w3.org/TR/owl2-quick-reference/#Data_Ranges
TEMPLATE <ontology/dataRangeDescription.rqg>( ?dataRange ) {
TEMPLATE <ontology/dataRangeDescription.rqg>( ?onto, ?dataRange ) {
# named datatype
TEMPLATE {
"<a href='#{fun:prefixedIRI(?dataRange)}' title='{?dataRange}'>{fun:prefixedIRI(?dataRange)}</a>"
"<a href='{IF( STRSTARTS( STR(?dataRange), STR(?onto)), "#{fun:prefixedIRI(?dataRange)}", ?dataRange )}' title='{?dataRange}'>{fun:prefixedIRI(?dataRange)}</a>"
}
WHERE {
FILTER(ISURI(?dataRange))
......@@ -27,7 +27,7 @@ TEMPLATE <ontology/dataRangeDescription.rqg>( ?dataRange ) {
# data range complement
TEMPLATE {
"( <span class='logic'>not</span> "
TEMPLATE <ontology/dataRangeDescription.rqg>( ?D ).
TEMPLATE <ontology/dataRangeDescription.rqg>( ?onto, ?D ).
")"
}
WHERE {
......@@ -39,7 +39,7 @@ TEMPLATE <ontology/dataRangeDescription.rqg>( ?dataRange ) {
# data range intersection
TEMPLATE {
before="(" ;
TEMPLATE <ontology/dataRangeDescription.rqg>( ?D ).
TEMPLATE <ontology/dataRangeDescription.rqg>( ?onto, ?D ).
; separator=" <span class='logic'>and</span> "
; after=")"
}
......@@ -52,7 +52,7 @@ TEMPLATE <ontology/dataRangeDescription.rqg>( ?dataRange ) {
# data range union
TEMPLATE {
before="(" ;
TEMPLATE <ontology/dataRangeDescription.rqg>( ?D ).
TEMPLATE <ontology/dataRangeDescription.rqg>( ?onto, ?D ).
; separator=" <span class='logic'>or</span> "
; after=")"
}
......@@ -65,7 +65,7 @@ TEMPLATE <ontology/dataRangeDescription.rqg>( ?dataRange ) {
# literal enumeration
TEMPLATE {
before="\{" ;
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v ).
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v ).
; separator=", "
; after="}"
}
......@@ -79,10 +79,10 @@ TEMPLATE <ontology/dataRangeDescription.rqg>( ?dataRange ) {
TEMPLATE {
"("
TEMPLATE <ontology/dataRangeDescription.rqg>( ?DN ) .
TEMPLATE <ontology/dataRangeDescription.rqg>( ?onto, ?DN ) .
" <span class='logic'>with restrictions:</span> "
TEMPLATE <ontology/facetDescription.rqg>( ?restriction )
TEMPLATE <ontology/facetDescription.rqg>( ?onto, ?restriction )
WHERE {
?dataRange owl:withRestrictions / rdf:rest* / rdf:first ?restriction
} .
......
......@@ -6,22 +6,22 @@ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/description.rqg>( ?ontology ) {
TEMPLATE <ontology/description.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 ),
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 ),
"Violation of TS 103 673 Clause 9.4.3.2" )
}
SOURCE <description.html> AS ?html
SOURCE <description.md> AS ?md
WHERE {
OPTIONAL {
?ontology dcterms:description ?description_en .
?onto dcterms:description ?description_en .
FILTER (LANG(?description_en)="en")
}
OPTIONAL {
?ontology dcterms:description ?description .
?onto dcterms:description ?description .
FILTER ( DATATYPE(?description) = xsd:string )
}
}
......
......@@ -15,12 +15,12 @@ BASE <https://saref.etsi.org/documentation/>
# See https://www.w3.org/TR/owl2-quick-reference/#Facets
TEMPLATE <ontology/facetDescription.rqg>( ?restriction ) {
TEMPLATE <ontology/facetDescription.rqg>( ?onto, ?restriction ) {
# xsd:minInclusive
TEMPLATE {
"<span class='logic'>minInclusive</span> "
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v) .
} WHERE {
?restriction xsd:minInclusive ?v .
} .
......@@ -28,7 +28,7 @@ TEMPLATE <ontology/facetDescription.rqg>( ?restriction ) {
# xsd:maxInclusive
TEMPLATE {
"<span class='logic'>maxInclusive</span> "
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v) .
} WHERE {
?restriction xsd:maxInclusive ?v .
} .
......@@ -36,7 +36,7 @@ TEMPLATE <ontology/facetDescription.rqg>( ?restriction ) {
# xsd:minExclusive
TEMPLATE {
"<span class='logic'>minExclusive</span> "
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v) .
} WHERE {
?restriction xsd:minExclusive ?v .
} .
......@@ -44,7 +44,7 @@ TEMPLATE <ontology/facetDescription.rqg>( ?restriction ) {
# xsd:maxExclusive
TEMPLATE {
"<span class='logic'>maxExclusive</span> "
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v) .
} WHERE {
?restriction xsd:maxExclusive ?v .
} .
......@@ -52,7 +52,7 @@ TEMPLATE <ontology/facetDescription.rqg>( ?restriction ) {
# xsd:minLength
TEMPLATE {
"<span class='logic'>minLength</span> "
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v) .
} WHERE {
?restriction xsd:minLength ?v .
} .
......@@ -60,7 +60,7 @@ TEMPLATE <ontology/facetDescription.rqg>( ?restriction ) {
# xsd:maxLength
TEMPLATE {
"<span class='logic'>maxLength</span> "
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v) .
} WHERE {
?restriction xsd:maxLength ?v .
} .
......@@ -68,7 +68,7 @@ TEMPLATE <ontology/facetDescription.rqg>( ?restriction ) {
# xsd:length
TEMPLATE {
"<span class='logic'>length</span> "
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v) .
} WHERE {
?restriction xsd:length ?v .
} .
......@@ -76,7 +76,7 @@ TEMPLATE <ontology/facetDescription.rqg>( ?restriction ) {
# xsd:pattern
TEMPLATE {
"<span class='logic'>pattern</span> "
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?v) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?v) .
} WHERE {
?restriction xsd:pattern ?v .
} .
......
......@@ -14,7 +14,7 @@ PREFIX schema: <http://schema.org/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/individual.rqg>( ?individual ) {
TEMPLATE <ontology/individual.rqg>( ?onto, ?individual ) {
"""
\n<div class='description'><dl>{st:incr()}
......@@ -23,7 +23,7 @@ TEMPLATE <ontology/individual.rqg>( ?individual ) {
# types
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'belongsto') }</dt><dd>" ;
TEMPLATE <ontology/classDescription.rqg>( ?class , true ) .
TEMPLATE <ontology/classDescription.rqg>( ?onto, ?class , true ) .
; separator = "<br/> "
; after = "</dd>"
}
......@@ -35,7 +35,7 @@ TEMPLATE <ontology/individual.rqg>( ?individual ) {
# sameAs
TEMPLATE {
before = "\n<dt>{ fun:property(<en.properties>, 'issameas') }</dt><dd>" ;
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?individual2 ) .
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?individual2 ) .
; separator = "<br/> "
; after = "</dd>"
}
......@@ -47,8 +47,8 @@ TEMPLATE <ontology/individual.rqg>( ?individual ) {
# assertions
TEMPLATE {
"\n<dt>{ st:call-template(<ontology/propertyDescription.rqg>, ?p ) }</dt><dd>"
TEMPLATE { TEMPLATE <ontology/individualAndLiteralDescription.rqg>(?value) . ; separator = ", "} WHERE { ?individual ?p ?value } .
"\n<dt>{ st:call-template(<ontology/propertyDescription.rqg>, ?onto, ?p ) }</dt><dd>"
TEMPLATE { TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?value) . ; separator = ", "} WHERE { ?individual ?p ?value } .
"</dd>"
; separator = "<br/>"
}
......
......@@ -14,11 +14,11 @@ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
BASE <https://saref.etsi.org/documentation/>
# See https://www.w3.org/TR/owl2-quick-reference/#Individuals_.26_Literals
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?object ) {
TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?onto, ?object ) {
# named individual
TEMPLATE {
"<a href='#{fun:prefixedIRI(?object)}' title='{ st:call-template(<ontology/label.rqg>, ?object ) }: {?commentStr}'>{fun:prefixedIRI(?object)}</a>"
"<a href='{IF( STRSTARTS( STR(?object), STR(?onto)), "#{fun:prefixedIRI(?object)}", ?object )}' title='{ st:call-template(<ontology/label.rqg>, ?onto, ?object ) }: {?commentStr}'>{fun:prefixedIRI(?object)}</a>"
"<sup title='{ fun:property(<en.properties>, 'namedindividual') }' class='type-ni'>ni</sup>"
} WHERE {
FILTER(ISURI(?object))
......@@ -38,7 +38,7 @@ TEMPLATE <ontology/individualAndLiteralDescription.rqg>( ?object ) {
"\"" STR( ?object ) "\""
TEMPLATE {
"^^{ TEMPLATE <ontology/dataRangeDescription.rqg>( DATATYPE( ?object ) ) . }"
"^^{ TEMPLATE <ontology/dataRangeDescription.rqg>( ?onto, DATATYPE( ?object ) ) . }"
} WHERE {
FILTER( DATATYPE(?object) != rdf:langString
&& DATATYPE(?object) != xsd:string )
......
......@@ -5,7 +5,7 @@ PREFIX fun: <http://w3id.org/sparql-generate/fn/>
BASE <https://saref.etsi.org/documentation/>
TEMPLATE <ontology/label.rqg>( ?s ) {
TEMPLATE <ontology/label.rqg>( ?onto, ?s ) {
TEMPLATE { ?label } WHERE { ?s skos:prefLabel ?label } LIMIT 1 .
TEMPLATE { ?label ; separator = ", aka " } WHERE { ?s rdfs:label ?label FILTER NOT EXISTS{ ?s skos:prefLabel ?label } } .
TEMPLATE { COALESCE( fun:prefixedIRI(?s) , "!! no label !!" ) } WHERE { FILTER NOT EXISTS{ ?s skos:prefLabel|rdfs:label ?label } } .
......
......@@ -172,7 +172,7 @@ TEMPLATE {
TEMPLATE {
before = "<h2>{ fun:property(<en.properties>, 'introduction') }</h2>\n" ;
TEMPLATE <ontology/description.rqg>(?onto) .
TEMPLATE <ontology/description.rqg>( ?onto ) .
; after = "\n"
} .
......@@ -224,7 +224,7 @@ TEMPLATE {
<div class="tab-pane show active" id="classes-toc" role="tabpanel" aria-labelledby="classes-toc-tab">
{
# toc
TEMPLATE <ontology/toc-bar.rqg>( ?class , rdfs:subClassOf )