From 38514ba5eced6feabe90bd6b138bcdc8acaa7626 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Euzenat?= <Jerome.Euzenat@inria.fr>
Date: Wed, 13 Jun 2007 19:41:27 +0000
Subject: [PATCH] - Added the new Ontology structure in the API implementation
 and in the format

---
 README.TXT                                    |   2 +-
 dtd/align.dtd                                 |  27 +++-
 .../exmo/align/impl/BasicAlignment.java       |  69 ++++++---
 .../exmo/align/impl/DistanceAlignment.java    |  55 +++----
 .../exmo/align/impl/OWLAPIAlignment.java      |  48 +++---
 .../inrialpes/exmo/align/impl/Ontology.java   |  50 +++++++
 .../exmo/align/impl/URIAlignment.java         |  20 +--
 .../exmo/align/parser/AlignmentParser.java    | 140 +++++++++++++-----
 8 files changed, 290 insertions(+), 121 deletions(-)
 create mode 100644 src/fr/inrialpes/exmo/align/impl/Ontology.java

diff --git a/README.TXT b/README.TXT
index 8d73931a..1799ddce 100644
--- a/README.TXT
+++ b/README.TXT
@@ -57,7 +57,7 @@ $ java -jar lib/procalign.jar file://$CWD/examples/rdf/onto1.owl file://$CWD/exa
 
 $ java -jar lib/procalign.jar file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -i fr.inrialpes.exmo.align.impl.method.StringDistAlignment -DstringFunction=levenshteinDistance -t 0.4 -o examples/rdf/sample.rdf
 
-$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.util.ParserPrinter examples/rdf/sample.rdf
+$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.util.ParserPrinter examples/rdf/newsample.rdf
 
 $ java -jar lib/procalign.jar file://$CWD/examples/rdf/onto1.owl file://$CWD/examples/rdf/onto2.owl -a examples/rdf/sample.rdf
 
diff --git a/dtd/align.dtd b/dtd/align.dtd
index 111c6971..95bf0c88 100644
--- a/dtd/align.dtd
+++ b/dtd/align.dtd
@@ -34,25 +34,38 @@
 <!-- (11|1?|1+|1*|?1|??|?+|?*|+1|+?|++|+*|*1|*?|*+|**) -->
 <!ELEMENT type (#PCDATA)>
 <!ELEMENT level (#PCDATA)>
+<!-- uriX are only here for compatibility purposes -->
 <!ELEMENT uri1 (#PCDATA)><!-- uri -->
 <!ATTLIST uri1 rdf:resource %uri; #IMPLIED>
 <!ELEMENT uri2 (#PCDATA)><!-- uri -->
 <!ATTLIST uri2 rdf:resource %uri; #IMPLIED>
-<!ELEMENT onto1 (#PCDATA)><!-- uri -->
+<!ELEMENT onto1 (ANY)><!-- uri|Ontology -->
 <!ATTLIST onto1 rdf:resource %uri; #IMPLIED>
-<!ELEMENT onto2 (#PCDATA)><!-- uri -->
+<!ELEMENT onto2 (ANY)><!-- uri|Ontology -->
 <!ATTLIST onto2 rdf:resource %uri; #IMPLIED>
+
+<!ELEMENT Ontology (formalism)>
+<!ATTLIST Ontology rdf:about %uri; #IMPLIED>
+<!ELEMENT location (#PCDATA)>
+<!ELEMENT formalism (Formalism)>
+<!ELEMENT Formalism (EMPTY)>
+<!ATTLIST Formalism uri %uri; #IMPLIED
+	  name CDATA #REQUIRED>
+
 <!-- For compatibility reason it is authorized to put several Cells
-     in a map element. However, the result is not RDF however -->
+     in a map element. However, the result is not RDF anymore -->
 <!ELEMENT map (Cell*)>
 
 <!ELEMENT Cell (entity1|entity2|measure|relation)*>
+<!ATTLIST Cell id %uri; #IMPLIED>
 
-<!ELEMENT entity1 EMPTY>
-<!ATTLIST entity1 rdf:resource %uri; #REQUIRED>
+<!-- either object or URI -->
+<!ELEMENT entity1 ANY>
+<!ATTLIST entity1 rdf:resource %uri; #IMPLIED>
 
-<!ELEMENT entity2 EMPTY>
-<!ATTLIST entity2 rdf:resource %uri; #REQUIRED>
+<!-- either object or URI -->
+<!ELEMENT entity2 ANY>
+<!ATTLIST entity2 rdf:resource %uri; #IMPLIED>
 
 <!-- I should put the true value here -->
 <!ATTLIST measure rdf:datatype %uri; #REQUIRED>
diff --git a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java
index b9673537..395309ec 100644
--- a/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java
+++ b/src/fr/inrialpes/exmo/align/impl/BasicAlignment.java
@@ -65,9 +65,11 @@ public class BasicAlignment implements Alignment {
     //public static String TIME = "http://knowledgeweb.semanticweb.org/heterogeneity/alignment:time";
     public static String TIME = "time";
 
-    protected Object onto1 = null;
-
-    protected Object onto2 = null;
+    // JE: OMWG1
+    //protected Object onto1 = null;
+    //protected Object onto2 = null;
+    protected Ontology onto1 = null;
+    protected Ontology onto2 = null;
 
     /* Set to true for rejecting the use of deprecated (non deterministic) primitives */
     protected static boolean STRICT_IMPLEMENTATION = false;
@@ -93,9 +95,9 @@ public class BasicAlignment implements Alignment {
      * This is NOT the Ontology URI which can be obtained by
      * getOntology1URI()
      */
-    protected URI uri1 = null;
-
-    protected URI uri2 = null;
+    // JE: OMWG1
+    //protected URI uri1 = null;
+    //protected URI uri2 = null;
 
     public BasicAlignment() {
 	hash1 = new Hashtable();
@@ -103,11 +105,23 @@ public class BasicAlignment implements Alignment {
 	extensions = new BasicParameters();
 	namespaces = new BasicParameters();
 	setExtension( METHOD, getClass().getName() );
+	// JE: OMWG1
+	onto1 = new Ontology();
+	onto2 = new Ontology();
     }
 
     public void init( Object onto1, Object onto2, Object cache ) throws AlignmentException {
-	this.onto1 = onto1;
-	this.onto2 = onto2;
+	System.err.println( "ONTO1[init()] = " +onto1 );
+	// JE: OMWG1
+	//this.onto1 = onto1;
+	//this.onto2 = onto2;
+	if ( onto1 instanceof Ontology ) {
+	    this.onto1 = (Ontology)onto1;
+	    this.onto2 = (Ontology)onto2;
+	} else {
+	    this.onto1.setOntology( onto1 );
+	    this.onto2.setOntology( onto2 );
+	}
     }
 
     public void init( Object onto1, Object onto2 ) throws AlignmentException {
@@ -128,24 +142,28 @@ public class BasicAlignment implements Alignment {
 
     /** Alignment methods * */
     public Object getOntology1() {
-	return onto1;
+	return onto1.getOntology();
     };
 
     public Object getOntology2() {
-	return onto2;
+	return onto2.getOntology();
     };
 
     public URI getOntology1URI() throws AlignmentException {
-	if ( onto1 instanceof URI ) {
-	    return (URI)onto1;
+	// JE: OMWG1
+	Object ontology = onto1.getOntology();
+	if ( ontology != null && ontology instanceof URI ) {
+	    return (URI)ontology;
 	} else {
 	    throw new AlignmentException( "Cannot find URI for "+onto1 );
 	}
     };
 
     public URI getOntology2URI() throws AlignmentException {
-	if ( onto2 instanceof URI ) {
-	    return (URI)onto2;
+	// JE: OMWG1
+	Object ontology = onto2.getOntology();
+	if ( ontology != null && ontology instanceof URI ) {
+	    return (URI)ontology;
 	} else {
 	    throw new AlignmentException( "Cannot find URI for "+onto2 );
 	}
@@ -153,12 +171,16 @@ public class BasicAlignment implements Alignment {
 
     public void setOntology1(Object ontology) throws AlignmentException {
 	//*/onto1 = (OWLOntology)ontology;
-	onto1 = ontology;
+	// JE: OMWG1
+	//onto1 = ontology;
+	onto1.setOntology( ontology );
     };
 
     public void setOntology2(Object ontology) throws AlignmentException {
 	//*/onto2 = (OWLOntology)ontology;
-	onto2 = ontology;
+	// JE: OMWG1
+	//onto2 = ontology;
+	onto2.setOntology( ontology );
     };
 
     public void setType(String type) { this.type = type; };
@@ -169,13 +191,19 @@ public class BasicAlignment implements Alignment {
 
     public String getLevel() { return level; };
 
-    public URI getFile1() { return uri1; };
+    // JE: OMWG1
+    //public URI getFile1() { return uri1; };
+    //public void setFile1(URI u) { uri1 = u; };
+    //public URI getFile2() { return uri2; };
+    //public void setFile2(URI u) { uri2 = u; };
+
+    public URI getFile1() { return onto1.getFile(); };
 
-    public void setFile1(URI u) { uri1 = u; };
+    public void setFile1(URI u) { onto1.setFile( u ); };
 
-    public URI getFile2() { return uri2; };
+    public URI getFile2() { return onto2.getFile(); };
 
-    public void setFile2(URI u) { uri2 = u; };
+    public void setFile2(URI u) { onto2.setFile( u ); };
 
     public Parameters getExtensions(){ return extensions; }
 
@@ -614,6 +642,7 @@ public class BasicAlignment implements Alignment {
     public void cleanUp() {}
 }
 
+
 class MEnumeration implements Enumeration {
     private Enumeration set = null; // The enumeration of sets
     private Iterator current = null; // The current set's enumeration
diff --git a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java
index f70ee42e..5967b032 100644
--- a/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java
+++ b/src/fr/inrialpes/exmo/align/impl/DistanceAlignment.java
@@ -158,18 +158,21 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce
       boolean found = false;
       double val = 0;
 
+	System.err.println( "ONTO1[extract()] = " +onto1 );
+	System.err.println( "ONTO1[extract().gO()] = " +onto1.getOntology() );
+
       try {
 	  // Extract for properties
 	  ConcatenatedIterator pit1 = new 
-	      ConcatenatedIterator(((OWLOntology)onto1).getObjectProperties().iterator(),
-				    ((OWLOntology)onto1).getDataProperties().iterator());
+	      ConcatenatedIterator(((OWLOntology)(onto1.getOntology())).getObjectProperties().iterator(),
+				   ((OWLOntology)(onto1.getOntology())).getDataProperties().iterator());
 	  for ( ; pit1.hasNext(); ) {
 	      OWLProperty prop1 = (OWLProperty)pit1.next();
 	      found = false; max = threshold; val = 0;
 	      OWLProperty prop2 = null;
 	      ConcatenatedIterator pit2 = new 
-		  ConcatenatedIterator(((OWLOntology)onto2).getObjectProperties().iterator(),
-					((OWLOntology)onto2).getDataProperties().iterator());
+		  ConcatenatedIterator(((OWLOntology)(onto2.getOntology())).getObjectProperties().iterator(),
+				       ((OWLOntology)(onto2.getOntology())).getDataProperties().iterator());
 	      for ( ; pit2.hasNext(); ) {
 		  OWLProperty current = (OWLProperty)pit2.next();
 		  val = 1 - sim.getPropertySimilarity(prop1,current);
@@ -180,11 +183,11 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce
 	      if ( found ) addAlignCell(prop1,prop2, "=", max);
 	  }
 	  // Extract for classes
-	  for (Iterator it1 = ((OWLOntology)onto1).getClasses().iterator(); it1.hasNext(); ) {
+	  for (Iterator it1 = ((OWLOntology)(onto1.getOntology())).getClasses().iterator(); it1.hasNext(); ) {
 	      OWLClass class1 = (OWLClass)it1.next();
 	      found = false; max = threshold; val = 0;
 	      OWLClass class2 = null;
-	      for (Iterator it2 = ((OWLOntology)onto2).getClasses().iterator(); it2.hasNext(); ) {
+	      for (Iterator it2 = ((OWLOntology)(onto2.getOntology())).getClasses().iterator(); it2.hasNext(); ) {
 		  OWLClass current = (OWLClass)it2.next();
 		  val = 1 - sim.getClassSimilarity(class1,current);
 		  if (val > max) {
@@ -196,12 +199,12 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce
 	  // Extract for individuals
 	  // This does not work, at least for the OAEI 2005 tests
 	  if (  params.getParameter("noinst") == null ){
-	      for (Iterator it1 = ((OWLOntology)onto1).getIndividuals().iterator(); it1.hasNext();) {
+	      for (Iterator it1 = ((OWLOntology)(onto1.getOntology())).getIndividuals().iterator(); it1.hasNext();) {
 		  OWLIndividual ind1 = (OWLIndividual)it1.next();
 		  if ( ind1.getURI() != null ) {
 		      found = false; max = threshold; val = 0;
 		      OWLIndividual ind2 = null;
-		      for (Iterator it2 = ((OWLOntology)onto2).getIndividuals().iterator(); it2.hasNext(); ) {
+		      for (Iterator it2 = ((OWLOntology)(onto2.getOntology())).getIndividuals().iterator(); it2.hasNext(); ) {
 			  OWLIndividual current = (OWLIndividual)it2.next();
 			  if ( current.getURI() != null ) {
 			      val = 1 - sim.getIndividualSimilarity(ind1,current);
@@ -230,17 +233,17 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce
 	    // (redoing the matrix instead of getting it)
 	    // For each kind of stuff (cl, pr, ind)
 	    // Create a matrix
-	    int nbclasses1 = ((OWLOntology)onto1).getClasses().size();
-	    int nbclasses2 = ((OWLOntology)onto2).getClasses().size();
+	    int nbclasses1 = ((OWLOntology)(onto1.getOntology())).getClasses().size();
+	    int nbclasses2 = ((OWLOntology)(onto2.getOntology())).getClasses().size();
 	    double[][] matrix = new double[nbclasses1][nbclasses2];
 	    OWLClass[] class1 = new OWLClass[nbclasses1];
 	    OWLClass[] class2 = new OWLClass[nbclasses2];
 	    int i = 0;
-	    for (Iterator it1 = ((OWLOntology)onto1).getClasses().iterator(); it1.hasNext(); i++) {
+	    for (Iterator it1 = ((OWLOntology)(onto1.getOntology())).getClasses().iterator(); it1.hasNext(); i++) {
 		class1[i] = (OWLClass)it1.next();
 	    }
 	    int j = 0;
-	    for (Iterator it2 = ((OWLOntology)onto2).getClasses().iterator(); it2.hasNext(); j++) {
+	    for (Iterator it2 = ((OWLOntology)(onto2.getOntology())).getClasses().iterator(); it2.hasNext(); j++) {
 		class2[j] = (OWLClass)it2.next();
 	    }
 	    for( i = 0; i < nbclasses1; i++ ){
@@ -265,22 +268,22 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce
 	catch (AlignmentException alex) { alex.printStackTrace(); }
 	// For properties
 	try{
-	    int nbprop1 = ((OWLOntology)onto1).getDataProperties().size() + ((OWLOntology)onto1).getObjectProperties().size();
-	    int nbprop2 = ((OWLOntology)onto2).getDataProperties().size() + ((OWLOntology)onto2).getObjectProperties().size();
+	    int nbprop1 = ((OWLOntology)(onto1.getOntology())).getDataProperties().size() + ((OWLOntology)(onto1.getOntology())).getObjectProperties().size();
+	    int nbprop2 = ((OWLOntology)(onto2.getOntology())).getDataProperties().size() + ((OWLOntology)(onto2.getOntology())).getObjectProperties().size();
 	    double[][] matrix = new double[nbprop1][nbprop2];
 	    OWLProperty[] prop1 = new OWLProperty[nbprop1];
 	    OWLProperty[] prop2 = new OWLProperty[nbprop2];
 	    int i = 0;
 	    ConcatenatedIterator pit1 = new 
-		ConcatenatedIterator(((OWLOntology)onto1).getObjectProperties().iterator(),
-				     ((OWLOntology)onto1).getDataProperties().iterator());
+		ConcatenatedIterator(((OWLOntology)(onto1.getOntology())).getObjectProperties().iterator(),
+				     ((OWLOntology)(onto1.getOntology())).getDataProperties().iterator());
 	    for (; pit1.hasNext(); i++) {
 		prop1[i] = (OWLProperty)pit1.next();
 	    }
 	    int j = 0;
 	    ConcatenatedIterator pit2 = new 
-		ConcatenatedIterator(((OWLOntology)onto2).getObjectProperties().iterator(),
-				     ((OWLOntology)onto2).getDataProperties().iterator());
+		ConcatenatedIterator(((OWLOntology)(onto2.getOntology())).getObjectProperties().iterator(),
+				     ((OWLOntology)(onto2.getOntology())).getDataProperties().iterator());
 	    for (; pit2.hasNext(); j++) {
 		prop2[j] = (OWLProperty)pit2.next();
 	    }
@@ -378,13 +381,13 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce
 	  // Plus a map from the objects to the cells
 	  // O(n^2.log n)
 	  ConcatenatedIterator pit1 = new 
-	      ConcatenatedIterator(((OWLOntology)onto1).getObjectProperties().iterator(),
-				    ((OWLOntology)onto1).getDataProperties().iterator());
+	      ConcatenatedIterator(((OWLOntology)(onto1.getOntology())).getObjectProperties().iterator(),
+				   ((OWLOntology)(onto1.getOntology())).getDataProperties().iterator());
 	  for (; pit1.hasNext(); ) {
 	      ent1 = (OWLProperty)pit1.next();
 	      ConcatenatedIterator pit2 = new 
-		  ConcatenatedIterator(((OWLOntology)onto2).getObjectProperties().iterator(),
-				       ((OWLOntology)onto2).getDataProperties().iterator());
+		  ConcatenatedIterator(((OWLOntology)(onto2.getOntology())).getObjectProperties().iterator(),
+					((OWLOntology)(onto2.getOntology())).getDataProperties().iterator());
 	      for (; pit2.hasNext(); ) {
 		  ent2 = (OWLProperty)pit2.next();
 		  val = 1 - sim.getPropertySimilarity((OWLProperty)ent1,(OWLProperty)ent2);
@@ -394,9 +397,9 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce
 		  }
 	      }
 	  }
-	  for (Iterator it1 = ((OWLOntology)onto1).getClasses().iterator(); it1.hasNext(); ) {
+	  for (Iterator it1 = ((OWLOntology)(onto1.getOntology())).getClasses().iterator(); it1.hasNext(); ) {
 	      ent1 = (OWLClass)it1.next();
-	      for (Iterator it2 = ((OWLOntology)onto2).getClasses().iterator(); it2.hasNext(); ) {
+	      for (Iterator it2 = ((OWLOntology)(onto2.getOntology())).getClasses().iterator(); it2.hasNext(); ) {
 		  ent2 = (OWLClass)it2.next();
 		  val = 1 - sim.getClassSimilarity((OWLClass)ent1,(OWLClass)ent2);
 		  //val = ((SimilarityMeasure)getSimilarity()).getSimilarity(ent1.getURI(),ent2.getURI());
@@ -407,11 +410,11 @@ public class DistanceAlignment extends OWLAPIAlignment implements AlignmentProce
 	  }
 	  // OLA with or without instances
 	  if (  params.getParameter("noinst") == null ){
-	      for (Iterator it1 = ((OWLOntology)onto1).getIndividuals().iterator(); it1.hasNext();) {
+	      for (Iterator it1 = ((OWLOntology)(onto1.getOntology())).getIndividuals().iterator(); it1.hasNext();) {
 		  ent1 = (OWLIndividual)it1.next();
 		  if ( ent1.getURI() != null ) {
 
-		      for (Iterator it2 = ((OWLOntology)onto2).getIndividuals().iterator(); it2.hasNext(); ) {
+		      for (Iterator it2 = ((OWLOntology)(onto2.getOntology())).getIndividuals().iterator(); it2.hasNext(); ) {
 			  ent2 = (OWLIndividual)it2.next();
 			  if ( ent2.getURI() != null ) {
 			      val = 1 - sim.getIndividualSimilarity((OWLIndividual)ent1,(OWLIndividual)ent2);
diff --git a/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java b/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java
index f2c88dfc..d36a5a85 100644
--- a/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java
+++ b/src/fr/inrialpes/exmo/align/impl/OWLAPIAlignment.java
@@ -56,32 +56,32 @@ import org.semanticweb.owl.align.Parameters;
 
 public class OWLAPIAlignment extends BasicAlignment {
 
-    //protected OWLOntology onto1 = null;
-
-    //protected OWLOntology onto2 = null;
-
     protected OWLAPIAlignment init = null;
 
-    public OWLAPIAlignment() {
-    }
+    public OWLAPIAlignment() {}
 
     public void init(Object onto1, Object onto2) throws AlignmentException {
 	init( onto1, onto2, (OntologyCache)null );
     }
 
-    public void init(Object onto1, Object onto2, Object ontologies) throws AlignmentException {
+    public void init(Object o1, Object o2, Object ontologies) throws AlignmentException {
 	OntologyCache cache = null;
 	if ( ontologies instanceof OntologyCache ) cache = (OntologyCache)ontologies;
 	else cache = (OntologyCache)null;
-	if ( onto1 instanceof OWLOntology && onto2 instanceof OWLOntology ){
-	    super.init( onto1, onto2, ontologies );
-	} else if ( onto1 instanceof URI && onto2 instanceof URI ) {
+	if ( (o1 instanceof OWLOntology && o2 instanceof OWLOntology)
+	     || (o1 instanceof Ontology && o2 instanceof Ontology) ){
+	    super.init( o1, o2, ontologies );
+	} else if ( o1 instanceof URI && o2 instanceof URI ) {
 	    // JE: This contains the File and not the URI!
-	    setFile1( (URI)onto1 );
-	    setFile2( (URI)onto2 );
+	    setFile1( (URI)o1 );
+	    setFile2( (URI)o2 );
+	    ((Ontology)onto1).setFormalism( "OWL1.0" );
+	    ((Ontology)onto2).setFormalism( "OWL1.0" );
+	    //onto1.setFormalismURI();
+	    //onto2.setFormalismURI();
 	    try {
-		super.init( loadOntology( getFile1(), cache ),
-			    loadOntology( getFile2(), cache ) );
+		super.init( loadOntology( (URI)o1, cache ),
+			    loadOntology( (URI)o2, cache ) );
 	    } catch (OWLException e) {
 		throw new AlignmentException( "Cannot load ontologies", e );
 	    } catch (SAXException e) {
@@ -109,7 +109,8 @@ public class OWLAPIAlignment extends BasicAlignment {
 
     public URI getOntology1URI() throws AlignmentException {
 	try {
-	    return ((OWLOntology)onto1).getLogicalURI();
+	    // JE: OWMG1
+	    return ((OWLOntology)(onto1.getOntology())).getLogicalURI();
 	} catch ( OWLException e ) {
 	    throw new AlignmentException( "URI conversion error for "+onto1, e );
 	}
@@ -117,7 +118,8 @@ public class OWLAPIAlignment extends BasicAlignment {
 
     public URI getOntology2URI() throws AlignmentException {
 	try {
-	    return ((OWLOntology)onto2).getLogicalURI();
+	    // JE: OWMG1
+	    return ((OWLOntology)(onto2.getOntology())).getLogicalURI();
 	} catch ( OWLException e ) {
 	    throw new AlignmentException( "URI conversion error for "+onto2, e );
 	}
@@ -216,7 +218,7 @@ public class OWLAPIAlignment extends BasicAlignment {
     public Object clone() {
 	OWLAPIAlignment align = new OWLAPIAlignment();
 	try {
-	    align.init( (OWLOntology)getOntology1(), (OWLOntology)getOntology2() );
+	    align.init( onto1, onto2 );
 	} catch ( AlignmentException e ) {};
 	align.setType( getType() );
 	align.setLevel( getLevel() );
@@ -264,6 +266,7 @@ public class OWLAPIAlignment extends BasicAlignment {
 	OWLAPIAlignment alignment = new OWLAPIAlignment();
 	//alignment.setFile1( al.getFile1() );
 	//alignment.setFile2( al.getFile2() );
+	System.err.println( "TOA: " + al.getFile1()+ " -- " + al.getFile2());
 	alignment.init( al.getFile1(), al.getFile2(), ontologies );
 	alignment.setType( al.getType() );
 	alignment.setLevel( al.getLevel() );
@@ -271,13 +274,16 @@ public class OWLAPIAlignment extends BasicAlignment {
 	    String label = (String)e.nextElement();
 	    alignment.setExtension( label, al.getExtension( label ) );
 	}
-	OWLOntology onto1 = (OWLOntology)alignment.getOntology1();
-	OWLOntology onto2 = (OWLOntology)alignment.getOntology2();
+	OWLOntology o1 = (OWLOntology)alignment.getOntology1();
+	OWLOntology o2 = (OWLOntology)alignment.getOntology2();
+	System.err.println( o1 );
 	for (Enumeration e = al.getElements(); e.hasMoreElements();) {
 	    Cell c = (Cell)e.nextElement();
+	    System.err.println( c.getObject1AsURI() );
+	    System.err.println( c.getObject2AsURI() );
 	    alignment.addAlignCell( c.getId(), 
-				    getEntity( onto1, c.getObject1AsURI() ),
-				    getEntity( onto2, c.getObject2AsURI() ),
+				    getEntity( o1, c.getObject1AsURI() ),
+				    getEntity( o2, c.getObject2AsURI() ),
 				    c.getRelation(), 
 				    c.getStrength(),
 				    c.getExtensions() );
diff --git a/src/fr/inrialpes/exmo/align/impl/Ontology.java b/src/fr/inrialpes/exmo/align/impl/Ontology.java
new file mode 100644
index 00000000..db126829
--- /dev/null
+++ b/src/fr/inrialpes/exmo/align/impl/Ontology.java
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) INRIA Rhône-Alpes, 2003-2007
+ * Copyright (C) CNR Pisa, 2005
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+package fr.inrialpes.exmo.align.impl;
+
+import java.net.URI;
+
+/**
+ * Store the information regarding ontologies in a specific structure
+ */
+
+public class Ontology {
+    protected URI uri = null;
+    protected URI file = null;
+    protected Object onto = null;
+    protected URI formalismURI = null;
+    protected String formalism = null;
+
+    public Ontology() {};
+
+    public URI getUri() { return uri; }
+    public URI getFile() { return file; }
+    public Object getOntology() { return onto; }
+    public URI getFormURI() { return formalismURI; }
+    public String getFormalism() { return formalism; }
+
+    public void setUri( URI uri ) { this.uri = uri; }
+    public void setFile( URI file ) { this.file = file; }
+    public void setOntology( Object o ) { this.onto = o; }
+    public void setFormURI( URI u ) { formalismURI = u; }
+    public void setFormalism( String name ) { formalism = name; }
+}
diff --git a/src/fr/inrialpes/exmo/align/impl/URIAlignment.java b/src/fr/inrialpes/exmo/align/impl/URIAlignment.java
index 871ba9a4..f6031c92 100644
--- a/src/fr/inrialpes/exmo/align/impl/URIAlignment.java
+++ b/src/fr/inrialpes/exmo/align/impl/URIAlignment.java
@@ -53,23 +53,23 @@ import org.semanticweb.owl.align.Parameters;
 
 public class URIAlignment extends BasicAlignment {
 
-    //protected URI onto1 = null;
+    public URIAlignment() {}
 
-    //protected URI onto2 = null;
-
-    public URIAlignment() {
-    }
-
-    public void init(URI onto1, URI onto2) throws AlignmentException {
-	if ( onto1 instanceof URI && onto2 instanceof URI ){
+    // JE: OMWG1, not sure it works...
+    public void init(Object o1, Object o2) throws AlignmentException {
+	if ( o1 instanceof Ontology && o2 instanceof Ontology ){
+	    super.init( o1, o2 );
+	} else if ( o1 instanceof URI && o2 instanceof URI ) {
 	    super.init( onto1, onto2 );
+	    this.onto1.setUri( (URI)o1 );
+	    this.onto2.setUri( (URI)o2 );
 	} else {
 	    throw new AlignmentException("arguments must be URIs");
 	};
     }
 
     public void setOntology1(Object ontology) throws AlignmentException {
-	if ( ontology instanceof URI ){
+	if ( ontology instanceof URI || ontology instanceof Ontology ){
 	    super.setOntology1( ontology );
 	} else {
 	    throw new AlignmentException("arguments must be URIs");
@@ -77,7 +77,7 @@ public class URIAlignment extends BasicAlignment {
     };
 
     public void setOntology2(Object ontology) throws AlignmentException {
-	if ( ontology instanceof URI ){
+	if ( ontology instanceof URI || ontology instanceof Ontology ){
 	    super.setOntology2( ontology );
 	} else {
 	    throw new AlignmentException("arguments must be URIs");
diff --git a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java
index c3feeff0..faec0a30 100644
--- a/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java
+++ b/src/fr/inrialpes/exmo/align/parser/AlignmentParser.java
@@ -20,6 +20,9 @@
 
 package fr.inrialpes.exmo.align.parser;
 
+// Imported OMWG classes
+import org.omwg.mediation.parser.alignment.XpathParser;
+
 //Imported SAX classes
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -30,10 +33,12 @@ import org.xml.sax.helpers.DefaultHandler;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
 
 //Imported JAVA classes
 import java.io.IOException;
 import java.io.StringReader;
+import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.lang.Integer;
@@ -45,6 +50,7 @@ import org.semanticweb.owl.align.Cell;
 import org.semanticweb.owl.align.AlignmentException;
 import org.semanticweb.owl.align.Parameters;
 
+import fr.inrialpes.exmo.align.impl.Ontology;
 import fr.inrialpes.exmo.align.impl.URIAlignment;
 import fr.inrialpes.exmo.align.impl.BasicParameters;
 
@@ -58,7 +64,8 @@ import fr.inrialpes.exmo.align.impl.BasicParameters;
  */
 
 public class AlignmentParser extends DefaultHandler {
-	
+
+    protected static String ALIGNNS = "http://knowledgeweb.semanticweb.org/heterogeneity/alignment";
     /**
      * level of debug/warning information
      */
@@ -72,12 +79,13 @@ public class AlignmentParser extends DefaultHandler {
     /**
      * the first Ontology 
      */
-    Object onto1 = null;
+    Ontology onto1 = null;
+    Ontology curronto = null;
     
     /**
      * the second Ontology 
      */
-    Object onto2 = null;
+    Ontology onto2 = null;
 
     /**
      * The currently loaded ontologies
@@ -90,7 +98,9 @@ public class AlignmentParser extends DefaultHandler {
      * This is a pitty but the idea of creating a particular alignment
      * is not in accordance with using an interface.
      */
-    protected URIAlignment alignment = null;
+    protected Alignment alignment = null;
+    // Used by the OMWGAlignments
+    //protected URIAlignment alignment = null;
     
     /**
      * the content found as text...
@@ -173,7 +183,10 @@ public class AlignmentParser extends DefaultHandler {
      * @param loaded should be replaced by OntologyCache (by useless)
      * @deprecated use parse( URI ) instead
      */
-    public Alignment parse( String uri, Hashtable loaded ) throws SAXException, IOException {
+    public Alignment parse( String uri, Hashtable loaded ) throws SAXException, IOException, XPathExpressionException {
+	// Determine which parser to use through the use of Xpath?
+	//private static final XPath XPATH = XPathFactory.newInstance().newXPath();
+	
 	//ontologies = loaded;
 	return parse( uri );
     }
@@ -184,13 +197,25 @@ public class AlignmentParser extends DefaultHandler {
      * parsed.
      * @param uri URI of the document to parse
      */
-    public Alignment parse( String uri ) throws SAXException, IOException {
+    public Alignment parse( String uri ) throws SAXException, IOException, XPathExpressionException {
 	this.uri = uri;
-	parser.parse(uri,this);
+	try { parser.parse(uri,this); }
+	catch (SAXException e) {
+	    if ( e.getMessage().equals("2OMWGAlignment") ) {
+		//alignment = new XpathParser().parse(((InputStream)new URL( uri ).openStream()));
+		alignment = new XpathParser().parse( new File( uri ) );
+	    } else {
+		throw e; // unfortunatelly
+	    }
+	}
 	return alignment;
     }
 
-    public Alignment parseString( String s ) throws SAXException, IOException {
+    /** 
+     * Parses a string instead of a URI
+     * @param s String the string to parse
+     */
+    public Alignment parseString( String s ) throws SAXException, IOException, XPathExpressionException {
 	parser.parse( new InputSource( new StringReader( s ) ),
 		      this );
 	return alignment;
@@ -209,7 +234,7 @@ public class AlignmentParser extends DefaultHandler {
 	if(debugMode > 2) 
 	    System.err.println("startElement AlignmentParser : " + pName);
 	parselevel++;
-	if(namespaceURI.equals("http://knowledgeweb.semanticweb.org/heterogeneity/alignment"))  {
+	if(namespaceURI.equals(ALIGNNS))  {
 	    if (pName.equals("relation")) {
 	    } else if (pName.equals("semantics")) {
 	    } else if (pName.equals("measure")) {
@@ -245,13 +270,32 @@ public class AlignmentParser extends DefaultHandler {
 		cl2 = null;
 	    } else if (pName.equals("map")) {
 		try {
-		    alignment.setOntology2( onto2 );
-		    alignment.setOntology1( onto1 );
+		    // JE: OMWG1 //NOT SURE
+		    alignment.init( onto1, onto2 );
 		} catch ( AlignmentException e ) {
 		    throw new SAXException("Catched alignment exception", e );
 		}
+	    } else if (pName.equals("Formalism")) {
+		// JE: OMWG1 leave it alone for the moment
+		//if ( atts.getValue("uri") != null )
+		//    curronto.setFormalismURI( new URI(atts.getValue("uri")) );
+		if ( atts.getValue("name") != null )
+		    curronto.setFormalism( atts.getValue("name") );
+	    } else if (pName.equals("formalism")) {
+	    } else if (pName.equals("location")) {
+	    } else if (pName.equals("Ontology")) {
+		if ( atts.getValue("rdf:about") != null && !atts.getValue("rdf:about").equals("") ) {
+			try {
+			    curronto.setOntology( new URI( atts.getValue("rdf:about") ) );
+			    curronto.setUri( new URI( atts.getValue("rdf:about") ) );
+			} catch (URISyntaxException e) {
+			    throw new SAXException("onto2: malformed URI");
+			}
+		}
 	    } else if (pName.equals("onto2")) {
+		curronto = onto2;
 	    } else if (pName.equals("onto1")) {
+		curronto = onto1;
 	    } else if (pName.equals("uri2")) {
 	    } else if (pName.equals("uri1")) {
 	    } else if (pName.equals("type")) {
@@ -259,6 +303,8 @@ public class AlignmentParser extends DefaultHandler {
 	    } else if (pName.equals("xml")) {
 	    } else if (pName.equals("Alignment")) {
 		alignment = new URIAlignment();
+		onto1 = new Ontology();
+		onto2 = new Ontology();
 	    } else {
 		if ( debugMode > 0 ) System.err.println("[AlignmentParser] Unknown element name : "+pName);
 	    };
@@ -266,7 +312,7 @@ public class AlignmentParser extends DefaultHandler {
 	    if ( !pName.equals("RDF") ) {
 		throw new SAXException("[AlignmentParser] unknown element name: "+pName); };
 	} else {
-	    if ( parselevel != 2 ) throw new SAXException("[AlignmentParser] Unknown namespace : "+namespaceURI);
+	    if ( parselevel != 3 && parselevel != 5 ) throw new SAXException("[AlignmentParser("+parselevel+")] Unknown namespace : "+namespaceURI);
 	}
     }
 
@@ -318,10 +364,10 @@ public class AlignmentParser extends DefaultHandler {
      * @param pName 			The local name of the current element
      * @param qname					The name of the current element 
      */
-    public  void endElement(String namespaceURI,String pName, String qName ) throws SAXException {
+    public  void endElement(String namespaceURI, String pName, String qName ) throws SAXException {
 	if(debugMode > 2) 
 	    System.err.println("endElement AlignmentParser : " + pName);
-	if(namespaceURI.equals("http://knowledgeweb.semanticweb.org/heterogeneity/alignment"))  {
+	if(namespaceURI.equals(ALIGNNS))  {
 	    try {
 		if (pName.equals("relation")) {
 		    relation = content;
@@ -352,31 +398,54 @@ public class AlignmentParser extends DefaultHandler {
 		    if ( extensions != null ) cell.setExtensions( extensions );
 		} else if (pName.equals("map")) {
 		} else if (pName.equals("uri1")) {
-		    try {
-			onto1 = new URI( content );
-		    } catch (URISyntaxException e) {
-			throw new SAXException("uri1: malformed URI");
+		    if ( onto1.getOntology() != null ){
+			try {
+			    // JE: OMWG1
+			    URI u = new URI( content );
+			    onto1.setOntology( u );
+			    onto1.setUri( u );
+			} catch (URISyntaxException e) {
+			    throw new SAXException("uri1: malformed URI");
+			}
 		    }
 		} else if (pName.equals("uri2")) {
-		    try {
-			onto2 = new URI( content );
-		    } catch (URISyntaxException e) {
-			throw new SAXException("uri2: malformed URI");
+		    if ( onto2.getOntology() != null ){
+			try {
+			    // JE: OMWG1
+			    URI u = new URI( content );
+			    onto2.setOntology( u );
+			    onto2.setUri( u );
+			} catch (URISyntaxException e) {
+			    throw new SAXException("uri2: malformed URI");
+			}
 		    }
-		} else if (pName.equals("onto2")) {
-		    try { alignment.setFile2( new URI( content ) );
+		// JE: OMWG1
+		} else if (pName.equals("Ontology")) {
+		} else if (pName.equals("location")) {
+		    try { curronto.setFile( new URI( content ) );
 		    } catch (URISyntaxException e) {
 			throw new SAXException("onto2: malformed URI");
 		    }
-		} else if (pName.equals("onto1")) {
-		    try { alignment.setFile1( new URI( content ) );
-		    } catch (URISyntaxException e) {
-			throw new SAXException("onto1: malformed URI");
-		    }
+		} else if (pName.equals("Formalism")) {
+		} else if (pName.equals("formalism")) {
+		} else if (pName.equals("onto1") || pName.equals("onto2")) {
+		    if ( curronto.getFile() == null && 
+			 content != null && !content.equals("") ) {
+			try { curronto.setFile( new URI( content ) );
+			} catch (URISyntaxException e) {
+			    throw new SAXException(pName+": malformed URI");
+			}
+		    };
+		    curronto = null;
 		} else if (pName.equals("type")) {
 		    alignment.setType( content );
 		} else if (pName.equals("level")) {
-		    alignment.setLevel( content );
+		    if ( content.equals("2OMWG") ) {
+			//throw new AlignmentException("2OMWGAlignment");
+			throw new SAXException("2OMWGAlignment");
+		    } else {
+			alignment.setLevel( content );
+		    }
 		} else if (pName.equals("xml")) {
 		    //if ( content.equals("no") )
 		    //	{ throw new SAXException("Non parseable alignment"); }
@@ -385,9 +454,7 @@ public class AlignmentParser extends DefaultHandler {
 		    if ( parselevel == 3 ){
 			alignment.setExtension( pName, content );
 		    } else if ( parselevel == 5 ) {
-			if ( extensions == null ) extensions = new BasicParameters();
-			//cell.setExtension( pName, content );
-			extensions.setParameter( pName, content );
+			    extensions.setParameter( pName, content );
 		    } else //if ( debugMode > 0 )
 			System.err.println("[AlignmentParser] Unknown element name : "+pName);
 		    //throw new SAXException("[AlignmentParser] Unknown element name : "+pName);
@@ -398,11 +465,12 @@ public class AlignmentParser extends DefaultHandler {
 		throw new SAXException("[AlignmentParser] unknown element name: "+pName); };
 	} else {
 	    if ( parselevel == 3 ){
-		alignment.setExtension( pName, content );
+		alignment.setExtension( qName, content );
+		//alignment.addNamespace( namespaceURI, );
 	    } else if ( parselevel == 5 ) {
 		if ( extensions == null ) extensions = new BasicParameters();
-		//cell.setExtension( pName, content );
-		extensions.setParameter( pName, content );
+		extensions.setParameter( qName, content );
+		//alignment.addNamespace( namespaceURI, );
 	    } else throw new SAXException("[AlignmentParser] Unknown namespace : "+namespaceURI);
 	}
 	parselevel--;
-- 
GitLab