Skip to content

Commit

Permalink
added extra config parameter and extended generalisations output logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragos0000 committed Nov 8, 2023
1 parent d9dbd13 commit d1cbaed
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 52 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
56 changes: 29 additions & 27 deletions src/owl-core-lib/connectors-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,36 @@
<xd:desc/>
</xd:doc>
<xsl:template match="connector[./properties/@ea_type = 'Generalization']">
<xsl:if test="f:checkIfConnectorTargetAndSourceElementsExists(.)">
<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="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
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:if
test="
./source/model/@type = 'ProxyConnector' and
./target/model/@type = 'ProxyConnector'">
<xsl:call-template name="propertyGeneralization"/>
</xsl:if>
<xsl:if
test="
./source/model/@type = 'Class' and
./target/model/@type = 'Class'">
<xsl:call-template name="classGeneralization"/>
</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>-->
</xsl:template>

<xd:doc>
Expand Down Expand Up @@ -251,7 +253,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
5 changes: 5 additions & 0 deletions src/owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,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
3 changes: 3 additions & 0 deletions src/owl-restrictions.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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
38 changes: 22 additions & 16 deletions src/reasoning-layer-lib/connectors-reasoning-layer.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</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>
Expand All @@ -76,7 +76,7 @@
<xsl:call-template name="disjointClasses">
<xsl:with-param name="generalisation" select="."/>
</xsl:call-template>
</xsl:if>
<!--</xsl:if>-->
</xsl:template>


Expand Down Expand Up @@ -604,21 +604,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

0 comments on commit d1cbaed

Please sign in to comment.