Created
January 28, 2013 16:54
-
-
Save stain/4657155 to your computer and use it in GitHub Desktop.
XSLT for translating OWL ontologies in RDF/XML format (specifically from OWL API/Protege) to a simplistic HTML, with a hyperlink to documentation.html. To use, modify the XML headers of the OWL file as in the example.xml below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<?xml-stylesheet type="text/xsl" href="owl2html.xslt"?> | |
<rdf:RDF xmlns="http://example.com/ontology/" | |
xmlns:dc="http://purl.org/dc/elements/1.1/" | |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" | |
xmlns:dct="http://purl.org/dc/terms/" | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" | |
xmlns:owl="http://www.w3.org/2002/07/owl#" | |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> | |
<owl:Ontology rdf:about="http://example.com/ontology/"> | |
<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2013-01-09T12:29:35+01:00</dct:modified> | |
<dc:creator rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Tha Creator</dc:creator> | |
<dc:contributor rdf:datatype="http://www.w3.org/2001/XMLSchema#string">John Doe</dc:contributor> | |
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2013-02-09T12:29:35+01:00</dct:issued> | |
<dct:title xml:lang="en">This is the title</dct:title> | |
</owl:Ontology> | |
<owl:ObjectProperty rdf:about="http://example.com/ontology/property1"> | |
<rdfs:label xml:lang="en">First property</rdfs:label> | |
<rdfs:comment xml:lang="en">Provides the very first object property</rdfs:comment> | |
</owl:ObjectProperty> | |
<owl:DatatypeProperty rdf:about="http://example.com/ontology/property2"> | |
<rdfs:label xml:lang="en">Second property</rdfs:label> | |
<rdfs:comment xml:lang="en">This is a data type property</rdfs:comment> | |
</owl:DatatypeProperty> | |
</rdf:RDF> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:owl="http://www.w3.org/2002/07/owl#" | |
xmlns:dct="http://purl.org/dc/terms/" | |
xmlns:dc="http://purl.org/dc/elements/1.1/" | |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" | |
> | |
<xsl:template match="/"> | |
<html> | |
<body> | |
<h1><xsl:value-of select="rdf:RDF/owl:Ontology/dct:title"/></h1> | |
<h2>OWL ontology</h2> | |
<dl> | |
<dt>Ontology IRI</dt> | |
<dd><xsl:value-of select="rdf:RDF/owl:Ontology/@rdf:about"/></dd> | |
<dt>Version IRI</dt> | |
<dd><xsl:value-of select="rdf:RDF/owl:Ontology/owl:versionIRI/@rdf:resource"/></dd> | |
<dt>Creator</dt> | |
<xsl:for-each select="//dc:creator"> | |
<dd><xsl:value-of select="." /></dd> | |
</xsl:for-each> | |
<dt>Contributors</dt> | |
<xsl:for-each select="//dc:contributor"> | |
<dd><xsl:value-of select="." /></dd> | |
</xsl:for-each> | |
<dt>Issued</dt> | |
<xsl:for-each select="//dct:issued"> | |
<dd><xsl:value-of select="." /></dd> | |
</xsl:for-each> | |
<dt>Last modified</dt> | |
<xsl:for-each select="//dct:modified"> | |
<dd><xsl:value-of select="." /></dd> | |
</xsl:for-each> | |
</dl> | |
<p>Please see the <a href="documentation.html">documentation for | |
<xsl:value-of select="rdf:RDF/owl:Ontology/dct:title"/> | |
</a>.</p> | |
<p>This HTML is meant to show a simple browser introduction to the ontology and has been | |
automatically created using XSLT. To see the | |
source OWL as RDF/XML, either use "Save As" or "View Source". | |
</p> | |
<h3>Defined object properties</h3> | |
<dl> | |
<xsl:for-each select="//owl:ObjectProperty"> | |
<dt> | |
<em><xsl:value-of select="rdfs:label" /></em> | |
  | |
<code><xsl:value-of select="@rdf:about" /></code> | |
</dt> | |
<dd><small><xsl:value-of select="rdfs:comment" /></small></dd> | |
</xsl:for-each> | |
</dl> | |
<h3>Defined data type properties</h3> | |
<dl> | |
<xsl:for-each select="//owl:DatatypeProperty"> | |
<dt><code><xsl:value-of select="@rdf:about" /></code> | |
  | |
<em><xsl:value-of select="rdfs:label" /></em></dt> | |
<dd><small><xsl:value-of select="rdfs:comment" /></small></dd> | |
</xsl:for-each> | |
</dl> | |
</body> | |
</html> | |
</xsl:template> | |
</xsl:stylesheet> | |
it great solution, but i want to transform owl to html directly. it is doable ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: