Skip to content

Commit

Permalink
Merge pull request #191 from OP-TED/feature/EPO-840
Browse files Browse the repository at this point in the history
added extra config for metadata and extended generalisation output logic
  • Loading branch information
Dragos0000 authored Nov 9, 2023
2 parents d9dbd13 + cfed829 commit f728296
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 61 deletions.
15 changes: 9 additions & 6 deletions src/common/fetchers.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@
<xd:desc>Get the superClass from using a generalization</xd:desc>
<xd:param name="generalization"/>
</xd:doc>
<xsl:function name="f:getSuperClassFromGeneralization">
<xsl:function name="f:getSuperClassFromGeneralization" as="xs:string*">
<xsl:param name="generalization" as="node()"/>
<!--<xsl:variable name="root" select="root($element)"/>-->
<xsl:variable name="superClassId" select="$generalization/target/@xmi:idref" as="xs:string"/>
<xsl:sequence select="f:getElementByIdRef($superClassId,root($generalization))"/>
<!-- <xsl:variable name="superClassQname" select="$generalization/target/@xmi:idref" as="xs:string"/>-->
<xsl:value-of select="$generalization/target/model/@name"/>
<!-- /xmi:XMI/xmi:Extension/connectors/connector[./properties/@ea_type = 'Generalization'][target/@xmi:idref='EAID_E84B97D8_2656_498d_B584_D95C2DBBD7A1']/source/model/@name-->

</xsl:function>
Expand All @@ -140,9 +140,12 @@
<xsl:function name="f:getSubClassesFromGeneralization">
<xsl:param name="generalization" as="node()"/>
<xsl:variable name="root" select="root($generalization)"/>
<xsl:variable name="superClassId" select="f:getSuperClassFromGeneralization($generalization)/@xmi:idref" as="xs:string"/>
<xsl:variable name="subClassesId" select="$root//connectors/connector[./properties/@ea_type = 'Generalization' and target/@xmi:idref=$superClassId]/source/@xmi:idref
"/>
<!-- <xsl:variable name="superClassId" select="f:getSuperClassFromGeneralization($generalization)/@xmi:idref" as="xs:string"/>-->
<xsl:variable name="subClassesId"
select="
$root//connectors/connector[./properties/@ea_type = 'Generalization' and target/model/@name = f:getSuperClassFromGeneralization($generalization)]/source/@xmi:idref
"
/>
<xsl:sequence
select="
for $id in $subClassesId
Expand Down
67 changes: 41 additions & 26 deletions src/owl-core-lib/connectors-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,49 @@
<xd:desc/>
</xd:doc>
<xsl:template match="connector[./properties/@ea_type = 'Generalization']">
<xsl:if test="f:checkIfConnectorTargetAndSourceElementsExists(.)">
<!-- <xsl:if test="f:checkIfConnectorTargetAndSourceElementsExists(.)">-->
<xsl:if test="f:connectorToReusedClasses(.) and $generateReusedConcepts">
<xsl:if
test="
./source/model/@type = 'ProxyConnector' and
./target/model/@type = 'ProxyConnector'">
<xsl:call-template name="propertyGeneralization"/>
</xsl:if>
</xsl:if>
<xsl:if test="not(f:connectorToReusedClasses(.))">
<xsl:if
test="
./source/model/@type = 'ProxyConnector' and
./target/model/@type = 'ProxyConnector'">
<xsl:call-template name="propertyGeneralization"/>
</xsl:if>
</xsl:if>
<!-- </xsl:if>-->
</xsl:template>

<xd:doc>
<xd:desc>Applying core layer rules to generalisation connectors with distinct targets</xd:desc>
</xd:doc>
<xsl:template name="generalisationsWithDistinctTargetsInCoreLayer">
<xsl:variable name="generalisations" select="//connector[./properties/@ea_type = 'Generalization'][not(target/@xmi:idref = preceding::connector[./properties/@ea_type = 'Generalization']/target/@xmi:idref)]"/>
<xsl:for-each select="$generalisations">
<xsl:if test="f:connectorToReusedClasses(.) and $generateReusedConcepts">
<xsl:choose>
<xsl:when
test="
./source/model/@type = 'ProxyConnector' and
./target/model/@type = 'ProxyConnector'">
<xsl:call-template name="propertyGeneralization"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="classGeneralization"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if
test="
./source/model/@type = 'Class' and
./target/model/@type = 'Class'">
<xsl:call-template name="classGeneralization"/>
</xsl:if>
</xsl:if>
<xsl:if test="not(f:connectorToReusedClasses(.))">
<xsl:choose>
<xsl:when
test="
./source/model/@type = 'ProxyConnector' and
./target/model/@type = 'ProxyConnector'">
<xsl:call-template name="propertyGeneralization"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="classGeneralization"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
<xsl:if
test="
./source/model/@type = 'Class' and
./target/model/@type = 'Class'">
<xsl:call-template name="classGeneralization"/>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>

<xd:doc>
Expand Down Expand Up @@ -251,7 +266,7 @@

<xsl:template name="classGeneralization">
<xsl:variable name="superClass" select="f:getSuperClassFromGeneralization(.)"/>
<xsl:variable name="superClassURI" select="f:buildURIFromElement($superClass)"/>
<xsl:variable name="superClassURI" select="f:buildURIfromLexicalQName($superClass)"/>
<xsl:variable name="subClasses" select="f:getSubClassesFromGeneralization(.)"/>
<xsl:if test="f:getElementByIdRef(./source/@xmi:idref, root(.))">

Expand Down
6 changes: 6 additions & 0 deletions src/owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
</xsl:for-each>
<xsl:call-template name="ontology-header"/>
<xsl:apply-templates/>
<xsl:call-template name="generalisationsWithDistinctTargetsInCoreLayer"/>
<xsl:call-template name="connectorsOwlCore"/>
<xsl:call-template name="generatePropertiesFromDistinctAttributeNamesInCore"/>
</rdf:RDF>
Expand All @@ -69,6 +70,11 @@
<dct:title xml:lang="en">
<xsl:value-of select="$ontologyTitleCore"/>
</dct:title>

<rdfs:label xml:lang="en">
<xsl:value-of select="$ontologyLabelCore"/>
</rdfs:label>

<dct:description xml:lang="en">
<xsl:value-of select="$ontologyDescriptionCore"/>
</dct:description>
Expand Down
4 changes: 4 additions & 0 deletions src/owl-restrictions.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

<xsl:call-template name="ontology-header"/>
<xsl:apply-templates/>
<xsl:call-template name="generalisationsWithDistinctTargetsInReasoningLayer"/>
<xsl:call-template name="distinctAttributeNamesInReasoningLayer"/>
<xsl:call-template name="distinctConnectorsNamesInReasoningLayer"/>
</rdf:RDF>
Expand All @@ -64,6 +65,9 @@
<dct:title xml:lang="en">
<xsl:value-of select="$ontologyTitleRestrictions"/>
</dct:title>
<rdfs:label xml:lang="en">
<xsl:value-of select="$ontologyLabelRestrictions"/>
</rdfs:label>
<dct:publisher>
<xsl:value-of select="$publisher"/>
</dct:publisher>
Expand Down
51 changes: 34 additions & 17 deletions src/reasoning-layer-lib/connectors-reasoning-layer.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,30 @@
</xd:doc>

<xsl:template match="connector[./properties/@ea_type = 'Generalization']">
<xsl:if test="f:checkIfConnectorTargetAndSourceElementsExists(.)">
<!-- <xsl:if test="f:checkIfConnectorTargetAndSourceElementsExists(.)">-->
<xsl:call-template name="classEquivalence">
<xsl:with-param name="generalisation" select="."/>
</xsl:call-template>
<xsl:call-template name="propertiesEquivalence">
<xsl:with-param name="generalisation" select="."/>
</xsl:call-template>

<!--</xsl:if>-->
</xsl:template>

<xd:doc>
<xd:desc>Applying reasoning layer rules to generalisation connectors with distinct targets</xd:desc>
</xd:doc>
<xsl:template name="generalisationsWithDistinctTargetsInReasoningLayer">
<xsl:variable name="generalisations" select="//connector[./properties/@ea_type = 'Generalization'][not(target/@xmi:idref = preceding::connector[./properties/@ea_type = 'Generalization']/target/@xmi:idref)]"/>
<xsl:for-each select="$generalisations">
<xsl:call-template name="disjointClasses">
<xsl:with-param name="generalisation" select="."/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>




<xd:doc>
<xd:desc>Applying reasoning layer rules to connectors with distinct names [Dependency and
Expand Down Expand Up @@ -604,21 +615,27 @@

<xsl:template name="disjointClasses">
<xsl:param name="generalisation"/>
<xsl:variable name="superClass" select="f:getSuperClassFromGeneralization($generalisation)"/>
<xsl:variable name="superClassURI" select="f:buildURIFromElement($superClass)"/>
<xsl:variable name="subClasses" select="f:getSubClassesFromGeneralization($generalisation)"/>
<xsl:if test="f:getElementByIdRef($generalisation/source/@xmi:idref, root($generalisation)) and count($subClasses) > 1">

<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<xsl:for-each select="$subClasses">
<xsl:variable name="subClassURI" select="f:buildURIFromElement(.)"/>
<rdf:Description rdf:about="{$subClassURI}"/>
</xsl:for-each>
</owl:members>
</rdf:Description>
<xsl:if
test="$generalisation/source/model/@type = 'Class' and $generalisation/target/model/@type = 'Class'">
<xsl:variable name="superClass"
select="f:getSuperClassFromGeneralization($generalisation)"/>
<xsl:variable name="superClassURI" select="f:buildURIfromLexicalQName($superClass)"/>
<xsl:variable name="subClasses"
select="f:getSubClassesFromGeneralization($generalisation)"/>
<xsl:if
test="f:getElementByIdRef($generalisation/source/@xmi:idref, root($generalisation)) and count($subClasses) > 1">

<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<xsl:for-each select="$subClasses">
<xsl:variable name="subClassURI" select="f:buildURIFromElement(.)"/>
<rdf:Description rdf:about="{$subClassURI}"/>
</xsl:for-each>
</owl:members>
</rdf:Description>

</xsl:if>
</xsl:if>
</xsl:template>

Expand Down
3 changes: 3 additions & 0 deletions src/shacl-shapes.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<dct:title xml:lang="en">
<xsl:value-of select="$ontologyTitleShapes"/>
</dct:title>
<rdfs:label xml:lang="en">
<xsl:value-of select="$ontologyLabelShapes"/>
</rdfs:label>
<dct:publisher>
<xsl:value-of select="$publisher"/>
</dct:publisher>
Expand Down
20 changes: 20 additions & 0 deletions test/ePO-default-config/config-parameters.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,38 @@
This artefact excludes the restrictions.
The eProcurement Ontology describes objects and concepts, with definitions, attributes and relationships which are present within the European public procurement domain.
The provision of these concepts provides the basis for a common understanding of the domain for all stakeholders ensuring the quality of data exchange and transparency.'"/>
<xsl:variable name="ontologyLabelCore"
select="
'This artefact provides the definitions for the eProcurement Ontology Core.
This artefact excludes the restrictions.
The eProcurement Ontology describes objects and concepts, with definitions, attributes and relationships which are present within the European public procurement domain.
The provision of these concepts provides the basis for a common understanding of the domain for all stakeholders ensuring the quality of data exchange and transparency.'"/>

<xsl:variable name="ontologyDescriptionRestrictions"
select="
'This artefact provides the restrictions and inference-related specifications for the eProcurement Ontology Core.
This artefact excludes the definitions of concepts.
The eProcurement Ontology describes objects and concepts, with definitions, attributes and relationships which are present within the European public procurement domain.
The provision of these concepts provides the basis for a common understanding of the domain for all stakeholders ensuring the quality of data exchange and transparency.'"/>
<xsl:variable name="ontologyLabelRestrictions"
select="
'This artefact provides the restrictions and inference-related specifications for the eProcurement Ontology Core.
This artefact excludes the definitions of concepts.
The eProcurement Ontology describes objects and concepts, with definitions, attributes and relationships which are present within the European public procurement domain.
The provision of these concepts provides the basis for a common understanding of the domain for all stakeholders ensuring the quality of data exchange and transparency.'"/>

<xsl:variable name="ontologyDescriptionShapes"
select="
'This artefact provides the generic datashape specifications for the eProcurement Ontology Core.
The eProcurement Ontology describes objects and concepts, with definitions, attributes and relationships which are present within the European public procurement domain.
The provision of these concepts provides the basis for a common understanding of the domain for all stakeholders ensuring the quality of data exchange and transparency.'"/>

<xsl:variable name="ontologyLabelShapes"
select="
'This artefact provides the generic datashape specifications for the eProcurement Ontology Core.
The eProcurement Ontology describes objects and concepts, with definitions, attributes and relationships which are present within the European public procurement domain.
The provision of these concepts provides the basis for a common understanding of the domain for all stakeholders ensuring the quality of data exchange and transparency.'"/>

<!-- rdfs:seeAlso -->
<xsl:variable name="seeAlsoResources"
select="
Expand Down
4 changes: 2 additions & 2 deletions test/ePO-default-config/xsdAndRdfDataTypes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<datatype namespace="rdf" qname="rdf:XMLLiteral"/>
<datatype namespace="rdf" qname="rdf:langString"/>

<datatype namespace="rdfs" qname="rdfs:Literal"/>

<datatype namespace="rdf" qname="rdf:PlainLiteral"/>

</datatypes>
2 changes: 1 addition & 1 deletion test/unitTests/test-common/test-fetchers.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<x:param name="element" href="../../testData/ePO-CM-v2.0.2-2020-05-17_test.eap.xmi"
select="/xmi:XMI/xmi:Extension[1]/connectors[1]/connector[43]"/>
</x:call>
<x:expect label="result" test="boolean(element)"/>
<x:expect label="result" select="'epo:Agent'"/>
</x:scenario>

<x:scenario label="get sub Classes using a generalization and super Class">
Expand Down
14 changes: 5 additions & 9 deletions test/unitTests/test-owl-core-lib/test-connectors-owl-core.xspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uml="http://www.omg.org/spec/UML/20131001"
xmlns:xmi="http://www.omg.org/spec/XMI/20131001"
xmlns:umldi="http://www.omg.org/spec/UML/20131001/UMLDI"
Expand All @@ -24,17 +25,12 @@
/>
</x:scenario>

<x:scenario
label="Scenario for testing template with match 'connector[./properties/@ea_type = 'Generalization'] - Classes">
<x:context href="../../testData/ePO-CM_v.3.0.1.eap.xmi"
select="/xmi:XMI/xmi:Extension[1]/connectors[1]/connector[114]"/>
<x:expect label="result" test="boolean(/owl:Class)"/>
<x:expect label="result" test="boolean(/owl:Class/rdfs:subClassOf)"/>
</x:scenario>


<x:scenario
label="Scenario for testing template with match 'connector[./properties/@ea_type = 'Generalization']">
<x:context href="../../testData/ePO-CM-v2.0.1-2022-04-29_test.eap.xmi" select="/xmi:XMI/xmi:Extension[1]/*[namespace-uri()='' and local-name()='connectors'][1]/*[namespace-uri()='' and local-name()='connector'][4]"/>
label="Test generalisationsWithDistinctTargetsInCoreLayer">
<x:context href="../../testData/ePO-CM-v2.0.1-2022-04-29_test.eap.xmi"/>
<x:call template="generalisationsWithDistinctTargetsInCoreLayer"/>
<x:expect label="result" test="boolean(/owl:Class)"/>
<x:expect label="result" test="/owl:Class/@rdf:about='http://data.europa.eu/a4g/ontology#ElementChangeSpecification'"/>
</x:scenario>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@

</x:scenario>

<x:scenario
label="Test generalisationsWithDistinctTargetsInReasoningLayer">
<x:context href="../../testData/ePO-CM-v2.0.1-2022-04-29_test.eap.xmi"/>
<x:call template="generalisationsWithDistinctTargetsInReasoningLayer"/>
<x:expect label="result" test="boolean(/rdf:Description/rdf:type[@rdf:resource='http://www.w3.org/2002/07/owl#AllDisjointClasses'])"/>
</x:scenario>

<x:scenario
label="Scenario for testing template with match 'connector[./properties/@ea_type = 'Association']">
<x:context href="../../testData/ePO-CM_v.3.0.1.eap.xmi"
Expand Down

0 comments on commit f728296

Please sign in to comment.