Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add indexing: namespace for user-defined values in fedora
- Update HTML header rendering to make it consistent with owl2html

Resolves: https://jira.duraspace.org/browse/FCREPO-1285
  • Loading branch information
acoburn authored and Andrew Woods committed Jan 23, 2015
1 parent f5f1561 commit d13033b
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 29 deletions.
1 change: 1 addition & 0 deletions README
Expand Up @@ -2,6 +2,7 @@ v4 Ontology for Fedora Commons.

http://fedora.info/definitions/v4/repository
http://fedora.info/definitions/v4/oai-pmh
http://fedora.info/definitions/v4/indexing

To generate HTML versions of the ontologies:

Expand Down
3 changes: 1 addition & 2 deletions index.xml
@@ -1,5 +1,4 @@
<index title="Fedora Ontologies">
<page id="rels-ext"/>
<page id="repository"/>
<page id="rest-api"/>
<page id="indexing"/>
</index>
40 changes: 40 additions & 0 deletions index2html.xsl
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<xsl:output method="html"/>
<xsl:template match="/index">
<html>
<head>
<title><xsl:value-of select="@title"/></title>
<style>
h1 { font-size: large; }
body { font-family: sans-serif; }
</style>
</head>
<body>
<h1><xsl:value-of select="@title"/></h1>
<ul>
<xsl:for-each select="page">
<xsl:variable name="page_id" select="@id"/>
<xsl:for-each select="document(concat($page_id,'.rdf'))">
<xsl:choose>
<xsl:when test="rdf:RDF/owl:Ontology/rdfs:label">
<li>
<a href="{$page_id}/"><xsl:value-of select="rdf:RDF/owl:Ontology/rdfs:label"/></a>
</li>
</xsl:when>
<xsl:when test="rdf:RDF/rdf:Description[1]/dcterms:title">
<a href="{$page_id}/"><xsl:value-of select="rdf:RDF/rdf:Description[1]/dcterms:title"/></a>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
31 changes: 31 additions & 0 deletions indexing.rdf
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="rdfs2html.xsl"?>
<rdf:RDF
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<rdf:Description rdf:about="http://fedora.info/definitions/v4/indexing#">
<dcterms:title xml:lang="en">Fedora Commons Indexing Ontology</dcterms:title>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2015-01-23</dcterms:modified>
<dcterms:publisher rdf:resource="http://fedorarepository.org/"/>
<rdfs:seeAlso rdf:resource="https://wiki.duraspace.org/display/FEDORA4x/External+Search"/>
<rdfs:comment xml:lang="en">Ontology for indexing configuration in Fedora repositories.</rdfs:comment>
</rdf:Description>

<rdf:Property rdf:about="http://fedora.info/definitions/v4/indexing#hasIndexingTransformation">
<rdfs:label xml:lang="en">has indexing transformation</rdfs:label>
<rdfs:comment xml:lang="en">Specifies an indexing transformation</rdfs:comment>
<rdfs:domain rdf:resource="http://fedora.info/definitions/v4/indexing#Indexable"/>
<rdfs:isDefinedBy rdf:resource="http://fedora.info/definitions/v4/indexing#"/>
</rdf:Property>

<rdfs:Class rdf:about="http://fedora.info/definitions/v4/indexing#Indexable">
<rdfs:label xml:lang="en">indexable resource</rdfs:label>
<rdfs:comment xml:lang="en">A resource that has been marked as indexable.</rdfs:comment>
<rdfs:subClassOf rdf:resource="http://fedora.info/definitions/v4/repository#Resource"/>
<rdfs:isDefinedBy rdf:resource="http://fedora.info/definitions/v4/indexing#"/>
</rdfs:Class>

</rdf:RDF>
23 changes: 0 additions & 23 deletions owl2html.xsl
Expand Up @@ -184,27 +184,4 @@
</xsl:if>
</div>
</xsl:template>
<xsl:template match="/index">
<html>
<head>
<title><xsl:value-of select="@title"/></title>
<style>
h1 { font-size: large; }
body { font-family: sans-serif; }
</style>
</head>
<body>
<h1><xsl:value-of select="@title"/></h1>
<ul>
<xsl:for-each select="page">
<xsl:variable name="page_id" select="@id"/>
<xsl:for-each select="document(concat($page_id,'.rdf'))">
<xsl:variable name="title" select="rdf:RDF/owl:Ontology/rdfs:label"/>
<li><a href="{$page_id}/"><xsl:value-of select="$title"/></a></li>
</xsl:for-each>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
20 changes: 16 additions & 4 deletions pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo</artifactId>
<version>4.0.0-beta-02-SNAPSHOT</version>
<version>4.0.1-SNAPSHOT</version>
</parent>

<artifactId>fcrepo-ontology</artifactId>
Expand All @@ -31,9 +31,7 @@
<transformationSet>
<dir>.</dir>
<includes>
<include>rels-ext.rdf</include>
<include>repository.rdf</include>
<include>rest-api.rdf</include>
</includes>
<stylesheet>owl2html.xsl</stylesheet>
<outputDir>${project.build.directory}/html</outputDir>
Expand All @@ -44,12 +42,26 @@
</fileMapper>
</fileMappers>
</transformationSet>
<transformationSet>
<dir>.</dir>
<includes>
<include>indexing.rdf</include>
</includes>
<stylesheet>rdfs2html.xsl</stylesheet>
<outputDir>${project.build.directory}/html</outputDir>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.RegExpFileMapper">
<pattern>\.rdf$</pattern>
<replacement>/index.html</replacement>
</fileMapper>
</fileMappers>
</transformationSet>
<transformationSet>
<dir>.</dir>
<includes>
<include>index.xml</include>
</includes>
<stylesheet>owl2html.xsl</stylesheet>
<stylesheet>index2html.xsl</stylesheet>
<outputDir>${project.build.directory}/html</outputDir>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
Expand Down
145 changes: 145 additions & 0 deletions rdfs2html.xsl
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/">
<xsl:output method="html"/>
<xsl:variable name="about" select="/rdf:RDF/rdf:Description[1]/@rdf:about"/>
<xsl:variable name="title" select="/rdf:RDF/rdf:Description[1]/dcterms:title"/>
<xsl:variable name="comment" select="/rdf:RDF/rdf:Description[1]/rdfs:comment"/>
<xsl:variable name="modified" select="/rdf:RDF/rdf:Description[1]/dcterms:modified"/>
<xsl:variable name="publisher" select="/rdf:RDF/rdf:Description[1]/dcterms:publisher/@rdf:resource"/>
<xsl:variable name="seeAlso" select="/rdf:RDF/rdf:Description[1]/rdfs:seeAlso/@rdf:resource"/>


<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="$title"/></title>
<style>
h4 { margin-bottom: 0.25em; }
body { font-family: sans-serif; }
.about { font-family: monospace; margin-left: 1em; }
.label { margin-left: 1em; font-style:italic; }
.comment { margin-left: 1em; }
.property { margin-left: 1em; }
.modified { margin-left: 1em; }
.published { margin-left: 1em; }
.seealso { margin-left: 1em; }
</style>
</head>
<body>
<h1><xsl:value-of select="$title"/></h1>
<div class="about"><xsl:value-of select="$about"/></div>
<div class="comment"><xsl:value-of select="$comment"/></div>
<div class="modified">Modified: <xsl:value-of select="$modified"/></div>
<div class="published">Published by: <a href="{$publisher}"><xsl:value-of select="$publisher"/></a></div>
<xsl:if test="$seeAlso != ''">
<div class="seealso">See Also: <a href="{$seeAlso}"><xsl:value-of select="$seeAlso"/></a></div>
</xsl:if>

<!-- table of contents -->
<div class="table-of-contents">
<h2>Table of Contents</h2>
<xsl:for-each select="/rdf:RDF/rdfs:Class">
<xsl:sort select="@rdf:about"/>
<xsl:if test="position() = 1"><h3>Classes</h3></xsl:if>
<xsl:call-template name="toc-entry"/>
</xsl:for-each>
<xsl:for-each select="/rdf:RDF/rdf:Property">
<xsl:sort select="@rdf:about"/>
<xsl:if test="position() = 1"><h3>Properties</h3></xsl:if>
<xsl:call-template name="toc-entry"/>
</xsl:for-each>
</div>

<!-- class list -->
<div class="contents">
<h2>Entity Definitions</h2>
<xsl:for-each select="/rdf:RDF/rdfs:Class">
<xsl:sort select="@rdf:about"/>
<xsl:if test="position() = 1"><h3>Classes</h3></xsl:if>
<xsl:call-template name="main-entry"/>
</xsl:for-each>

<!-- properties list -->
<xsl:for-each select="/rdf:RDF/rdf:Property">
<xsl:sort select="@rdf:about"/>
<xsl:if test="position() = 1"><h3>Properties</h3></xsl:if>
<xsl:call-template name="main-entry"/>
</xsl:for-each>
</div>
</body>
</html>
</xsl:template>
<xsl:template name="display-uri">
<xsl:param name="label"/>
<xsl:param name="uri"/>
<xsl:variable name="name">
<xsl:choose>
<xsl:when test="/*/namespace::*[starts-with($uri,.)]">
<xsl:for-each select="/*/namespace::*">
<xsl:if test="starts-with($uri,.)">
<xsl:value-of select="name()"/>:<xsl:value-of select="substring-after($uri,.)"/>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$uri"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$uri != ''">
<li><xsl:value-of select="$label"/><xsl:text>: </xsl:text>
<a href="$uri"><xsl:value-of select="$name"/></a>
</li>
</xsl:if>
</xsl:template>
<xsl:template name="toc-entry">
<xsl:variable name="id">
<xsl:value-of select="substring-after(@rdf:about,$about)"/>
</xsl:variable>
<xsl:if test="$id != ''">
<a href="#{$id}"><xsl:value-of select="$id"/></a>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="main-entry">
<xsl:variable name="id">
<xsl:value-of select="substring-after(@rdf:about,$about)"/>
</xsl:variable>
<xsl:if test="$id != ''">
<h4 id="{$id}"><xsl:value-of select="$id"/></h4>
<ul>
<li>Label: <xsl:value-of select="rdfs:label"/></li>
<xsl:if test="rdfs:comment != ''">
<li>Comment: <xsl:value-of select="rdfs:comment"/></li>
</xsl:if>
<xsl:if test="rdfs:subClassOf/@rdf:resource">
<xsl:call-template name="display-uri">
<xsl:with-param name="label">Subclass of</xsl:with-param>
<xsl:with-param name="uri" select="rdfs:subClassOf/@rdf:resource"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="rdfs:subPropertyOf/@rdf:resource">
<xsl:call-template name="display-uri">
<xsl:with-param name="label">Subproperty of</xsl:with-param>
<xsl:with-param name="uri" select="rdfs:subPropertyOf/@rdf:resource"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="rdfs:domain/@rdf:resource">
<xsl:call-template name="display-uri">
<xsl:with-param name="label">Domain</xsl:with-param>
<xsl:with-param name="uri" select="rdfs:domain/@rdf:resource"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="rdfs:range/@rdf:resource">
<xsl:call-template name="display-uri">
<xsl:with-param name="label">Range</xsl:with-param>
<xsl:with-param name="uri" select="rdfs:range/@rdf:resource"/>
</xsl:call-template>
</xsl:if>
</ul>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

0 comments on commit d13033b

Please sign in to comment.