From 15bae8ea2aa4f838def38288ccd2cf705ffc3407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr> Date: Sat, 24 Mar 2012 14:03:15 +0000 Subject: [PATCH] - fixed polymeaning of edoal:type - forced edoal:Datatype in edoal:datatype --- examples/omwg/total-owlable.xml | 6 +- examples/omwg/total.xml | 6 +- html/credits.html | 5 +- html/edoal.html | 231 ++++++++++++------ .../exmo/align/impl/edoal/Datatype.java | 16 +- .../renderer/OWLAxiomsRendererVisitor.java | 2 +- .../impl/renderer/RDFRendererVisitor.java | 6 +- .../exmo/align/parser/RDFParser.java | 43 ++-- .../exmo/align/parser/SyntaxElement.java | 5 +- test/src/EDOALExportTest.java | 6 +- 10 files changed, 200 insertions(+), 126 deletions(-) diff --git a/examples/omwg/total-owlable.xml b/examples/omwg/total-owlable.xml index c617fefc..fff73869 100644 --- a/examples/omwg/total-owlable.xml +++ b/examples/omwg/total-owlable.xml @@ -137,7 +137,7 @@ <edoal:onAttribute> <edoal:Relation rdf:about="&wine;hasTerroir"/> </edoal:onAttribute> - <edoal:datatype>An-integer-as-datatype</edoal:datatype> + <edoal:datatype><edoal:Datatype rdf:about="http://example.com/An-integer-as-datatype" /></edoal:datatype> </edoal:AttributeTypeRestriction> <edoal:AttributeOccurenceRestriction> <edoal:onAttribute> @@ -410,7 +410,7 @@ <measure rdf:datatype='&xsd;float'>1.</measure> <relation>SubsumedBy</relation> <edoal:transformation> - <edoal:Transformation edoal:type="o-"> + <edoal:Transformation edoal:direction="o-"> <edoal:entity1> <edoal:Property><edoal:compose rdf:parseType="Collection"/></edoal:Property> </edoal:entity1> @@ -445,7 +445,7 @@ <measure rdf:datatype='&xsd;float'>1.</measure> <relation>SubsumedBy</relation> <edoal:transformation> - <edoal:Transformation edoal:type="o-"> + <edoal:Transformation edoal:direction="o-"> <edoal:entity1> <edoal:Relation><edoal:compose /></edoal:Relation> </edoal:entity1> diff --git a/examples/omwg/total.xml b/examples/omwg/total.xml index f296d6fe..77f1f270 100644 --- a/examples/omwg/total.xml +++ b/examples/omwg/total.xml @@ -147,7 +147,7 @@ </edoal:compose> </edoal:Property> </edoal:onAttribute> - <edoal:datatype>An-integer-as-datatype</edoal:datatype> + <edoal:datatype><edoal:Datatype rdf:about="http://example.com/An-integer-as-datatype" /></edoal:datatype> </edoal:AttributeTypeRestriction> <edoal:AttributeOccurenceRestriction> <edoal:onAttribute> @@ -708,7 +708,7 @@ <measure rdf:datatype='&xsd;float'>1.</measure> <relation>SubsumedBy</relation> <edoal:transformation> - <edoal:Transformation edoal:type="o-"> + <edoal:Transformation edoal:direction="o-"> <edoal:entity1> <edoal:Property><edoal:compose rdf:parseType="Collection"/></edoal:Property> </edoal:entity1> @@ -743,7 +743,7 @@ <measure rdf:datatype='&xsd;float'>1.</measure> <relation>SubsumedBy</relation> <edoal:transformation> - <edoal:Transformation edoal:type="o-"> + <edoal:Transformation edoal:direction="o-"> <edoal:entity1> <edoal:Relation><edoal:compose /></edoal:Relation> </edoal:entity1> diff --git a/html/credits.html b/html/credits.html index 426688a9..41e5db0f 100644 --- a/html/credits.html +++ b/html/credits.html @@ -19,7 +19,7 @@ IDDN.FR. 001.050019 .000.S.P.2 011.000.2090 0 <h2>Contributors</h2> -<p>Below is the name of individual whose work has contributed to the +<p>Below are the names of individuals whose work has contributed to the Alignment API. This can be either because they directly worked on the project or because the released some code that has been integrated within the project.</p> @@ -29,7 +29,7 @@ IDDN.FR. 001.050019 .000.S.P.2 011.000.2090 0 developer of the Alignment API and Server.</dd> <dt><a href="http://www.iro.umontreal.ca/~valtchev/">Petko Valtchev</a></dt><dd>was instrumental in fixing many different parts of the code when working on other projects.</dd> -<dt><a href="http://www.ai.univ-paris8.fr/~leduc/">Chan Le Duc</a></dt><dd>has developed the NeOn plug-in and improves the whole system.</dd> +<dt><a href="http://www.ai.univ-paris8.fr/~leduc/">Chan Le Duc</a></dt><dd>has developed the NeOn plug-in and improved the whole system.</dd> <dt><a href="http://www.inrialpes.fr/exmo/people/jdavid/">Jérôme David</a></dt><dd>developed the Ontology part of the API (ontowrap).</dd> <dt>Maria Roşoiu</dt><dd>developed the generator interface (gen).</dd> @@ -80,6 +80,7 @@ Copyright (C) 2008 Quentin Reul (parts of SKOSRendererVisitor)<br /> by providing bug reports, feature requests and patches: Mathieu d'Aquin, Jürgen Bock, +<a href="http://www.ecs.soton.ac.uk/people/gc3/">Gianluca Correndo</a>, Mark Ingram, Antoine Isaac, Kotis Kostas, diff --git a/html/edoal.html b/html/edoal.html index a28b0c05..aa344d61 100644 --- a/html/edoal.html +++ b/html/edoal.html @@ -4,12 +4,6 @@ <!--style type="text/css">@import url(style.css);</style--> <link rel="stylesheet" type="text/css" href="base.css" /> <link rel="stylesheet" type="text/css" href="style.css" /> -</head> - -<body> -[<a href="format.html">Alignment format</a>] -[<a href="./">API</a>] - <script type="text/javascript">/*<![CDATA[*/ /* Written by Jonathan Snook, http://www.snook.ca/jonathan @@ -19,11 +13,9 @@ */ var displayed = []; -displayed["fssyntax"] = 1; -displayed["rdfxml"] = 0; +displayed["rdfxml"] = 1; displayed["n3"] = 0; displayed["graph"] = 0; -displayed["owlxml"] = 0; function display(syntax,status) { var howmany = 0; @@ -90,14 +82,18 @@ function set_display_by_id(id, newValue) { } function primerOnLoad() { - display('rdfxml', 'none'); set_display_by_id('hide-rs', 'none'); set_display_by_id('show-rs', ''); - display('n3', ''); set_display_by_id('hide-ts', ''); set_display_by_id('show-ts', 'none'); + display('rdfxml', ''); set_display_by_id('hide-rs', ''); set_display_by_id('show-rs', 'none'); + display('n3', 'none'); set_display_by_id('hide-ts', 'none'); set_display_by_id('show-ts', ''); display('graph', 'none'); set_display_by_id('hide-ms', 'none'); set_display_by_id('show-ms', ''); - display('owlxml', 'none'); set_display_by_id('hide-xs', 'none'); set_display_by_id('show-xs', ''); } /*]]>*/ </script> +</head> +<body> +[<a href="format.html">Alignment format</a>] +[<a href="./">API</a>] + <h1 class="titre">EDOAL: Expressive and Declarative Ontology Alignment Language</h1> @@ -126,6 +122,12 @@ the <a href="format.html">alignment format</a>.</p> <h3 id="sec:purpose">Purpose</h3> +<!--div class="rdfxml"> +<div class="exampleheader"><span class="exampleheader">RDF/XML Syntax</span></div> +<pre><owl:IrreflexiveProperty rdf:about="parentOf"/> +</pre> +</div--> + <p>Representing ontology alignments is the general purpose of this vocabulary. Particularly, it extends the ontology <a href="format.html">alignment format</a> in order to enable the representation of complex correspondences.</p> <p>This format can be used for cases where expressing equivalence or subsumption between terms is not sufficient, when more precise relations need to be expressed. While term equivalence or subsumption might be enough for exchanging documents, more precise relations are needed to exchange and integrate data.</p> @@ -188,9 +190,11 @@ EDOAL's own namespace is <tt>http://ns.inria.org/edoal/1.0/</tt> (usual prefix: edoal). </p> <p> +<b>NOTE: THIS IS TO BE FIXED</b> Comparators are taken from the W3C XPath functions -recommendation: <tt>http://www.w3.org/2005/xpath-functions</tt> -(usual prefix: functions).</p> +recommendation: <tt>http://www.w3.org/2005/xpath-functions</tt> [<a href="http://www.w3.org/TR/xpath-functions">1</a>] +(usual prefix: functions), which are also XML schema comparators. +</p> <h3 id="ssec:alignment">Alignment format</h3> @@ -204,7 +208,8 @@ The alignment moreover specifies the two aligned ontologies, and as exemplified in the code below. </p> -<div class="rdfxml"><div class="exampleheader">RDF/XML Syntax</div> +<div class="rdfxml"> +<div class="exampleheader">RDF/XML Syntax</div> <div class="detail"> <pre> <?xml version='1.0' encoding='utf-8' standalone='no'?> @@ -243,8 +248,9 @@ exemplified in the code below. <p>An alignment contains a set of correspondences (<tt>Cell</tt>s). Each cell can be linked to an alignment using the <tt>map</tt> property. </p> - -<div class="rdfxml"><div class="exampleheader">RDF/XML Syntax</div> +<p> +<div class="rdfxml"> +<div class="exampleheader">RDF/XML Syntax</div> <div class="detail"> <pre> ... @@ -258,7 +264,7 @@ Each cell can be linked to an alignment using the <tt>map</tt> property. </align:map> ... </pre></div></div> - +</p> <p> As the example shows, the EDOAL vocabulary only appears within the "entity" properties and very specificaly in the <tt>edoal:transformation</tt> @@ -318,9 +324,6 @@ Datatype </pre> </p> <p> -Below are the syntactic declaration of these entities. -</p> -<p> The <i>Id</i> interface is implemented by expressions identified by an URI: these are the named entities of ontologies that may be used in basic URIAlignments. The <i>ValueExpression</i> is implemented by @@ -328,6 +331,15 @@ expressions that identify in context a particular value or instance. This can be an instance or a literal as well as a path expression that leads to that value in the context of an instance. </p> +<p> +Hence, the entities that can be found in cells are: +<div class="fragment"><pre> +<u>entity</u> ::= <u>instexpr</u> | <u>classexpr</u> | <u>attexpr</u> + +<u>attexpr</u> ::= <u>propexpr</u> | <u>relexpr</u> +</pre></div> +Below are the syntactic declaration of these entities. +</p> <h2 id="ssec:classes">Class expressions</h2> @@ -356,7 +368,7 @@ Restrictions are defined by giving an <i>path expression</i> (relation or proper <div class="fragment"><pre> <u>classexpr</u> ::= <Class rdf:about=" <u>URI</u> "/> | <Class> <u>classconst</u> </Class> - | <AttributeOccurenceRestriction> <u>onatt</u> <u>comp</u> <value><Literal type="&xsd;Integer" string="INTEGER" /></value> </AttributeOccurenceRestriction> + | <AttributeOccurenceRestriction> <u>onatt</u> <u>comp</u> <value><Literal edoal:type="&xsd;Integer" edoal:string="INTEGER" /></value> </AttributeOccurenceRestriction> | <AttributeDomainRestriction> <u>onatt</u> <u>classrest</u> </AttributeDomainRestriction> | <AttributeTypeRestriction> <u>onatt</u> <u>typerest</u> </AttributeTypeRestriction> | <AttributeValueRestriction> <u>onatt</u> <u>comp</u> (<value><u>instexpr</u></value>|<u>val</u>) </AttributeValueRestriction> @@ -370,15 +382,9 @@ Restrictions are defined by giving an <i>path expression</i> (relation or proper table:</p> <div class="fragment"><pre> -<u>entity</u> ::= <u>instexpr</u> | <u>classexpr</u> | <u>attexpr</u> - -<u>attexpr</u> ::= <u>propexpr</u> | <u>relexpr</u> - <u>onatt</u> ::= <onAttribute> <u>attexpr</u> </onAttribute> -<u>val</u> ::= <value> <u>value</u> </value> - -<u>typerest</u> ::= <!--<all> <u>type</u> </all> | <exists> <u>type</u> </exists> | --><type> <u>type</u> </type> +<u>typerest</u> ::= <!--<all> <u>type</u> </all> | <exists> <u>type</u> </exists> | --><datatype> <u>type</u> </datatype> <u>type</u> ::= <Datatype rdf:about=" <u>URI</u> " /> @@ -386,12 +392,8 @@ Restrictions are defined by giving an <i>path expression</i> (relation or proper <u>comp</u> ::= <comparator rdf:resource=" <u>URI</u> "/> -<u>value</u> ::= <Literal {type=" <u>URI</u> "} string=" <u>STRING</u> " /> | <u>instepr</u> | <u>attrexpr</u> - | <Apply operator=" <u>URI</u> "> <arguments rdf:parseType="Collection"><u>value</u>*</arguments> </Apply> </pre></div> -<p>Comparators are taken from the XPath function specification [<a href="http://www.w3.org/TR/xpath-functions">1</a>].</p> - <div class="rdfxml"> Hence, a class expression may be an identified class: <div class="exampleheader">RDF/XML Syntax</div> @@ -430,7 +432,7 @@ or as a restriction on the value of a property (here a property path): <value edoal:type="&xsd;string">Acquitaine</value> </AttributeValueRestriction> </pre></div> -Thanks to paths and restrictions, it is possible to restrict a correspondence to ``Wines whose producing region is located in Aquitaine'' using the following restriction. The comparator is issued from the standard XML Schema comparators. +Thanks to paths and restrictions, it is possible to restrict a correspondence to ``Wines whose producing region is located in Aquitaine'' using the following restriction. </div> <!--div class="rdfxml"> We can with this restriction build the correspondence between @@ -456,7 +458,7 @@ We can with this restriction build the correspondence between </Relation> </onAttribute> <comparator rdf:resource="&xsd;equals"/> - <value rdf:datatype="&xsd;string">Acquitaine</value> + <value edoal:type="&xsd;string">Acquitaine</value> </Restriction> </attributeValueCondition> </Class> @@ -519,13 +521,14 @@ ending by a property: </pre></div></div> <div class="rdfxml"> +blabla <div class="exampleheader">RDF/XML Syntax</div> <div class="detail"> <pre> <PropertyTypeRestriction> - <type> - <Datatype rdf:about="&xsd;" /> - </type> + <datatype> + <Datatype rdf:about="&xsd;Integer" /> + </datatype> </PropertyTypeRestriction> </pre></div></div> @@ -592,7 +595,7 @@ An example of occurrence restriction would be the wines produced in a region wit </Relation> </onAttribute> <comparator rdf:resource="&xsd;greater-than"/> - <value rdf:datatype="&xsd;int">0</value> + <value edoal:type="&xsd;int">0</value> </Restriction> </attributeOccurrenceCondition> </Class> @@ -634,53 +637,120 @@ uses a path to state that a locally grown wine is a wine whose owner (propri&eac </pre></div></div> -<h2 id="ssec:instances">Instances</h2> +<h2 id="ssec:values">Values</h2> + +<p> +A value expression may be used in alignments for denoting an +individual things (not a class, a property or a relations). These +values may be: +<ul> +<li>a litteral value;</li> +<li>an individual instance;</li> +<li>a value reachable to a property or relation;</li> +<li>a value computable by a function from arguments which are values.</li> +</ul> +</p> -<p>Instances are always single entities refering to an individual - through its URI.</p> +<p> +They obey the following grammar: <div class="fragment"><pre> -<u>instance</u> ::= <Instance rdf:about=" <u>URI</u> "/> +<u>val</u> ::= <value> <u>value</u> </value> + +<u>value</u> ::= <Literal {edoal:type=" <u>URI</u> "} edoal:string=" <u>STRING</u> " /> + | <u>instexpr</u> + | <u>attrexpr</u> + | <Apply operator=" <u>URI</u> "> <arguments rdf:parseType="Collection"><u>value</u>*</arguments> </Apply> + +<u>instexpr</u> ::= <Instance rdf:about=" <u>URI</u> "/> </pre></div> +</p> -<!--h2 id="ssec:transfs">Transformations</h2--> - -<!--div class="fragment"><pre> -transformation ::= <Transformation> - xpath-transformation - </Transformation> - | <Transformation> - <transformation rdf:resource="uri"/> - <parameters> - <rdf:Seq> - <rdf:li />* - </rdf:Seq> - </parameters> - </Transformation> -</pre></div--> +<!--h2>Instances</h2--> -<!--p>Transformations are of two kinds, either XPath transformation functions can be used, or other transformation services can be invoked, for example for dynamic transformations like currency conversions (see <a href="#sec:examples">examples</a>).</p--> +<div class="rdfxml"> +Literal values: +<div class="exampleheader">RDF/XML Syntax</div> +<div class="detail"> +<pre> + <Literal edoal:type="&xsd;Integer" edoal:string="123" /> + <Literal edoal:type="&xsd;Integer">123</Literal> +</pre></div></div> -<!--div class="rdfxml"> +<p> +Instances are always single entities refering to an individual + through its URI: +<div id="ssec:instances" class="rdfxml"> +<div class="exampleheader">RDF/XML Syntax</div> +<div class="detail"> +<pre> + <Instance rdf:about="&vin;hasTerroir" /> +</pre></div></div> +</p> +<p> +<div class="rdfxml"> +Application of an operator is not operational but may be expressed in +the following way: +<div class="exampleheader">RDF/XML Syntax</div> +<div class="detail"> +<pre> + <Apply operator="http://example.com/Whatever"> + <arguments rdf:parseType="Collection"> + <Literal rdf:about="&xsd;Integer">123</Literal> + <Property> + <compose rdf:parseType="Collection"> + <edoal:Relation rdf:about="&vin;hasTerroir" /> + <edoal:Property rdf:about="&proton;localedIn" /> + </compose> + </Property> + <Instance rdf:about="&vin;Bordelais" /> + </arguments> + </Apply> +</pre></div></div> +</p> +<h2 id="ssec:transf">Transformations</h2> + +<p> +<b>The development of transformations is still work in progress and you +can contribute by providing your requirements.</b> +Transformations are expressed in the cell itself. Transformations do +not express constraints on the classes or properties, but constraints +on instances that should match. +</p> + +<div class="fragment"><pre> +<u>transformation</u> ::= <Transformation operator=" <u>URI</u> " direction=" <u>STRING</u> "> + <arguments rdf:parseType="Collection"> <u>value</u>* </arguments> + </Transformation> +</pre></div> + +<p> +Transformations <!--are of two kinds, either XPath transformation functions can be used, or other transformation services -->can be invoked, for example for dynamic transformations like currency conversions (see <a href="#sec:examples">examples</a>).</p> + +<div class="rdfxml"> The following correspondence shows an example of the use of data transformation: <div class="exampleheader">RDF/XML Syntax</div> <div class="detail"> <pre> -<align:Cell> - <align:entity1> - <Property rdf:about="&wine;hasVintageYear"/> - </align:entity1> - <align:entity2> - <Property rdf:about="&vin;annee\_millesime"> - <apply> - <Transf rdf:resource="Transformation:Date2Int" /> - <Property rdf:about="&wine;date"/> - </apply> - </Property> - </align:entity2> - <align:measure rdf:datatype="&xsd;float">1.0</align:measure> - <align:relation>=</align:relation> -</align:Cell> -</pre></div></div--> + <edoal:transformation> + <edoal:Transformation edoal:direction="o-"> + <edoal:entity1> + <edoal:Property><edoal:compose rdf:parseType="Collection"/></edoal:Property> + </edoal:entity1> + <edoal:entity2> + <edoal:Apply edoal:operator="concat"> + <edoal:arguments rdf:parseType="Collection"> + <edoal:Property rdf:about="vcard:firstname"/> + <edoal:Literal edoal:type="&xsd;string" edoal:string=" "/> + <!-- or even compute middle initial from middlename --> + <edoal:Property rdf:about="vcard:middleinitial"/> + <edoal:Literal edoal:string=". "/> + <edoal:Property rdf:about="vcard:lastname"/> + </edoal:arguments> + </edoal:Apply> + </edoal:entity2> + </edoal:Transformation> + </edoal:transformation> +</pre></div></div> <h2 id="sec:examples">Longer examples</h2> @@ -819,7 +889,7 @@ O2:GreenLED a edoal:Class. <align:entity2><edoal:Property rdf:about="&O2;weight" /></align:entity2> <align:relation>=</align:relation> <edoal:transformation> - <edoal:Transformation edoal:type="o-"> + <edoal:Transformation edoal:direction="o-"> <edoal:entity1> <edoal:Property><edoal:compose rdf:parseType="Collection"/></edoal:Property> </edoal:entity1> @@ -843,7 +913,7 @@ O2:GreenLED a edoal:Class. <align:entity2><edoal:Class rdf:about="&O2;Patient" /></align:entity2> <align:relation>=</align:relation> <edoal:transformation> - <edoal:Transformation edoal:type="o-"> + <edoal:Transformation edoal:direction="o-"> <edoal:entity1><edoal:Property rdf:about="&O1;hasWeight" /></edoal:entity1> <edoal:entity2> <edoal:Apply edoal:operator="&fn;safe-divide"> @@ -894,7 +964,7 @@ O2:weight a edoal:Property. <align:entity2><edoal:Property rdf:about="&O2;hasPrice" /></align:entity2> <align:relation>=</align:relation> <edoal:transformation> - <edoal:Transformation edoal:type="o-"> + <edoal:Transformation edoal:direction="o-"> <edoal:entity1> <edoal:Property><edoal:compose rdf:parseType="Collection"/></edoal:Property> </edoal:entity1> @@ -962,7 +1032,7 @@ This pattern thus captures all correspondences between two classes, the scope of </edoal:class> </edoal:PropertyDomainRestriction> </edoal:onAttribute> - <edoal:type><edoal:Datatype rdf:about="&xsd;integer" /></edoal:type> + <edoal:datatype><edoal:Datatype rdf:about="&xsd;integer" /></edoal:datatype> </edoal:AttributeTypeRestriction> </edoal:and> </edoal:Class> @@ -1065,6 +1135,7 @@ syntax toggling scripts borrowed from the OWL Recommendation web page. <address> <small> <hr /> +<script type="text/javascript">primerOnLoad();</script> <center>http://alignapi.gforge.inria.fr/edoal.html</center> <hr /> $Id$ diff --git a/src/fr/inrialpes/exmo/align/impl/edoal/Datatype.java b/src/fr/inrialpes/exmo/align/impl/edoal/Datatype.java index 0d1d372a..1c73aff4 100644 --- a/src/fr/inrialpes/exmo/align/impl/edoal/Datatype.java +++ b/src/fr/inrialpes/exmo/align/impl/edoal/Datatype.java @@ -38,13 +38,6 @@ public class Datatype { //implements Cloneable /** Holds the type */ private String type; - public void accept( EDOALVisitor visitor) throws AlignmentException { - visitor.visit( this ); - } - public TYPE accept( TypeCheckingVisitor visitor ) throws AlignmentException { - return visitor.visit(this); - } - /** * Constructs an object with the given type. * @@ -62,7 +55,14 @@ public class Datatype { //implements Cloneable this.type = type; } - public String plainText() { + public void accept( EDOALVisitor visitor) throws AlignmentException { + visitor.visit( this ); + } + public TYPE accept( TypeCheckingVisitor visitor ) throws AlignmentException { + return visitor.visit(this); + } + + public String getType() { return type; } diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java index 31b1bde6..c5e12e2d 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/OWLAxiomsRendererVisitor.java @@ -870,7 +870,7 @@ public class OWLAxiomsRendererVisitor extends IndentedRendererVisitor implements * clauses */ public void visit( final Datatype e ) { - indentedOutput("<owl:Datatype><owl:onDataType rdf:resource=\""+e.plainText()+"\"/></owl:Datatype>"); + indentedOutput("<owl:Datatype><owl:onDataType rdf:resource=\""+e.getType()+"\"/></owl:Datatype>"); } } diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java index ca7129d3..3ac5b2c3 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java @@ -690,9 +690,9 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align } public void visit( final Datatype e ) throws AlignmentException { - indentedOutput("<"+SyntaxElement.DATATYPE.print(DEF)+">"); - writer.print(e.plainText()); - writer.print("</"+SyntaxElement.DATATYPE.print(DEF)+">"); + indentedOutput("<"+SyntaxElement.EDATATYPE.print(DEF)+">"); + writer.print("<"+SyntaxElement.DATATYPE.print(DEF)+" "+SyntaxElement.RDF_ABOUT.print(DEF)+"=\""+e.getType()+"\"/>"); + writer.print("</"+SyntaxElement.EDATATYPE.print(DEF)+">"); } } diff --git a/src/fr/inrialpes/exmo/align/parser/RDFParser.java b/src/fr/inrialpes/exmo/align/parser/RDFParser.java index 6b79c23f..8ab22b29 100644 --- a/src/fr/inrialpes/exmo/align/parser/RDFParser.java +++ b/src/fr/inrialpes/exmo/align/parser/RDFParser.java @@ -422,7 +422,7 @@ public class RDFParser { try { // parsing type Statement stmt = node.getProperty( (Property)SyntaxElement.TRDIR.resource ); - if ( stmt == null ) throw new AlignmentException( "Required edoal:type property in Transformation" ); + if ( stmt == null ) throw new AlignmentException( "Required "+SyntaxElement.TRDIR.print()+" property in Transformation" ); String type = stmt.getLiteral().toString(); // parsing entity1 and entity2 Resource entity1 = node.getProperty((Property)SyntaxElement.TRENT1.resource).getResource(); @@ -544,15 +544,9 @@ public class RDFParser { if ( rdfType.equals( SyntaxElement.TYPE_COND.resource ) ) { // Check that pe is a Property / Relation // ==> different treatment - // Datatype could also be defined as objets...? (like rdf:resource="") - stmt = node.getProperty( (Property)SyntaxElement.DATATYPE.resource ); - if ( stmt == null ) throw new AlignmentException( "Required edoal:datatype property" ); - RDFNode nn = stmt.getObject(); - if ( nn.isLiteral() ) { - return new ClassTypeRestriction( pe, new Datatype( ((Literal)nn).getString() ) ); - } else { - throw new AlignmentException( "Bad edoal:datatype value" ); - } + stmt = node.getProperty( (Property)SyntaxElement.EDATATYPE.resource ); + if ( stmt == null ) throw new AlignmentException( "Required "+SyntaxElement.EDATATYPE.print()+" property" ); + return new ClassTypeRestriction( pe, parseDatatype( stmt.getObject() ) ); } else if ( rdfType.equals( SyntaxElement.DOMAIN_RESTRICTION.resource ) ) { if ( (stmt = node.getProperty( (Property)SyntaxElement.TOCLASS.resource ) ) != null || (stmt = node.getProperty( (Property)SyntaxElement.ALL.resource ) ) != null ) { RDFNode nn = stmt.getObject(); @@ -569,7 +563,7 @@ public class RDFParser { if ( stmt == null ) throw new AlignmentException( "Required edoal:comparator property" ); URI id = getNodeId( stmt.getResource() ); if ( id != null ) comp = Comparator.getComparator( id ); - else throw new AlignmentException("edoal:comparator requires an URI"); + else throw new AlignmentException("edoal:comparator requires a URI"); if ( rdfType.equals( SyntaxElement.OCCURENCE_COND.resource ) ) { stmt = node.getProperty( (Property)SyntaxElement.VALUE.resource ); if ( stmt == null ) throw new AlignmentException( "Required edoal:value property" ); @@ -680,16 +674,9 @@ public class RDFParser { throw new AlignmentException( "Incorrect class expression "+nn ); } } else if ( rdfType.equals( SyntaxElement.PROPERTY_TYPE_COND.resource ) ) { - // Datatype could also be defined as objets...? (like rdf:resource="") - // Or classes? OF COURSE???? - stmt = node.getProperty( (Property)SyntaxElement.DATATYPE.resource ); - if ( stmt == null ) throw new AlignmentException( "Required edoal:datatype property" ); - RDFNode nn = stmt.getObject(); - if ( nn.isLiteral() ) { - return new PropertyTypeRestriction( new Datatype( ((Literal)nn).getString() ) ); - } else { - throw new AlignmentException( "Bad edoal:datatype value" ); - } + stmt = node.getProperty( (Property)SyntaxElement.EDATATYPE.resource ); + if ( stmt == null ) throw new AlignmentException( "Required "+SyntaxElement.EDATATYPE.print()+" property" ); + return new PropertyTypeRestriction( parseDatatype( stmt.getObject() ) ); } else if ( rdfType.equals( SyntaxElement.PROPERTY_VALUE_COND.resource ) ) { // Find comparator stmt = node.getProperty( (Property)SyntaxElement.COMPARATOR.resource ); @@ -706,6 +693,20 @@ public class RDFParser { } } + protected Datatype parseDatatype ( final RDFNode nn ) throws AlignmentException { + String uri = null; + if ( nn.isLiteral() ) { // Legacy + System.err.println( "Warning: datatypes must be Datatype objects ("+((Literal)nn).getString()+")" ); + uri = ((Literal)nn).getString(); + } else if ( nn.isResource() ) { + if ( !((Resource)nn).getProperty(RDF.type).getResource().equals( SyntaxElement.DATATYPE.resource ) ) + throw new AlignmentException( "datatype requires a "+SyntaxElement.DATATYPE.print()+" value" ); + uri = ((Resource)nn).getURI(); + // check URI + } else throw new AlignmentException( "Bad "+SyntaxElement.EDATATYPE.print()+" value" ); + return new Datatype( uri ); + } + protected RelationExpression parseRelation( final Resource node ) throws AlignmentException { Resource rdfType = node.getProperty(RDF.type).getResource(); Statement stmt = null; diff --git a/src/fr/inrialpes/exmo/align/parser/SyntaxElement.java b/src/fr/inrialpes/exmo/align/parser/SyntaxElement.java index 072034f8..675d25a2 100644 --- a/src/fr/inrialpes/exmo/align/parser/SyntaxElement.java +++ b/src/fr/inrialpes/exmo/align/parser/SyntaxElement.java @@ -94,7 +94,8 @@ public enum SyntaxElement { CLASS_EXPR( Namespace.EDOAL, "Class", true),//ALIGNMENT COMPARATOR( Namespace.EDOAL, "comparator"), COMPOSE( Namespace.EDOAL, "compose", Constructor.COMP), - DATATYPE( Namespace.EDOAL, "datatype"), + EDATATYPE( Namespace.EDOAL, "datatype"), + DATATYPE( Namespace.EDOAL, "Datatype"), DOMAIN_RESTRICTION(Namespace.EDOAL, "AttributeDomainRestriction", true), //ID( Namespace.EDOAL, "Id", true), // Useless INSTANCE_EXPR( Namespace.EDOAL, "Instance", true), @@ -125,7 +126,7 @@ public enum SyntaxElement { TRENT1( Namespace.EDOAL, "entity1"), TRENT2( Namespace.EDOAL, "entity2"), TRANSF( Namespace.EDOAL, "Transformation", true), - TRDIR( Namespace.EDOAL, "type"), + TRDIR( Namespace.EDOAL, "direction"), TRANSFORMATION( Namespace.EDOAL, "transformation"), TRANSITIVE( Namespace.EDOAL, "transitive", Constructor.TRANSITIVE), TYPE_COND(Namespace.EDOAL, "AttributeTypeRestriction", true), // undocumented diff --git a/test/src/EDOALExportTest.java b/test/src/EDOALExportTest.java index 8ddb7a4d..1716701a 100644 --- a/test/src/EDOALExportTest.java +++ b/test/src/EDOALExportTest.java @@ -154,7 +154,7 @@ public class EDOALExportTest { writer.close(); String str1 = stream.toString(); //System.err.println(str1); - assertEquals( str1.length(), 11604 ); + assertEquals( str1.length(), 11623 ); } @Test(groups = { "full", "omwg", "raw" }, dependsOnMethods = {"setUp"}) @@ -220,7 +220,7 @@ public class EDOALExportTest { assertEquals( render( toExport ), "<edoal:AttributeTypeRestriction>" + "<edoal:onAttribute><edoal:Property rdf:about=\"http://my.sister#age\"/></edoal:onAttribute>" //+ "<edoal:comparator rdf:resource=\"http://www.w3.org/2001/XMLSchema#equals\"/>" - + "<edoal:datatype>integer-under-100</edoal:datatype>" + + "<edoal:datatype><edoal:Datatype rdf:about=\"integer-under-100\"/></edoal:datatype>" + "</edoal:AttributeTypeRestriction>" ); toExport = new ClassOccurenceRestriction( new PropertyId(new URI("http://my.sister#age")), Comparator.GREATER, 18); assertEquals( render( toExport ), "<edoal:AttributeOccurenceRestriction>" @@ -304,7 +304,7 @@ public class EDOALExportTest { + "<edoal:value><edoal:Literal edoal:string=\"18\"/></edoal:value>" + "</edoal:PropertyValueRestriction>" ); assertEquals( render( new PropertyTypeRestriction(new Datatype("int"))), - "<edoal:PropertyTypeRestriction><edoal:datatype>int</edoal:datatype></edoal:PropertyTypeRestriction>" ); + "<edoal:PropertyTypeRestriction><edoal:datatype><edoal:Datatype rdf:about=\"int\"/></edoal:datatype></edoal:PropertyTypeRestriction>" ); } @Test(groups = { "full", "omwg", "raw" }, dependsOnMethods = {"setUp"}) -- GitLab