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

rule for floating comments #176

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions src/common/selectors.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
<xsl:template match="xmi:XMI">
<xsl:apply-templates select="/xmi:XMI/xmi:Extension/elements"/>
<xsl:apply-templates select="/xmi:XMI/xmi:Extension/connectors"/>
<xsl:apply-templates select="/xmi:XMI/uml:Model/packagedElement//ownedComment"/>
</xsl:template>

<xd:doc>
<xd:desc>This template target floating comments in the model</xd:desc>
</xd:doc>
<xsl:template match="ownedComment">
<xsl:apply-templates select="ownedComment[@xmi:type='uml:Comment']"/>
</xsl:template>

<xd:doc>
Expand Down
2 changes: 1 addition & 1 deletion src/owl-core-lib/connectors-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
<xsl:with-param name="elementUri" select="$roleURI"/>
</xsl:call-template>
</xsl:if>
<!-- TODO ADD COMMENT RULE T05-->

<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$roleURI"/>
</xsl:call-template>
Expand Down
6 changes: 3 additions & 3 deletions src/owl-core-lib/descriptors-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</xsl:template>

<xd:doc>
<xd:desc>Rule T.05. Comment - Specify annotation axiom for UML Comment associated to a UML
<xd:desc>Rule T.06. Comment - Specify annotation axiom for UML Comment associated to a UML
element</xd:desc>
<xd:param name="comment"/>
<xd:param name="elementUri"/>
Expand All @@ -64,9 +64,9 @@
<xsl:param name="comment"/>
<xsl:param name="elementUri"/>
<rdf:Description rdf:about="{$elementUri}">
<rdfs:comment xml:lang="en">
<skos:editorialNote xml:lang="en">
<xsl:value-of select="$comment"/>
</rdfs:comment>
</skos:editorialNote>
</rdf:Description>
</xsl:template>

Expand Down
81 changes: 73 additions & 8 deletions src/owl-core-lib/elements-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,74 @@
<xsl:output method="xml" encoding="UTF-8" byte-order-mark="no" indent="yes"
cdata-section-elements="lines"/>

<xd:doc>
<xd:desc> Rule T.05. Comment — in core ontology layer. Specify an annotation axiom (comment or editorial note)
on the OWL entity for the UML Comment associated to a UML element.
Selector to run core layer transfomation rules for commnents </xd:desc>
</xd:doc>
<xsl:template match="ownedComment[@xmi:type='uml:Comment']">
<xsl:variable name="commentText" select="./@body"/>
<xsl:for-each select="./annotatedElement/@xmi:idref">
<xsl:variable name="elementFound" select="f:getElementByIdRef(.,root(.))"/>
<xsl:if test="boolean($elementFound)">
<xsl:variable name="elementUri" select="f:buildURIFromElement($elementFound)"/>
<xsl:call-template name="coreLayerComment">
<xsl:with-param name="elementUri" select="$elementUri"/>
<xsl:with-param name="comment" select="$commentText"/>
</xsl:call-template>
</xsl:if>
<xsl:variable name="connectorFound" select="f:getConnectorByIdRef(.,root(.))"/>
<xsl:if test="fn:boolean($connectorFound)">
<xsl:variable name="connectorDirection"
select="$connectorFound/properties/@direction"/>
<xsl:choose>
<xsl:when test="$connectorDirection = 'Source -&gt; Destination'">
<xsl:variable name="connectorTargetRoleUri"
select="
if ($connectorFound/target/role/not(@name) = fn:true()) then
()
else
f:buildURIfromLexicalQName($connectorFound/target/role/@name)"/>
<xsl:if test="boolean($connectorTargetRoleUri)">
<xsl:call-template name="coreLayerComment">
<xsl:with-param name="elementUri" select="$connectorTargetRoleUri"/>
<xsl:with-param name="comment" select="$commentText"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="connectorTargetRoleUri"
select="
if ($connectorFound/target/role/not(@name) = fn:true()) then
()
else
f:buildURIfromLexicalQName($connectorFound/target/role/@name)"/>
<xsl:variable name="connectorSourceRoleUri"
select="
if ($connectorFound/source/role/not(@name) = fn:true()) then
()
else
f:buildURIfromLexicalQName($connectorFound/source/role/@name)"/>
<xsl:if test="boolean($connectorSourceRoleUri)">
<xsl:call-template name="coreLayerComment">
<xsl:with-param name="elementUri" select="$connectorSourceRoleUri"/>
<xsl:with-param name="comment" select="$commentText"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="boolean($connectorTargetRoleUri)">
<xsl:call-template name="coreLayerComment">
<xsl:with-param name="elementUri" select="$connectorTargetRoleUri"/>
<xsl:with-param name="comment" select="$commentText"/>
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:template>




<xd:doc>
<xd:desc> Selector to run core layer transformation rules for classes</xd:desc>
Expand Down Expand Up @@ -68,8 +136,7 @@
<xsl:with-param name="elementUri" select="$classURI"/>
</xsl:call-template>
</xsl:if>
<!-- TODO ADD COMMENT RULE T05-->


<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$classURI"/>
</xsl:call-template>
Expand Down Expand Up @@ -182,7 +249,6 @@
</xsl:call-template>
</xsl:if>

<!-- TODO ADD COMMENT RULE T05-->

<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$attributeURI"/>
Expand Down Expand Up @@ -248,7 +314,6 @@
<xsl:with-param name="elementUri" select="$dataTypeURI"/>
</xsl:call-template>
</xsl:if>
<!-- TODO ADD COMMENT RULE T05-->

<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$dataTypeURI"/>
Expand Down Expand Up @@ -285,7 +350,7 @@
<xsl:with-param name="elementUri" select="$conceptSchemeURI"/>
</xsl:call-template>
</xsl:if>
<!-- TODO ADD COMMENT RULE T05-->


<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$conceptSchemeURI"/>
Expand All @@ -304,7 +369,7 @@
<xsl:with-param name="elementUri" select="$conceptSchemeURI"/>
</xsl:call-template>
</xsl:if>
<!-- TODO ADD COMMENT RULE T05-->


<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$conceptSchemeURI"/>
Expand Down Expand Up @@ -351,7 +416,7 @@
<xsl:with-param name="elementUri" select="$enumerationAttributeURI"/>
</xsl:call-template>
</xsl:if>
<!-- TODO ADD COMMENT RULE T05-->


<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$enumerationAttributeURI"/>
Expand All @@ -374,7 +439,7 @@
<xsl:with-param name="elementUri" select="$enumerationAttributeURI"/>
</xsl:call-template>
</xsl:if>
<!-- TODO ADD COMMENT RULE T05-->


<xsl:call-template name="coreDefinedBy">
<xsl:with-param name="elementUri" select="$enumerationAttributeURI"/>
Expand Down
75 changes: 75 additions & 0 deletions src/shacl-shape-lib/elements-shacl-shape.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,81 @@

<xsl:output method="xml" encoding="UTF-8" byte-order-mark="no" indent="yes"
cdata-section-elements="lines"/>


<xd:doc>
<xd:desc> Rule T.06. Comment — in data shape layer. Specify an annotation axiom (comment or description)
on the SHACL shape for the UML Comment associated to a UML element.
Selector to run core layer transfomation rules for commnents </xd:desc>
</xd:doc>
<xsl:template match="ownedComment[@xmi:type='uml:Comment']">
<xsl:variable name="commentText" select="./@body"/>
<xsl:for-each select="./annotatedElement/@xmi:idref">
<xsl:variable name="elementFound" select="f:getElementByIdRef(.,root(.))"/>
<xsl:if test="boolean($elementFound)">
<xsl:variable name="elementUri" select="f:buildShapeURI($elementFound/@name)"/>
<xsl:call-template name="shapeLayerComment">
<xsl:with-param name="uri" select="$elementUri"/>
<xsl:with-param name="rdfsComment" select="fn:true()"/>
<xsl:with-param name="comment" select="$commentText"/>
</xsl:call-template>
</xsl:if>
<xsl:variable name="connectorFound" select="f:getConnectorByIdRef(.,root(.))"/>
<xsl:if test="fn:boolean($connectorFound)">
<xsl:variable name="connectorDirection"
select="$connectorFound/properties/@direction"/>
<xsl:choose>
<xsl:when test="$connectorDirection = 'Source -&gt; Destination'">
<xsl:variable name="connectorShapeUri"
select="
if ($connectorFound/target/role/not(@name) = fn:true()) then
()
else
f:buildPropertyShapeURI($connectorFound/source/model/@name,$connectorFound/target/role/@name)"/>
<xsl:if test="boolean($connectorShapeUri)">
<xsl:call-template name="shapeLayerComment">
<xsl:with-param name="uri" select="$connectorShapeUri"/>
<xsl:with-param name="comment" select="$commentText"/>
<xsl:with-param name="rdfsComment" select="fn:false()"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="connectorTargetRoleShapeUri"
select="
if ($connectorFound/target/role/not(@name) = fn:true()) then
()
else
f:buildPropertyShapeURI($connectorFound/source/model/@name,$connectorFound/target/role/@name)"/>
<xsl:variable name="connectorSourceRoleShapeUri"
select="
if ($connectorFound/source/role/not(@name) = fn:true()) then
()
else
f:buildPropertyShapeURI($connectorFound/target/model/@name,$connectorFound/source/role/@name)"/>
<xsl:if test="boolean($connectorSourceRoleShapeUri)">
<xsl:call-template name="shapeLayerComment">
<xsl:with-param name="uri" select="$connectorSourceRoleShapeUri"/>
<xsl:with-param name="comment" select="$commentText"/>
<xsl:with-param name="rdfsComment" select="fn:false()"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="boolean($connectorTargetRoleShapeUri)">
<xsl:call-template name="shapeLayerComment">
<xsl:with-param name="uri" select="$connectorTargetRoleShapeUri"/>
<xsl:with-param name="comment" select="$commentText"/>
<xsl:with-param name="rdfsComment" select="fn:false()"/>
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:template>






<xd:doc>
Expand Down
Loading