Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL Transformation of .owl file 1

Status
Not open for further replies.

Faid

Programmer
Mar 23, 2005
2
0
0
NL
Hey, I'm building an ontology in Protégé and I want to transform parts of it (e.g. the instances) to HTML with XSL. When I was transforming another file with 'simple' XML-tags like <author> before, I got it working, but the OWL-file is formatted differently and I don't know how to access the elements. I'll post the .owl file below, but this is basically what I want to get from the file (the course name):

Code:
<Course rdf:ID="AdvancedKnowledgeTechnology">
    <CourseName rdf:datatype="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#string"[/URL]
    >Advanced Knowledge Technology</CourseName>
...
</Course>

Any kind of help is appreciated.

The OWL-file:

Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="MasterAI.xsl"?>
<rdf:RDF
    xmlns:rdf="[URL unfurl="true"]http://www.w3.org/1999/02/22-rdf-syntax-ns#"[/URL]
    xmlns:rdfs="[URL unfurl="true"]http://www.w3.org/2000/01/rdf-schema#"[/URL]
    xmlns:owl="[URL unfurl="true"]http://www.w3.org/2002/07/owl#"[/URL]
    xmlns="[URL unfurl="true"]http://www.owl-ontologies.com/unnamed.owl#"[/URL]
  xml:base="[URL unfurl="true"]http://www.owl-ontologies.com/unnamed.owl">[/URL]
  <owl:Ontology rdf:about=""/>
  <owl:Class rdf:ID="Programme">
    <rdfs:subClassOf>
      <owl:Class rdf:ID="MasterAI"/>
    </rdfs:subClassOf>
    <owl:disjointWith>
      <owl:Class rdf:ID="University"/>
    </owl:disjointWith>
    <owl:disjointWith>
      <owl:Class rdf:ID="Course"/>
    </owl:disjointWith>
    <owl:equivalentClass>
      <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
          <owl:Restriction>
            <owl:allValuesFrom>
              <owl:Class rdf:about="#Course"/>
            </owl:allValuesFrom>
            <owl:onProperty>
              <owl:ObjectProperty rdf:ID="hasCourse"/>
            </owl:onProperty>
          </owl:Restriction>
          <owl:Restriction>
            <owl:onProperty>
              <owl:ObjectProperty rdf:about="#hasCourse"/>
            </owl:onProperty>
            <owl:someValuesFrom>
              <owl:Class rdf:about="#Course"/>
            </owl:someValuesFrom>
          </owl:Restriction>
        </owl:intersectionOf>
      </owl:Class>
    </owl:equivalentClass>
  </owl:Class>
  <owl:Class rdf:about="#Course">
    <owl:disjointWith>
      <owl:Class rdf:about="#University"/>
    </owl:disjointWith>
    <rdfs:subClassOf rdf:resource="#MasterAI"/>
    <owl:disjointWith rdf:resource="#Programme"/>
  </owl:Class>
  <owl:Class rdf:about="#University">
    <rdfs:subClassOf rdf:resource="#MasterAI"/>
    <owl:disjointWith rdf:resource="#Course"/>
    <owl:equivalentClass>
      <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
          <owl:Restriction>
            <owl:onProperty>
              <owl:ObjectProperty rdf:ID="hasProgramme"/>
            </owl:onProperty>
            <owl:allValuesFrom rdf:resource="#Programme"/>
          </owl:Restriction>
          <owl:Restriction>
            <owl:someValuesFrom rdf:resource="#Programme"/>
            <owl:onProperty>
              <owl:ObjectProperty rdf:about="#hasProgramme"/>
            </owl:onProperty>
          </owl:Restriction>
        </owl:intersectionOf>
      </owl:Class>
    </owl:equivalentClass>
    <owl:disjointWith rdf:resource="#Programme"/>
  </owl:Class>
  <owl:Class rdf:ID="ProgrammeAI">
    <rdfs:subClassOf rdf:resource="#Programme"/>
  </owl:Class>
  <owl:ObjectProperty rdf:about="#hasProgramme">
    <rdfs:domain rdf:resource="#University"/>
    <rdf:type rdf:resource="[URL unfurl="true"]http://www.w3.org/2002/07/owl#InverseFunctionalProperty"/>[/URL]
    <rdfs:range rdf:resource="#Programme"/>
    <owl:inverseOf>
      <owl:FunctionalProperty rdf:ID="isProgrammeOf"/>
    </owl:inverseOf>
  </owl:ObjectProperty>
  <owl:ObjectProperty rdf:about="#hasCourse">
    <rdfs:range rdf:resource="#Course"/>
    <rdfs:domain rdf:resource="#Programme"/>
    <owl:inverseOf>
      <owl:ObjectProperty rdf:ID="isCourseOf"/>
    </owl:inverseOf>
  </owl:ObjectProperty>
  <owl:ObjectProperty rdf:about="#isCourseOf">
    <rdfs:domain rdf:resource="#Course"/>
    <owl:inverseOf rdf:resource="#hasCourse"/>
    <rdfs:range rdf:resource="#Programme"/>
  </owl:ObjectProperty>
  <owl:DatatypeProperty rdf:ID="CourseName">
    <rdfs:range rdf:resource="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#string"/>[/URL]
    <rdfs:domain rdf:resource="#Course"/>
    <rdf:type rdf:resource="[URL unfurl="true"]http://www.w3.org/2002/07/owl#FunctionalProperty"/>[/URL]
  </owl:DatatypeProperty>
  <owl:DatatypeProperty rdf:ID="CourseECTS">
    <rdf:type rdf:resource="[URL unfurl="true"]http://www.w3.org/2002/07/owl#FunctionalProperty"/>[/URL]
    <rdfs:range rdf:resource="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#float"/>[/URL]
    <rdfs:domain rdf:resource="#Course"/>
  </owl:DatatypeProperty>
  <owl:FunctionalProperty rdf:ID="ProgrammeName">
    <rdfs:domain rdf:resource="#Programme"/>
    <rdf:type rdf:resource="[URL unfurl="true"]http://www.w3.org/2002/07/owl#DatatypeProperty"/>[/URL]
    <rdfs:range rdf:resource="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#string"/>[/URL]
  </owl:FunctionalProperty>
  <owl:FunctionalProperty rdf:ID="UniversityName">
    <rdf:type rdf:resource="[URL unfurl="true"]http://www.w3.org/2002/07/owl#DatatypeProperty"/>[/URL]
    <rdfs:range rdf:resource="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#string"/>[/URL]
    <rdfs:domain rdf:resource="#University"/>
  </owl:FunctionalProperty>
  <owl:FunctionalProperty rdf:about="#isProgrammeOf">
    <owl:inverseOf rdf:resource="#hasProgramme"/>
    <rdfs:range rdf:resource="#University"/>
    <rdfs:domain rdf:resource="#Programme"/>
    <rdf:type rdf:resource="[URL unfurl="true"]http://www.w3.org/2002/07/owl#ObjectProperty"/>[/URL]
  </owl:FunctionalProperty>
[b]
  <Course rdf:ID="AdvancedKnowledgeTechnology">
    <CourseName rdf:datatype="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#string"[/URL]
    >Advanced Knowledge Technology</CourseName>
    <isCourseOf>
      <ProgrammeAI rdf:ID="MensMachineCommunicatie">
        <ProgrammeName rdf:datatype="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#string"[/URL]
        >Mens-Machine Communicatie en Artificial Intelligence</ProgrammeName>
        <hasCourse rdf:resource="#AdvancedKnowledgeTechnology"/>
        <isProgrammeOf>
          <University rdf:ID="GroningenRuG">
            <UniversityName rdf:datatype="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#string"[/URL]
            >Groningen(RuG)</UniversityName>
            <hasProgramme rdf:resource="#MensMachineCommunicatie"/>
          </University>
        </isProgrammeOf>
      </ProgrammeAI>
    </isCourseOf>
    <CourseECTS rdf:datatype="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema#float"[/URL]
    >5.0</CourseECTS>
  </Course>
[/b]
</rdf:RDF>
 
Just include the namespaces at the top of the XSL file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:rdf="[URL unfurl="true"]http://www.w3.org/1999/02/22-rdf-syntax-ns#"[/URL] xmlns:rdfs="[URL unfurl="true"]http://www.w3.org/2000/01/rdf-schema#"[/URL] xmlns:owl="[URL unfurl="true"]http://www.w3.org/2002/07/owl#"[/URL] xmlns="[URL unfurl="true"]http://www.owl-ontologies.com/unnamed.owl#"[/URL] xml:base="[URL unfurl="true"]http://www.owl-ontologies.com/unnamed.owl">[/URL]
Then refer to the nodes as rdf:mynode/owl:mynode/........

You'll probably hit a problem because you're using a default namespace. See FAQ for help with that.
 
Yes, thank you, the default namespace was the problem. Now it works. :)
 
Hi,
I have problem transform <td>&nbsp;</td>, I have to necessary transform <td>&nbsp;</td>
 
Please post this as a new thread.

And try to describe your problem in more detail please.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top