Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWRL rule ordering and minor href fix #664

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this triggers an error if the label does not exist

Copy link
Contributor Author

@vChavezB vChavezB Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed all the swrl rules had an rdfs:label because in the SWRL Tab from Protégé the rdfs: label is always included.

grafik

I am not sure if this will work but we could perhaps check if the rdfs:label exists

<xsl:choose>
    <xsl:when test="exists(rdfs:label)">
        <xsl:sort select="lower-case(f:getLabel(rdfs:label))" order="ascending" data-type="text"/>
    </xsl:when>
    <xsl:otherwise>
        <xsl:sort select="lower-case(f:getLabel(rdfs:comment))" order="ascending" data-type="text"/>
    </xsl:otherwise>
</xsl:choose>

</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>