Skip to content

Commit

Permalink
refactored and added extra config parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragos0000 committed May 18, 2022
1 parent ece5526 commit a557690
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 20 deletions.
1 change: 1 addition & 0 deletions config/ePO-default/config-parameters.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,6 @@
<xsl:variable name="title-restriction-module">eProcurement extended ontology</xsl:variable>
<xsl:variable name="description-restriction-module">This module provides the inference-related definitions for
the eProcurement ontology.</xsl:variable>
<xsl:variable name="reference-to-external-classes-in-glossary" select="fn:false()"/>

</xsl:stylesheet>
71 changes: 67 additions & 4 deletions src/common/utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@
xs:anyURI(fn:concat(fn:namespace-uri-from-QName($qname), fn:local-name-from-QName($qname)))
else
xs:anyURI(fn:concat(fn:namespace-uri-from-QName($qname), $defaultDelimiter, fn:local-name-from-QName($qname)))
"/>
"
/>
</xsl:function>

<xd:doc>
Expand Down Expand Up @@ -269,7 +270,7 @@
$localName
"/>
<xsl:sequence
select="f:buildURIFromNode($attribute, fn:concat($prefix,':',$expandedLocalName), $isPascalCase, $isDefaultNamespaceContextualised)"
select="f:buildURIFromNode($attribute, fn:concat($prefix, ':', $expandedLocalName), $isPascalCase, $isDefaultNamespaceContextualised)"
/>
</xsl:function>

Expand Down Expand Up @@ -301,7 +302,8 @@
else
concat($defaultNamespacePrefix, ':', $elementName)"/>

<xsl:sequence select="f:buildURIfromLexicalQName($normalisedElementName, $isPascalCase, fn:true())"/>
<xsl:sequence
select="f:buildURIfromLexicalQName($normalisedElementName, $isPascalCase, fn:true())"/>
</xsl:function>


Expand Down Expand Up @@ -435,7 +437,7 @@
$attributeMultiplicityValue"
/>
</xsl:function>

<xd:doc>
<xd:desc>Check if connector target and source are in the model</xd:desc>
<xd:param name="connector"/>
Expand All @@ -454,4 +456,65 @@
/>
</xsl:function>

<xd:doc>
<xd:desc>Check if the connector is used to or from external classes</xd:desc>
<xd:param name="connectorName"/>
</xd:doc>

<xsl:function name="f:connector-to-or-from-external-class">
<xsl:param name="connectorName"/>
<xsl:param name="root"/>
<xsl:variable name="connectorElements" select="f:getConnectorByName($connectorName, $root)"/>
<xsl:choose>
<xsl:when test="fn:count($connectorElements) > 1">
<xsl:variable name="targetClasses"
select="
for $connector in $connectorElements
return
if (f:getElementByIdRef($connector/target/@xmi:idref, $root)/@name) then
fn:true()
else
fn:false()"/>
<xsl:variable name="sourceClasses"
select="
for $connector in $connectorElements
return
if (f:getElementByIdRef($connector/source/@xmi:idref, $root)/@name) then
fn:true()
else
fn:false()"/>
<xsl:variable name="externalTargetClasses"
select="
every $i in $targetClasses
satisfies $i = fn:false()"/>
<xsl:variable name="externalSourceClasses"
select="
every $i in $sourceClasses
satisfies $i = fn:false()"/>
<xsl:sequence
select="
if ($externalSourceClasses or $externalTargetClasses) then
fn:true()
else
fn:false()"/>

</xsl:when>
<xsl:otherwise>
<xsl:variable name="targetClass"
select="f:getElementByIdRef($connectorElements/target/@xmi:idref, $root)/@name"/>
<xsl:variable name="sourceClass"
select="f:getElementByIdRef($connectorElements/source/@xmi:idref, $root)/@name"/>
<xsl:sequence
select="
if ($targetClass and $sourceClass) then
fn:false()
else
fn:true()"
/>
</xsl:otherwise>
</xsl:choose>


</xsl:function>

</xsl:stylesheet>
2 changes: 1 addition & 1 deletion src/html-model-glossary/fragments/footer.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

$("table.display").DataTable({
buttons: [],
"lengthMenu": [[-1], [30, "All"]],
"lengthMenu": [[-1], ["All"]],
responsive: {
details: true
}
Expand Down
77 changes: 62 additions & 15 deletions src/html-model-glossary/glossary.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@


<xsl:import href="../common/utils.xsl"/>
<xsl:import href="../common/formatters.xsl"/>
<xsl:import href="../common/fetchers.xsl"/>


<xsl:template name="glossary">
<h1>Model glossary</h1>
<h1>Glossary</h1>
<h2>Class names and definitions</h2>
<table class="display">
<thead class="center aligned">
Expand Down Expand Up @@ -75,7 +76,7 @@
</td>
<td>
<xsl:variable name="classElement" select="f:getElementByName(., $root)"/>
<xsl:value-of select="$classElement/properties/@documentation"/>
<xsl:value-of select="f:formatDocString($classElement/properties/@documentation)"/>
</td>
</tr>
</xsl:for-each>
Expand Down Expand Up @@ -113,7 +114,13 @@
<xsl:choose>
<xsl:when test="fn:count($attributesWithSameName) > 1">
<td>
<xsl:value-of select="$attributesWithSameName[0]/documentation/@value"/>

<xsl:value-of
select="
for $atribute in $attributesWithSameName
return
f:formatDocString($atribute/documentation/@value)"
/>
</td>
<td>
<xsl:for-each select="$attributesWithSameName">
Expand All @@ -136,7 +143,7 @@
<xsl:variable name="className"
select="$attributesWithSameName/parent::attributes/parent::element/@name"/>
<td>
<xsl:value-of select="$attributesWithSameName/documentation/@value"/>
<xsl:value-of select="f:formatDocString($attributesWithSameName/documentation/@value)"/>
</td>
<td>
<xsl:value-of select="$className"/>
Expand All @@ -154,24 +161,27 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template name="listOfConnectors">
<xsl:variable name="root" select="root()"/>
<xsl:variable name="connectorNames" select="f:getDistinctConnectorsNames($root)"/>
<xsl:for-each select="$connectorNames">
<xsl:sort select="." lang="en"/>
<xsl:if test="not(f:connector-to-or-from-external-class(., $root)) or $reference-to-external-classes-in-glossary">
<xsl:variable name="connectorName" select="."/>
<tr>
<td>
<xsl:value-of select="$connectorName"/>
<xsl:value-of select="f:connector-to-or-from-external-class(.,$root)"/>
</td>

<xsl:call-template name="connectorUsage">
<xsl:with-param name="connectorName" select="$connectorName"/>
<xsl:with-param name="root" select="$root"/>
</xsl:call-template>
</tr>
</xsl:if>
</xsl:for-each>
</xsl:template>

Expand All @@ -184,27 +194,54 @@
<xsl:when test="fn:count($connectorsWithSameName) > 1">
<td>
<xsl:value-of
select="fn:concat($connectorsWithSameName[0]/documentation/@value, $connectorsWithSameName[0]/source/documentation/@value, $connectorsWithSameName[0]/target/documentation/@value)"
select="
for $connector in $connectorsWithSameName
return
f:formatDocString(fn:concat($connector/documentation/@value, $connector/source/documentation/@value, $connector/target/documentation/@value))"
/>
</td>
<td>
<xsl:for-each select="$connectorsWithSameName">
<xsl:variable name="targetClass"
select="f:getElementByIdRef(./target/@xmi:idref, $root)/@name"/>
select="
if (f:getElementByIdRef(./target/@xmi:idref, $root)/@name) then
f:getElementByIdRef(./target/@xmi:idref, $root)/@name
else
if ($reference-to-external-classes-in-glossary) then
fn:concat(./target/model/@name, ' (external)')
else
()"/>
<xsl:variable name="sourceClass"
select="f:getElementByIdRef(./source/@xmi:idref, $root)/@name"/>
select="
if (f:getElementByIdRef(./source/@xmi:idref, $root)/@name) then
f:getElementByIdRef(./source/@xmi:idref, $root)/@name
else
if ($reference-to-external-classes-in-glossary) then
fn:concat(./source/model/@name, ' (external)')
else
()"/>
<xsl:variable name="targetMultiplicity" select="./target/type/@multiplicity"/>
<xsl:variable name="sourceMultiplicity" select="./source/type/@multiplicity"/>
<xsl:if test="./target/role/@name = $connectorName">

<xsl:value-of
select="fn:concat($sourceClass, ' -&gt; ', $targetClass, ' [', $targetMultiplicity, ']')"/>
select="
if ($sourceClass and $targetClass) then
fn:concat($sourceClass, ' -&gt; ', $targetClass, ' [', $targetMultiplicity, ']')
else
()"
/>
<br/>
</xsl:if>
<xsl:if test="./source/role/@name = $connectorName">

<xsl:value-of
select="fn:concat($sourceClass, ' [,', $sourceMultiplicity, ']', ' &lt;- ', $targetClass)"/>
select="
if ($sourceClass and $targetClass) then
fn:concat($sourceClass, ' [,', $sourceMultiplicity, ']', ' &lt;- ', $targetClass)
else
()"
/>
<br/>
</xsl:if>
</xsl:for-each>
Expand All @@ -213,7 +250,7 @@
<xsl:otherwise>
<td>
<xsl:value-of
select="fn:concat($connectorsWithSameName/documentation/@value, $connectorsWithSameName/source/documentation/@value, $connectorsWithSameName/target/documentation/@value)"
select="f:formatDocString(fn:concat($connectorsWithSameName/documentation/@value, $connectorsWithSameName/source/documentation/@value, $connectorsWithSameName/target/documentation/@value))"
/>
</td>

Expand All @@ -222,13 +259,19 @@
if (f:getElementByIdRef($connectorsWithSameName/target/@xmi:idref, $root)/@name) then
f:getElementByIdRef($connectorsWithSameName/target/@xmi:idref, $root)/@name
else
$connectorsWithSameName/target/model/@name"/>
if ($reference-to-external-classes-in-glossary) then
fn:concat($connectorsWithSameName/target/model/@name, ' (external)')
else
()"/>
<xsl:variable name="sourceClass"
select="
if (f:getElementByIdRef($connectorsWithSameName/source/@xmi:idref, $root)/@name) then
f:getElementByIdRef($connectorsWithSameName/source/@xmi:idref, $root)/@name
else
$connectorsWithSameName/source/model/@name"/>
if ($reference-to-external-classes-in-glossary) then
fn:concat($connectorsWithSameName/source/model/@name, ' (external)')
else
()"/>
<xsl:variable name="targetMultiplicity"
select="$connectorsWithSameName/target/type/@multiplicity"/>
<xsl:variable name="sourceMultiplicity"
Expand All @@ -243,7 +286,11 @@
<xsl:if test="$connectorsWithSameName/source/role/@name = $connectorName">
<td>
<xsl:value-of
select="fn:concat($sourceClass, ' [,', $sourceMultiplicity, ']', ' &lt;- ', $targetClass)"
select="
if ($sourceClass and $targetClass) then
fn:concat($sourceClass, ' [,', $sourceMultiplicity, ']', ' &lt;- ', $targetClass)
else
()"
/>
</td>
</xsl:if>
Expand Down

0 comments on commit a557690

Please sign in to comment.