Skip to content

Commit

Permalink
SWRL rule ordering and minor href fix
Browse files Browse the repository at this point in the history
This change orders swrl rules according to their rdfs:label and a minor fix to href in the body and head of the swrl rules.
  • Loading branch information
vChavezB authored Dec 31, 2023
1 parent badb45b commit e3928bc
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/main/resources/lode/swrl-module.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ Copyright (C) 2023, Victor Chavez <[email protected]>
<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:sort select="lower-case(f:getLabel(rdfs:label))"
order="ascending" data-type="text"/>
</xsl:apply-templates>
</ul>
</xsl:template>
Expand Down Expand Up @@ -132,19 +133,22 @@ Copyright (C) 2023, Victor Chavez <[email protected]>
<xsl:text>)</xsl:text>
</xsl:template>

<!-- Use http://www.essepuntato.it/2011/05/overlapping to test it -->

<xsl:template match="swrl:BuiltinAtom | rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#BuiltinAtom']]">
<xsl:value-of select="substring-after(swrl:builtin/@rdf:resource,'http://www.w3.org/2003/11/swrlb#')" />
<xsl:text>(</xsl:text>
<xsl:variable name="builtinHref" select="swrl:builtin/@rdf:resource" />
<a href="{$builtinHref}" title="{substring-after($builtinHref, '#')}">
<xsl:value-of select="substring-after($builtinHref, '#')" />
</a>
<xsl:text>(</xsl:text>
<xsl:for-each select="swrl:arguments/rdf:Description">
<xsl:value-of select="concat('?',substring-after(@rdf:about,'#'))"/>
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:value-of select="concat('?', substring-after(@rdf:about, '#'))"/>
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>)</xsl:text>
</xsl:template>

<xsl:template match="swrl:classPredicate">
<xsl:apply-templates select="@rdf:resource">
<xsl:with-param name="type" select="'class'" tunnel="yes" as="xs:string" />
Expand Down Expand Up @@ -184,7 +188,10 @@ Copyright (C) 2023, Victor Chavez <[email protected]>
<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']])" />
<xsl:apply-templates select="//(swrl:Imp | rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']])" >
<xsl:sort select="lower-case(f:getLabel(rdfs:label))"
order="ascending" data-type="text"/>
</xsl:apply-templates>
</div>
</xsl:if>
</xsl:template>
Expand All @@ -203,4 +210,4 @@ Copyright (C) 2023, Victor Chavez <[email protected]>
</xsl:if>
</span>
</xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>

0 comments on commit e3928bc

Please sign in to comment.