Skip to content

Commit

Permalink
Merge branch 'OP-TED:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragos0000 committed Nov 17, 2023
2 parents cfb81f1 + f728296 commit 607a875
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 113 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
71 changes: 43 additions & 28 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 @@ -190,7 +205,7 @@
()"/>

<xsl:variable name="documentation"
select="f:formatDocString(fn:string-join($connectorDocumentations))"/>
select="fn:normalize-space(f:formatDocString(fn:string-join($connectorDocumentations)))"/>

<xsl:variable name="connectorNotes" as="xs:string*"
select="
Expand All @@ -204,7 +219,7 @@
else
()"/>

<xsl:variable name="note" select="f:formatDocString(fn:string-join($connectorNotes))"/>
<xsl:variable name="note" select="fn:normalize-space(f:formatDocString(fn:string-join($connectorNotes)))"/>


<owl:ObjectProperty rdf:about="{$roleURI}"/>
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
4 changes: 2 additions & 2 deletions src/owl-core-lib/descriptors-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<xsl:param name="elementUri"/>
<rdf:Description rdf:about="{$elementUri}">
<skos:definition xml:lang="en">
<xsl:value-of select="$definition"/>
<xsl:value-of select="fn:normalize-space($definition)"/>
</skos:definition>
</rdf:Description>
</xsl:template>
Expand All @@ -65,7 +65,7 @@
<xsl:param name="elementUri"/>
<rdf:Description rdf:about="{$elementUri}">
<skos:editorialNote xml:lang="en">
<xsl:value-of select="$comment"/>
<xsl:value-of select="fn:normalize-space($comment)"/>
</skos:editorialNote>
</rdf:Description>
</xsl:template>
Expand Down
10 changes: 5 additions & 5 deletions src/owl-core-lib/elements-owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<xsl:variable name="className" select="./@name"/>
<xsl:variable name="idref" select="./@xmi:idref"/>
<xsl:variable name="classURI" select="f:buildURIFromElement(.)"/>
<xsl:variable name="documentation" select="f:formatDocString(./properties/@documentation)"/>
<xsl:variable name="documentation" select="fn:normalize-space(f:formatDocString(./properties/@documentation))"/>

<owl:Class rdf:about="{$classURI}"/>

Expand Down Expand Up @@ -210,7 +210,7 @@
for $attribute in $attributesWithSameName
return
if ($attribute/documentation/@value) then
fn:concat(f:formatDocString($attribute/documentation/@value), ' (', $attribute/../../@name, ') ')
fn:concat(fn:normalize-space(f:formatDocString($attribute/documentation/@value)), ' (', $attribute/../../@name, ') ')
else
()"/>
<xsl:variable name="descriptionsWithAnnotations" as="xs:string"
Expand Down Expand Up @@ -316,7 +316,7 @@
<xsl:variable name="dataTypeName" select="./@name"/>
<xsl:variable name="idref" select="./@xmi:idref"/>
<xsl:variable name="dataTypeURI" select="f:buildURIFromElement(.)"/>
<xsl:variable name="documentation" select="f:formatDocString(./properties/@documentation)"/>
<xsl:variable name="documentation" select="fn:normalize-space(f:formatDocString(./properties/@documentation))"/>

<rdfs:Datatype rdf:about="{$dataTypeURI}"/>

Expand Down Expand Up @@ -357,7 +357,7 @@

<xsl:variable name="conceptSchemeURI" select="f:buildURIFromElement(.)"/>
<xsl:variable name="documentation"
select="f:formatDocString(./properties/@documentation)"/>
select="fn:normalize-space(f:formatDocString(./properties/@documentation))"/>


<xsl:if
Expand Down Expand Up @@ -437,7 +437,7 @@
./@name"/>
<xsl:variable name="enumerationAttributeURI" select="f:buildURIFromElement(.)"/>
<xsl:variable name="enumerationURI" select="f:buildURIFromElement(../..)"/>
<xsl:variable name="documentation" select="f:formatDocString(./documentation/@value)"/>
<xsl:variable name="documentation" select="fn:normalize-space(f:formatDocString(./documentation/@value))"/>

<xsl:if
test="not(fn:contains($enumerationAttributeURI, $base-ontology-uri)) and $generateReusedConcepts">
Expand Down
22 changes: 14 additions & 8 deletions src/owl-core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:vann="http://purl.org/vocab/vann/"
xmlns:cc="http://creativecommons.org/ns#"
exclude-result-prefixes="xs math xd xsl uml xmi umldi fn f"
exclude-result-prefixes="xs math xd xsl uml xmi umldi fn f bibo"
version="3.0">


Expand Down Expand Up @@ -52,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 @@ -70,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 All @@ -82,17 +87,18 @@
<rdfs:seeAlso rdf:resource="{.}"/>
</xsl:for-each>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date"><xsl:value-of select="$issuedDate"/></dct:issued>
<dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#date"><xsl:value-of select="$createdDate"/></dct:created>
<owl:versionInfo><xsl:value-of select="$versionInfo"/></owl:versionInfo>
<owl:incompatibleWith><xsl:value-of select="$incompatibleWith"/></owl:incompatibleWith>
<owl:versionIRI rdf:resource="{fn:concat($coreArtefactURI,'-',$versionInfo)}"/>
<bibo:status><xsl:value-of select="$ontologyStatus"/></bibo:status>
<owl:priorVersion><xsl:value-of select="$priorVersion"/></owl:priorVersion>
<!-- <bibo:status><xsl:value-of select="$ontologyStatus"/></bibo:status>-->

<owl:priorVersion><xsl:value-of select="fn:concat($coreArtefactURI,'-',$priorVersion)"/></owl:priorVersion>

<vann:preferredNamespaceUri><xsl:value-of select="$preferredNamespaceUri"/></vann:preferredNamespaceUri>
<vann:preferredNamespacePrefix><xsl:value-of select="$preferredNamespacePrefix"/></vann:preferredNamespacePrefix>
<dct:rights><xsl:value-of select="$rightsLiteral"/></dct:rights>
<dct:license rdf:resource="{$licenseURI}"/>
<cc:attributionName><xsl:value-of select="$attributionNameLiteral"/></cc:attributionName>
<cc:attributionURL rdf:resource="{$attributionURL}"/>
<dct:license><xsl:value-of select="$licenseLiteral"/></dct:license>

</owl:Ontology>

</xsl:template>
Expand Down
17 changes: 9 additions & 8 deletions src/owl-restrictions.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:vann="http://purl.org/vocab/vann/"
xmlns:cc="http://creativecommons.org/ns#"
exclude-result-prefixes="xs math xd xsl uml xmi umldi fn f"
exclude-result-prefixes="xs math xd xsl uml xmi umldi fn f bibo"
version="3.0">
<xd:doc scope="stylesheet">
<xd:desc>
Expand Down Expand Up @@ -48,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 @@ -65,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 All @@ -79,17 +82,15 @@
</xsl:for-each>

<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date"><xsl:value-of select="$issuedDate"/></dct:issued>
<dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#date"><xsl:value-of select="$createdDate"/></dct:created>
<owl:versionInfo><xsl:value-of select="$versionInfo"/></owl:versionInfo>
<owl:incompatibleWith><xsl:value-of select="$incompatibleWith"/></owl:incompatibleWith>
<owl:versionIRI rdf:resource="{fn:concat($restrictionsArtefactURI,'-',$versionInfo)}"/>
<bibo:status><xsl:value-of select="$ontologyStatus"/></bibo:status>
<owl:priorVersion><xsl:value-of select="$priorVersion"/></owl:priorVersion>
<!-- <bibo:status><xsl:value-of select="$ontologyStatus"/></bibo:status>-->
<owl:priorVersion><xsl:value-of select="fn:concat($restrictionsArtefactURI,'-',$priorVersion)"/></owl:priorVersion>
<vann:preferredNamespaceUri><xsl:value-of select="$preferredNamespaceUri"/></vann:preferredNamespaceUri>
<vann:preferredNamespacePrefix><xsl:value-of select="$preferredNamespacePrefix"/></vann:preferredNamespacePrefix>
<dct:rights><xsl:value-of select="$rightsLiteral"/></dct:rights>
<dct:license rdf:resource="{$licenseURI}"/>
<cc:attributionName><xsl:value-of select="$attributionNameLiteral"/></cc:attributionName>
<cc:attributionURL rdf:resource="{$attributionURL}"/>
<dct:license><xsl:value-of select="$licenseLiteral"/></dct:license>

</owl:Ontology>
</xsl:template>
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
Loading

0 comments on commit 607a875

Please sign in to comment.