Skip to content

Commit

Permalink
status filtering function
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragos0000 committed Jan 15, 2025
1 parent f6c70f1 commit 71d305c
Show file tree
Hide file tree
Showing 4 changed files with 55,528 additions and 1 deletion.
46 changes: 46 additions & 0 deletions src/common/utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -632,5 +632,51 @@
<xsl:namespace name="{./@name}" select="./@value"/>
</xsl:for-each>
</xsl:template>

<xd:doc>
<xd:desc>This template will return true or false if the an element should be filtered or not by looking at
the status value
:nodeInput can be an element or connector
</xd:desc>
<xd:param name="nodeInput"/>
</xd:doc>

<xsl:function name="f:isExcludedByStatus">
<xsl:param name="nodeInput" as="node()*"/>

<!-- Get all tags for the element -->
<xsl:variable name="tags"
select="
if (local-name($nodeInput) = 'connector') then
f:getConnectorTags($nodeInput)
else
f:getElementTags($nodeInput)"/>

<!-- Find the status tag -->
<xsl:variable name="statusTag" select="
for $tag in $tags
return if ($tag/@name = $statusProperty) then $tag else ()"/>
<xsl:message>Status Tag: <xsl:copy-of select="$statusTag"/></xsl:message>
<!-- Extract the value of the status tag -->
<xsl:variable name="statusValue" select="$statusTag/@value"/>

<!-- Validation: Ensure statusValue is in validStatusesList -->
<xsl:if test="$statusValue and not($statusValue = $validStatusesList)">
<xsl:message terminate="yes"> Error: Invalid status value "<xsl:value-of
select="$statusValue"/>" for element with ID "<xsl:value-of
select="$nodeInput/@xmi:id"/>". Allowed values are: <xsl:value-of
select="string-join($validStatusesList, ', ')"/>. </xsl:message>
</xsl:if>
<xsl:message><xsl:value-of select="fn:concat('Status is ', $statusValue)"/></xsl:message>
<!-- Determine if the element should be excluded -->
<xsl:sequence
select="
if (not($statusValue)) then
$unspecifiedStatusInterpretation = $excludedElementStatusesList
else
$statusValue = $excludedElementStatusesList
"
/>
</xsl:function>

</xsl:stylesheet>
7 changes: 7 additions & 0 deletions test/ePO-default-config/config-parameters.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@

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

<!-- Variables for status filtering -->
<xsl:variable name="statusProperty" select="'epo:status'"/>
<xsl:variable name="validStatusesList" select="('proposed', 'approved', 'implemented')"/>
<xsl:variable name="excludedElementStatusesList" select="('proposed', 'approved')"/>
<xsl:variable name="unspecifiedStatusInterpretation" select="'implemented'"/>


<!-- This variable control if Object and Realisation are generated -->
<xsl:variable name="generateObjectsAndRealisations" select="fn:false()"/>
Expand Down
Loading

0 comments on commit 71d305c

Please sign in to comment.