-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addes support for correct xslt transformation for TOC and SWRL display. The transformation checks if rdfs:label is defined if not the rules are generically number as they appear in the XML serialization of the ontology.
- Loading branch information
Victor Chavez
committed
Dec 11, 2023
1 parent
4da92b2
commit 6b4ef70
Showing
3 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2010-2013, Silvio Peroni <[email protected]> | ||
Copyright (C) 2023, Victor Chavez <[email protected]> | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -28,18 +29,59 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
xmlns:f="http://www.essepuntato.it/xslt/function" | ||
xmlns:dcterms="http://purl.org/dc/terms/" | ||
xmlns="http://www.w3.org/1999/xhtml"> | ||
|
||
|
||
|
||
<xsl:template match="rdf:Description" mode="toc"> | ||
<li> | ||
<a href="#{generate-id()}"> | ||
<xsl:choose> | ||
<xsl:when test="string(rdfs:label)"> | ||
<xsl:value-of select="rdfs:label"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:text>Rule #</xsl:text> | ||
<xsl:value-of select="count(preceding-sibling::rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']]) + 1"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</a> | ||
</li> | ||
</xsl:template> | ||
|
||
<xsl:template name="get.swrl.toc"> | ||
<ul class="hlist"> | ||
<xsl:apply-templates select="/rdf:RDF/rdf:Description[rdf:type[@rdf:resource='http://www.w3.org/2003/11/swrl#Imp']]" mode="toc"> | ||
<xsl:sort select="rdfs:comment" order="ascending" data-type="text"/> | ||
</xsl:apply-templates> | ||
</ul> | ||
</xsl:template> | ||
|
||
<xsl:template match="swrl:Imp | rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']]"> | ||
<div id="{generate-id()}" class="entity"> | ||
<h3>Rule #<xsl:value-of select="count(preceding-sibling::swrl:Imp | preceding-sibling::rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']]) + 1" /> <xsl:call-template name="get.backlink.to.top" /></h3> | ||
<h3> | ||
<xsl:choose> | ||
<xsl:when test="string(rdfs:label)"> | ||
<xsl:value-of select="rdfs:label"/> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="concat('Rule #', count(preceding-sibling::swrl:Imp | preceding-sibling::rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']]) + 1)"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
<xsl:call-template name="get.backlink.to.top" /> | ||
</h3> | ||
<p> | ||
<!-- Add rdfs:comment --> | ||
<xsl:if test="rdfs:comment"> | ||
<strong>Comment: </strong> | ||
<xsl:value-of select="rdfs:comment" /><br/><br/> | ||
</xsl:if> | ||
<!-- Continue with the existing content --> | ||
<xsl:apply-templates select="swrl:body" /> | ||
<xsl:text> -> </xsl:text> | ||
<xsl:apply-templates select="swrl:head" /> | ||
</p> | ||
</div> | ||
</xsl:template> | ||
|
||
<xsl:template match="swrl:body | swrl:head | swrl:AtomList/rdf:first | rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#AtomList']]/rdf:first"> | ||
<xsl:apply-templates /> | ||
</xsl:template> | ||
|
@@ -140,6 +182,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
<xsl:if test="exists(//(swrl:Imp | rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']]))"> | ||
<div id="swrlrules"> | ||
<h2>SWRL rules</h2> | ||
<xsl:call-template name="get.swrl.toc"/> | ||
<xsl:apply-templates select="//(swrl:Imp | rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']])" /> | ||
</div> | ||
</xsl:if> | ||
|