Skip to content

Commit

Permalink
added new Tags support, new variable for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragos0000 committed Jan 13, 2025
1 parent 0945047 commit af5d923
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,4 @@ pyvenv.cfg
/build/
/node_modules/
.temp
/enf/
10 changes: 10 additions & 0 deletions src/common/fetchers.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@
<xsl:sequence select="$element/tags/tag"/>
</xsl:function>

<xd:doc>
<xd:desc>Fetch all tags for a connector, including source, target, and connector-level tags</xd:desc>
<xd:param name="connector"/>
</xd:doc>
<xsl:function name="f:getConnectorTags">
<xsl:param name="connector"/>
<!-- Fetch all tags from source, target, and connector level -->
<xsl:sequence select="$connector//tags/tag" />
</xsl:function>

<xd:doc>
<xd:desc> Fetch role name value from a connector. It can be either in source or in target</xd:desc>
<xd:param name="connector"/>
Expand Down
40 changes: 36 additions & 4 deletions src/owl-core-lib/descriptors-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@
<xsl:param name="comment"/>
<xsl:param name="elementUri"/>
<rdf:Description rdf:about="{$elementUri}">
<skos:editorialNote xml:lang="en">
<xsl:value-of select="fn:normalize-space($comment)"/>
</skos:editorialNote>
<xsl:element name="{$commentProperty}">
<xsl:attribute name="xml:lang">en</xsl:attribute>
<xsl:value-of select="fn:normalize-space($comment)"/>
</xsl:element>
</rdf:Description>
</xsl:template>

Expand Down Expand Up @@ -96,19 +97,50 @@
<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: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:when test="fn:contains($tagName, '^^')">
<xsl:variable name="datatype" select="fn:substring-after($tagName, '^^')"/>
<xsl:variable name="datatypePrefix" select="fn:substring-before($datatype, ':')"/>
<xsl:variable name="datatypeValue" select="fn:substring-after($datatype, ':')"/>
<xsl:variable name="expandedDatatypePrefix" select="f:getNamespaceURI($datatypePrefix)"/>

<xsl:choose>
<xsl:when test="$datatypeValue='string'">
<xsl:element name="{fn:substring-before($tagName,'^^')}">
<xsl:value-of select="$tagValue"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{fn:substring-before($tagName,'^^')}">
<xsl:attribute name="rdf:datatype">
<xsl:value-of select="fn:concat($expandedDatatypePrefix,$datatypeValue)"/>
</xsl:attribute>
<xsl:value-of select="$tagValue"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="fn:contains($tagName, '&lt;&gt;')">
<xsl:variable name="tagPrefix" select="fn:substring-before($tagName, ':')"/>
<xsl:element name="{fn:substring-before($tagName,'&lt;&gt;')}">
<xsl:attribute name="rdf:resource">
<xsl:value-of select="$tagValue"/>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$tagName}">
<xsl:attribute name="xml:lang">
Expand Down
4 changes: 3 additions & 1 deletion test/ePO-default-config/config-parameters.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
</xd:doc>



<!-- a set of prefix-baseURI definitions -->
<xsl:variable name="namespacePrefixes" select="fn:doc('namespaces.xml')"/>

Expand Down Expand Up @@ -82,6 +81,9 @@
<xsl:variable name="generateReusedConceptsOWLcore" select="fn:true()"/>
<xsl:variable name="generateReusedConceptsOWLrestrictions" select="fn:true()"/>
<xsl:variable name="generateReusedConceptsGlossary" select="fn:true()"/>

<xsl:variable name="commentsGeneration" select="fn:false()"/>
<xsl:variable name="commentProperty" select="'skos:editorialNote'"/>

<!-- This variable control if Object and Realisation are generated -->
<xsl:variable name="generateObjectsAndRealisations" select="fn:false()"/>
Expand Down
7 changes: 7 additions & 0 deletions test/unitTests/test-common/test-fetchers.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@
<x:expect label="no tags" select="()"/>
</x:scenario>

<x:scenario label="Get connector tags ">
<x:call function="f:getConnectorTags">
<x:param name="element" href="../../testData/ePO_core_with_tags.xml" select="/xmi:XMI/xmi:Extension[1]/connectors[1]/connector[92]"/>
</x:call>
<x:expect label="correct tags number" test="count(/tag)=8"/>
</x:scenario>

<x:scenario label="Get connector role name value - Source -> Destination">
<x:call function="f:getRoleNameFromConnector">
<x:param name="connector" href="../../testData/ePO-CM-v2.0.1-2020-03-27_test.eap.xmi" select="/xmi:XMI/xmi:Extension[1]/connectors[1]/connector[21]"/>
Expand Down
46 changes: 46 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 @@ -92,5 +92,51 @@
</x:scenario>


<x:scenario
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
label="Scenario for testing generation of tags - with datatypes - string ">

<x:call template="coreLayerTags">
<x:param name="tagName" select="'skos:historyNote^^xsd:string'"/>
<x:param name="tagValue" select="'Something related with history'"/>
<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="correct skos:historyNote text"
test="/rdf:Description/skos:historyNote/text() = 'Something related with history'" />
</x:scenario>



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

<x:call template="coreLayerTags">
<x:param name="tagName" select="'skos:indentifier&lt;&gt;'"/>
<x:param name="tagValue" select="'http://base.onto.uri/URI'"/>
<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="correct skos:indentifier/@rdf:resource text" test="rdf:Description/skos:indentifier/@rdf:resource = 'http://base.onto.uri/URI'"/>
</x:scenario>


<x:scenario
label="Scenario for testing generation of comments">

<x:call template="coreLayerComment">
<x:param name="comment" select="'This is a comment'"/>
<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="correct skos:editorialNote text" test="rdf:Description/skos:editorialNote/text() = 'This is a comment'"/>
</x:scenario>

</x:description>

0 comments on commit af5d923

Please sign in to comment.