[xsl] XSL transformation of instances in an OWL ontology to HTML

Subject: [xsl] XSL transformation of instances in an OWL ontology to HTML
From: Fredrik <faid@xxxxxxxxxx>
Date: Mon, 28 Mar 2005 17:23:38 +0200
Hey, I'm developing a very simple ontology in Protigi 3.0. Just to give a
brief introduction to the case: the three main classes are Course,
University and ProgrammeAI. There are properties/relations between the
classes, for example "Programme (hasCourse) Course" , "Course (isCourseOf)
Programme" and "ProgrammeAI (isProgrammeOf) University". I want to use XSLT
to be able to retrieve and show, in HTML, different views of this data, for
instance "which Courses are part of which ProgrammeAI" or "which Courses
can be found at which Universities".
I'm new to XML and XSLT, and the problem I have is that I don't know how
traverse the tree to find all the information. To clarify, I can find a
course with <xsl:template match="myns:Course"> but then I want to find out
which ProgrammeAI it belongs to, either by going up in the tree (via
<isCourseOf>) or down in the tree (via <hasCourse>). After that, I want to
find out which University the ProgrammeAI belongs to, either via
<isProgrammeOf> or via <hasProgramme>. Is it possible to do it this way or
is there a better way to do it? I've looked at a couple of tutorials,
posted on some forums and the closest I got to some understanding was to
use some XPATH axis expression with ancestor:: or descendent:: but I do not
know how to formulate the expressions or if it's the right way to go. I'm
stuck and any help is highly appreciated. I'll post the full OWL file below
(hope it doesn't get cut off because it's quite long). Note that I only
want to transform the data starting at <myns:ProgrammeAI
rdf:ID="AgentsLanguageSpeech"> and down.

- Fredrik Henricsson

<?xml version="1.0"?>
<rdf:RDF
   xmlns="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/Exe
rcise%205/MasterAI.owl#"
   xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#";
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#";
   xmlns:owl="http://www.w3.org/2002/07/owl#";
   xmlns:myns="http://www.owl-ontologies.com/unnamed.owl#";
 xml:base="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/Ex
ercise%205/MasterAI.owl">
 <owl:Ontology
rdf:about="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/Exe
rcise%205/MasterAI.owl"/>
 <owl:Ontology rdf:about="http://www.owl-ontologies.com/unnamed.owl"/>
 <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Programme";>
   <rdfs:subClassOf>
     <owl:Class
rdf:about="http://www.owl-ontologies.com/unnamed.owl#MasterAI"/>
   </rdfs:subClassOf>
   <owl:disjointWith>
     <owl:Class
rdf:about="http://www.owl-ontologies.com/unnamed.owl#University"/>
   </owl:disjointWith>
   <owl:disjointWith>
     <owl:Class
rdf:about="http://www.owl-ontologies.com/unnamed.owl#Course"/>
   </owl:disjointWith>
   <owl:equivalentClass>
     <owl:Class>
       <owl:intersectionOf rdf:parseType="Collection">
         <owl:Restriction>
           <owl:allValuesFrom>
             <owl:Class
rdf:about="http://www.owl-ontologies.com/unnamed.owl#Course"/>
           </owl:allValuesFrom>
           <owl:onProperty>
             <owl:ObjectProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasCourse"/>
           </owl:onProperty>
         </owl:Restriction>
         <owl:Restriction>
           <owl:onProperty>
             <owl:ObjectProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasCourse"/>
           </owl:onProperty>
           <owl:someValuesFrom>
             <owl:Class
rdf:about="http://www.owl-ontologies.com/unnamed.owl#Course"/>
           </owl:someValuesFrom>
         </owl:Restriction>
       </owl:intersectionOf>
     </owl:Class>
   </owl:equivalentClass>
 </owl:Class>
 <owl:Class rdf:about="http://www.owl-ontologies.com/unnamed.owl#Course";>
   <owl:disjointWith>
     <owl:Class
rdf:about="http://www.owl-ontologies.com/unnamed.owl#University"/>
   </owl:disjointWith>
   <rdfs:subClassOf
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#MasterAI"/>
   <owl:disjointWith
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
 </owl:Class>
 <owl:Class
rdf:about="http://www.owl-ontologies.com/unnamed.owl#University";>
   <rdfs:subClassOf
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#MasterAI"/>
   <owl:disjointWith
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Course"/>
   <owl:equivalentClass>
     <owl:Class>
       <owl:intersectionOf rdf:parseType="Collection">
         <owl:Restriction>
           <owl:allValuesFrom
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
           <owl:onProperty>
             <owl:ObjectProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasProgramme"/>
           </owl:onProperty>
         </owl:Restriction>
         <owl:Restriction>
           <owl:someValuesFrom
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
           <owl:onProperty>
             <owl:ObjectProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasProgramme"/>
           </owl:onProperty>
         </owl:Restriction>
       </owl:intersectionOf>
     </owl:Class>
   </owl:equivalentClass>
   <owl:disjointWith
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
 </owl:Class>
 <owl:Class
rdf:about="http://www.owl-ontologies.com/unnamed.owl#ProgrammeAI";>
   <rdfs:subClassOf
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
 </owl:Class>
 <owl:ObjectProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasProgramme";>
   <rdfs:domain
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#University"/>
   <rdf:type
rdf:resource="http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/>
   <rdfs:range
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
   <owl:inverseOf>
     <owl:FunctionalProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#isProgrammeOf"/>
   </owl:inverseOf>
 </owl:ObjectProperty>
 <owl:ObjectProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#hasCourse";>
   <rdfs:range
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Course"/>
   <rdfs:domain
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
   <owl:inverseOf>
     <owl:ObjectProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#isCourseOf"/>
   </owl:inverseOf>
 </owl:ObjectProperty>
 <owl:ObjectProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#isCourseOf";>
   <rdfs:domain
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Course"/>
   <owl:inverseOf
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasCourse"/>
   <rdfs:range
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
 </owl:ObjectProperty>
 <owl:DatatypeProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#CourseName";>
   <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
   <rdfs:domain
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Course"/>
   <rdf:type
rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
 </owl:DatatypeProperty>
 <owl:DatatypeProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#CourseECTS";>
   <rdf:type
rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
   <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
   <rdfs:domain
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Course"/>
 </owl:DatatypeProperty>
 <owl:FunctionalProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#ProgrammeName";>
   <rdfs:domain
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
   <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
   <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
 </owl:FunctionalProperty>
 <owl:FunctionalProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#UniversityName";>
   <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
   <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
   <rdfs:domain
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#University"/>
 </owl:FunctionalProperty>
 <owl:FunctionalProperty
rdf:about="http://www.owl-ontologies.com/unnamed.owl#isProgrammeOf";>
   <owl:inverseOf
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#hasProgramme"/>
   <rdfs:range
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#University"/>
   <rdfs:domain
rdf:resource="http://www.owl-ontologies.com/unnamed.owl#Programme"/>
   <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
 </owl:FunctionalProperty>
 <myns:ProgrammeAI rdf:ID="AgentsLanguageSpeech">
   <myns:hasCourse>
     <myns:Course rdf:ID="EvaluationLanguageAndSpeech">
       <myns:isCourseOf
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#AgentsLanguageSpeech"/>
       <myns:CourseName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
       >Evaluation of Language and Speech Technology
Systems</myns:CourseName>
       <myns:CourseECTS
rdf:datatype="http://www.w3.org/2001/XMLSchema#float";
       >7.5</myns:CourseECTS>
     </myns:Course>
   </myns:hasCourse>
   <myns:isProgrammeOf>
     <myns:University rdf:ID="UtrechtUU">
       <myns:UniversityName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
       >Utrecht(UU)</myns:UniversityName>
       <myns:hasProgramme>
         <myns:ProgrammeAI rdf:ID="CognitiveDynamics">
           <myns:isProgrammeOf
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#UtrechtUU"/>
           <myns:ProgrammeName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
           >Cognitive Dynamics</myns:ProgrammeName>
           <myns:hasCourse>
             <myns:Course rdf:ID="DynamicSemantics">
               <myns:isCourseOf
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#CognitiveDynamics"/>
               <myns:CourseName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
               >Dynamic Semantics</myns:CourseName>
               <myns:isCourseOf>
                 <myns:ProgrammeAI rdf:ID="FoundationAI">
                   <myns:isProgrammeOf
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#UtrechtUU"/>
                   <myns:ProgrammeName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
                   >Foundation of AI</myns:ProgrammeName>
                   <myns:hasCourse
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#DynamicSemantics"/>
                 </myns:ProgrammeAI>
               </myns:isCourseOf>
               <myns:CourseECTS
rdf:datatype="http://www.w3.org/2001/XMLSchema#float";
               >7.5</myns:CourseECTS>
             </myns:Course>
           </myns:hasCourse>
         </myns:ProgrammeAI>
       </myns:hasProgramme>
       <myns:hasProgramme
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#FoundationAI"/>
       <myns:hasProgramme
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#AgentsLanguageSpeech"/>
     </myns:University>
   </myns:isProgrammeOf>
   <myns:ProgrammeName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
   >Agents, Language and Speech Technology</myns:ProgrammeName>
 </myns:ProgrammeAI>
 <myns:ProgrammeAI rdf:ID="MenMachine">
   <myns:hasCourse>
     <myns:Course rdf:ID="AdvancedKnowledgeTechnology">
       <myns:CourseECTS
rdf:datatype="http://www.w3.org/2001/XMLSchema#float";
       >5.0</myns:CourseECTS>
       <myns:isCourseOf
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#MenMachine"/>
       <myns:CourseName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
       >Advanced Knowledge Technology</myns:CourseName>
     </myns:Course>
   </myns:hasCourse>
   <myns:ProgrammeName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
   >Mens-Machine Communicatie en Artificial
Intelligence</myns:ProgrammeName>
   <myns:isProgrammeOf>
     <myns:University rdf:ID="GroningenRUG">
       <myns:hasProgramme
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#MenMachine"/>
       <myns:UniversityName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
       >Groningen(RUG)</myns:UniversityName>
     </myns:University>
   </myns:isProgrammeOf>
 </myns:ProgrammeAI>
 <myns:ProgrammeAI rdf:ID="ArtificialIntelligence">
   <myns:ProgrammeName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
   >Artificial Intelligence</myns:ProgrammeName>
   <myns:hasCourse>
     <myns:Course rdf:ID="LogischeTechniekenindeAI">
       <myns:CourseECTS
rdf:datatype="http://www.w3.org/2001/XMLSchema#float";
       >5.0</myns:CourseECTS>
       <myns:isCourseOf
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#ArtificialIntelligence"/>
       <myns:CourseName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
       >Logische Technieken in de AI</myns:CourseName>
     </myns:Course>
   </myns:hasCourse>
   <myns:isProgrammeOf>
     <myns:University rdf:ID="AmsterdamVU">
       <myns:hasProgramme
rdf:resource="file:/C:/Skola/Utbytesgrejer/Advanced%20Knowledge%20Technology/
Exercise%205/MasterAI.owl#ArtificialIntelligence"/>
       <myns:UniversityName
rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
       >Amsterdam(VU)</myns:UniversityName>
     </myns:University>
   </myns:isProgrammeOf>
 </myns:ProgrammeAI>
</rdf:RDF>

<!-- Created with Protege (with OWL Plugin 1.3, Build
225.4)  http://protege.stanford.edu -->

Current Thread