Skip to content

Commit

Permalink
Merge pull request #177 from OP-TED/feature/EPO-810
Browse files Browse the repository at this point in the history
transformation for tags
  • Loading branch information
costezki committed Aug 3, 2023
2 parents 6120504 + 6b825ff commit 38b793b
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/owl-core-lib/connectors-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,24 @@
<xsl:with-param name="elementUri" select="$roleURI"/>
</xsl:call-template>

<xsl:for-each select="$connectorsWithSameName">
<xsl:variable name="sourceTags" select="./source/tags/tag"/>
<xsl:variable name="targetTags" select="./target/tags/tag"/>
<xsl:for-each select="$sourceTags">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$roleURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="$targetTags">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$roleURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>

</xsl:template>

Expand Down
38 changes: 38 additions & 0 deletions src/owl-core-lib/descriptors-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,43 @@
</rdf:Description>
</xsl:if>
</xsl:template>


<xd:doc>
<xd:desc>Rule T.07. Tag — in core ontology layer. Specify an annotation axiom on the OWL entity for each UML Tag associated to a UML element.
If a tag has an associated language tag, it should be attached to the value.</xd:desc>
<xd:param name="elementUri"/>
<xd:param name="tagName"/>
<xd:param name="tagValue"/>
</xd:doc>
<xsl:template name="coreLayerTags">
<xsl:param name="tagName"/>
<xsl:param name="tagValue"/>
<xsl:param name="elementUri"/>
<rdf:Description rdf:about="{$elementUri}">
<xsl:choose>
<xsl:when test="fn:contains($tagName, '@')">
<xsl:variable name="langTag" select="fn:substring-after($tagName, '@')"/>
<xsl:variable name="normalisedTagName"
select="fn:substring-before($tagName, '@')"/>
<xsl:element name="{$normalisedTagName}">
<xsl:attribute name="xml:lang">
<xsl:value-of select="$langTag"/>
</xsl:attribute>
<xsl:value-of select="$tagValue"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$tagName}">
<xsl:attribute name="xml:lang">
<xsl:value-of select="'en'"/>
</xsl:attribute>
<xsl:value-of select="$tagValue"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</rdf:Description>
</xsl:template>


</xsl:stylesheet>
57 changes: 57 additions & 0 deletions src/owl-core-lib/elements-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@
<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$classURI"/>
</xsl:call-template>

<xsl:for-each select="f:getElementTags(.)">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$classURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>

</xsl:template>

Expand Down Expand Up @@ -253,6 +261,14 @@
<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$attributeURI"/>
</xsl:call-template>

<xsl:for-each select="f:getElementTags($firstAttribute)">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$attributeURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>


</xsl:if>
Expand Down Expand Up @@ -318,6 +334,14 @@
<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$dataTypeURI"/>
</xsl:call-template>

<xsl:for-each select="f:getElementTags(.)">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$dataTypeURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>

</xsl:template>

Expand Down Expand Up @@ -355,6 +379,15 @@
<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$conceptSchemeURI"/>
</xsl:call-template>

<xsl:for-each select="f:getElementTags(.)">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$conceptSchemeURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>

</xsl:if>
<xsl:if test="fn:contains($conceptSchemeURI, $base-ontology-uri)">
<skos:ConceptScheme rdf:about="{$conceptSchemeURI}"/>
Expand All @@ -374,6 +407,14 @@
<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$conceptSchemeURI"/>
</xsl:call-template>

<xsl:for-each select="f:getElementTags(.)">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$conceptSchemeURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
</xsl:if>

Expand Down Expand Up @@ -421,6 +462,14 @@
<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$enumerationAttributeURI"/>
</xsl:call-template>

<xsl:for-each select="f:getElementTags(.)">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$enumerationAttributeURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
<xsl:if test="fn:contains($enumerationAttributeURI, $base-ontology-uri)">

Expand All @@ -444,6 +493,14 @@
<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$enumerationAttributeURI"/>
</xsl:call-template>

<xsl:for-each select="f:getElementTags(.)">
<xsl:call-template name="coreLayerTags">
<xsl:with-param name="elementUri" select="$enumerationAttributeURI"/>
<xsl:with-param name="tagName" select="./@name"/>
<xsl:with-param name="tagValue" select="./@value"/>
</xsl:call-template>
</xsl:for-each>
</xsl:if>
</xsl:if>
</xsl:template>
Expand Down
30 changes: 30 additions & 0 deletions test/unitTests/test-owl-core-lib/test-descriptors-owl-core.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@
</x:scenario>


<x:scenario
label="Scenario for testing generation of tags - with lang tag ">

<x:call template="coreLayerTags">
<x:param name="tagName" select="'skos:altLabel@ro'"/>
<x:param name="tagValue" select="'Orice agent, chiar si Garcea. '"/>
<x:param name="elementUri" select="'http://base.onto.uri/ClassName'"/>
</x:call>
<x:expect label="there is rdf:Description"
test="boolean(/rdf:Description[@rdf:about='http://base.onto.uri/ClassName'])"
/>
<x:expect label="have lang tag" test="rdf:Description/skos:altLabel/@xml:lang = 'ro'"/>
<x:expect label="correct skos:altLabel text" test="rdf:Description/skos:altLabel/text() = 'Orice agent, chiar si Garcea. '"/>
</x:scenario>

<x:scenario
label="Scenario for testing generation of tags - without lang tag ">

<x:call template="coreLayerTags">
<x:param name="tagName" select="'skos:note'"/>
<x:param name="tagValue" select="'Something else'"/>
<x:param name="elementUri" select="'http://base.onto.uri/ClassName'"/>
</x:call>
<x:expect label="there is rdf:Description"
test="boolean(/rdf:Description[@rdf:about='http://base.onto.uri/ClassName'])"
/>
<x:expect label="have lang tag" test="rdf:Description/skos:note/@xml:lang = 'en'"/>
<x:expect label="correct skos:note text" test="rdf:Description/skos:note/text() = 'Something else'"/>
</x:scenario>



</x:description>

0 comments on commit 38b793b

Please sign in to comment.