diff --git a/examples/omwg/total.xml b/examples/omwg/total.xml index 8f4de9f460847337a6629dd7754d0495a1fa1255..f296d6fede46c37ebb7c02db99eda9db2becb6de 100644 --- a/examples/omwg/total.xml +++ b/examples/omwg/total.xml @@ -272,7 +272,7 @@ </edoal:Property> </edoal:onAttribute> <edoal:comparator rdf:resource="&xsd;equals"/> - <edoal:value><edoal:Literal edoal:string="33"/></edoal:value> + <edoal:value><edoal:Literal edoal:type="&xsd;int" edoal:string="33"/></edoal:value> </edoal:AttributeValueRestriction> <edoal:AttributeValueRestriction> <edoal:onAttribute> @@ -319,11 +319,11 @@ <edoal:value> <edoal:Apply edoal:operator="http://example.org/mydummyoperation/"> <edoal:arguments rdf:parseType="Collection"> - <edoal:Literal edoal:string="43"/> + <edoal:Literal edoal:type="&xsd;int" edoal:string="43"/> <edoal:Property rdf:about="&vin;matrid"/> <edoal:Apply edoal:operator="http://example.org/mydummyoperation2/"> <edoal:arguments rdf:parseType="Collection"> - <edoal:Literal edoal:string="22"/> + <edoal:Literal edoal:type="&xsd;int" edoal:string="22"/> <edoal:Property rdf:about="&vin;matrid"/> <edoal:Apply edoal:operator="http://example.org/mydummyoperation3/"> <edoal:arguments rdf:parseType="Collection"/> @@ -716,7 +716,7 @@ <edoal:Apply edoal:operator="concat"> <edoal:arguments rdf:parseType="Collection"> <edoal:Property rdf:about="vcard:firstname"/> - <edoal:Literal edoal:string=" "/> + <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=". "/> diff --git a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java index be2ae828359d041c88eb100ea3198c76009f955e..d5e70bf137296019c9ab521ba5450a811488a5b4 100644 --- a/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java +++ b/src/fr/inrialpes/exmo/align/impl/renderer/RDFRendererVisitor.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA, 2003-2010 + * Copyright (C) INRIA, 2003-2010, 2012 * * 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 @@ -81,6 +81,7 @@ import fr.inrialpes.exmo.align.impl.edoal.Apply; import fr.inrialpes.exmo.align.impl.edoal.Datatype; import fr.inrialpes.exmo.align.impl.edoal.Comparator; import fr.inrialpes.exmo.align.impl.edoal.EDOALCell; +import fr.inrialpes.exmo.align.impl.edoal.EDOALVisitor; /** * Renders an alignment in its RDF format @@ -89,7 +90,7 @@ import fr.inrialpes.exmo.align.impl.edoal.EDOALCell; * @version $Id$ */ -public class RDFRendererVisitor extends IndentedRendererVisitor implements AlignmentVisitor { +public class RDFRendererVisitor extends IndentedRendererVisitor implements AlignmentVisitor,EDOALVisitor { Alignment alignment = null; Cell cell = null; @@ -136,6 +137,7 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align else if ( o instanceof Cell ) visit( (Cell)o ); else if ( o instanceof Relation ) visit( (Relation)o ); else if ( o instanceof Alignment ) visit( (Alignment)o ); + else throw new AlignmentException( "Cannot dispatch expression "+o ); } public void visit( Alignment align ) throws AlignmentException { @@ -331,7 +333,10 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align }; public void visit( Expression o ) throws AlignmentException { - throw new AlignmentException("Cannot export abstract Expression: "+o ); + if ( o instanceof PathExpression ) visit( (PathExpression)o ); + else if ( o instanceof ClassExpression ) visit( (ClassExpression)o ); + else if ( o instanceof InstanceExpression ) visit( (InstanceExpression)o ); + else throw new AlignmentException( "Cannot dispatch Expression "+o ); } // DONE @@ -378,7 +383,7 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align if ( (op == Constructor.AND) || (op == Constructor.OR) ) writer.print(" "+SyntaxElement.RDF_PARSETYPE.print(DEF)+"=\"Collection\""); writer.print(">"+NL); increaseIndent(); - for (final ClassExpression ce : e.getComponents()) { + for ( final ClassExpression ce : e.getComponents() ) { writer.print(linePrefix); visit( ce ); writer.print(NL); @@ -714,12 +719,11 @@ public class RDFRendererVisitor extends IndentedRendererVisitor implements Align } public void visit( final Value e ) throws AlignmentException { - indentedOutput("<"+SyntaxElement.LITERAL.print(DEF)+" "+SyntaxElement.STRING.print(DEF)+"=\""); - writer.print(e.getValue()); + indentedOutput("<"+SyntaxElement.LITERAL.print(DEF)+" "); if ( e.getType() != null ) { - writer.print(" "+SyntaxElement.TYPE.print(DEF)+"=\""+e.getType()+"\""); + writer.print(SyntaxElement.ETYPE.print(DEF)+"=\""+e.getType()+"\" "); } - writer.print("\"/>"); + writer.print(SyntaxElement.STRING.print(DEF)+"=\""+e.getValue()+"\"/>"); } public void visit( final Apply e ) throws AlignmentException { diff --git a/src/fr/inrialpes/exmo/align/parser/RDFParser.java b/src/fr/inrialpes/exmo/align/parser/RDFParser.java index 008e6bc4620d39faef7bbf2c243884a2b8a43b0b..8b4e7124313d2dee844693ba889ca166efaa157e 100644 --- a/src/fr/inrialpes/exmo/align/parser/RDFParser.java +++ b/src/fr/inrialpes/exmo/align/parser/RDFParser.java @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Sourceforge version 1.7 - 2008 - * Copyright (C) INRIA, 2008-2010 + * Copyright (C) INRIA, 2008-2010, 2012 * * 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 @@ -801,12 +801,17 @@ public class RDFParser { return parseInstance( (Resource)node ); } else if ( nodeType.equals( SyntaxElement.LITERAL.resource ) ) { if ( ((Resource)node).hasProperty( (Property)SyntaxElement.STRING.resource ) ) { - if ( ((Resource)node).hasProperty( (Property)SyntaxElement.TYPE.resource ) ) { + URI u = null; + if ( ((Resource)node).hasProperty( (Property)SyntaxElement.ETYPE.resource ) ) { try { - return new Value( ((Resource)node).getProperty( (Property)SyntaxElement.STRING.resource ).getLiteral().getString(), new URI( ((Resource)node).getProperty( (Property)SyntaxElement.TYPE.resource ).getLiteral().getString() ) ); + u = new URI( ((Resource)node).getProperty( (Property)SyntaxElement.ETYPE.resource ).getLiteral().getString() ); } catch (URISyntaxException urisex) { - throw new AlignmentException( "Incorect URI for edoal:type : "+ ((Resource)node).getProperty( (Property)SyntaxElement.TYPE.resource ).getLiteral().getString() ); + //throw new AlignmentException( "Incorect URI for edoal:type : "+ ((Resource)node).getProperty( (Property)SyntaxElement.TYPE.resource ).getLiteral().getString() ); + urisex.printStackTrace(); } + } + if ( u != null ) { + return new Value( ((Resource)node).getProperty( (Property)SyntaxElement.STRING.resource ).getLiteral().getString(), u ); } else { return new Value( ((Resource)node).getProperty( (Property)SyntaxElement.STRING.resource ).getLiteral().getString() ); } diff --git a/src/fr/inrialpes/exmo/align/parser/SyntaxElement.java b/src/fr/inrialpes/exmo/align/parser/SyntaxElement.java index d34b86a9625c40960dc1091658012822da6d53e9..62f9204be691c6e7dafd1764bebc79418a8ac00b 100644 --- a/src/fr/inrialpes/exmo/align/parser/SyntaxElement.java +++ b/src/fr/inrialpes/exmo/align/parser/SyntaxElement.java @@ -4,7 +4,7 @@ * Copyright (C) 2006 Digital Enterprise Research Insitute (DERI) Innsbruck * Copyright (C) 2005 Digital Enterprise Research Insitute (DERI) Galway * Sourceforge version 1.6 - 2008 - then OmwgElement - * Copyright (C) INRIA, 2008-2010 + * Copyright (C) INRIA, 2008-2010, 2012 * * 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 @@ -117,6 +117,7 @@ public enum SyntaxElement { RELATION_EXPR( Namespace.EDOAL, "Relation", true), //SERVICE( Namespace.EDOAL, "service"), STRING( Namespace.EDOAL, "string"), + ETYPE( Namespace.EDOAL, "type"), SYMMETRIC( Namespace.EDOAL, "symmetric", Constructor.SYMMETRIC), TOCLASS( Namespace.EDOAL, "class"), ALL( Namespace.EDOAL, "all"),