Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] programmatically transformation UML2OWL with EMF
[ATL] programmatically transformation UML2OWL with EMF [message #68739] Tue, 11 December 2007 10:29 Go to next message
Eclipse UserFriend
Originally posted by: valerio.summo.gmail.com

Hi all,
I have an UML file (conform to UML 2.0) and I want to programmatically
trasform it into an OWL file through an ATL transformation UML2OWL with EMF.

This is the build.xml, that works fine:

<am3.loadModel name="umlModel" metamodel="UML"
path="/UML2OWL/Samples/UMLModels/${model}.uml"/>
<am3.atl path="/UML2OWL/UML2OWL.asm">
<inModel name="IN" model="umlModel"/>
<inModel name="UML" model="UML"/>
<inModel name="OWL" model="OWL"/>
<outModel name="OUT" model="owlModel" metamodel="OWL"/>
</am3.atl>
<am3.saveModel model="owlModel"
path="/UML2OWL/Samples/OWLModels/${model}-OWL.ecore"/>
<am3.atl path="/UML2OWL/OWL/XmlSyntax/OWL2XML.asm">
<inModel name="IN" model="owlModel"/>
<inModel name="OWL" model="OWL"/>
<inModel name="XML" model="XML"/>
<outModel name="OUT" model="xmlModel" metamodel="XML"/>
</am3.atl>
<am3.saveModel model="xmlModel"
path="/UML2OWL/Samples/OWLFiles/${model}.owl">
<extractor name="xml"/>
</am3.saveModel>
</target>
<target name="loadModels">
<!-- Load UML 2.0 metamodel-->
<am3.loadModel modelHandler="EMF" name="UML" metamodel="MOF"
nsuri="http://www.eclipse.org/uml2/2.0.0/UML"/>
<!-- Load OWL metamodel-->
<am3.loadModel modelHandler="EMF" name="OWL" metamodel="MOF"
path="/UML2OWL/OWL/OWL.ecore"/>
<!-- Load XML metamodel-->
<am3.loadModel modelHandler="EMF" name="XML" metamodel="MOF"
path="/UML2OWL/AMMACore/XML.ecore"/>
</target>

and these are my code lines:

private AtlEMFModelHandler emfamh = (AtlEMFModelHandler)
AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);
private URL UmlMM2OwlMMurl =
ATLTransformations.class.getResource(transformationsLocation +
"UML2OWL.asm");
private URL OwlMM2XMLOwlMMurl =
ATLTransformations.class.getResource(transformationsLocation +
"OWL2XML.asm");

private ASMModel umlMM_EMF = emfamh.loadModel("UML", this.emfamh.getMof(),
"uri:http://www.eclipse.org/uml2/2.1.0/UML");
private ASMModel xmlEMFmm = emfamh.loadModel("XML", emfamh.getMof(),
"xml/xml.ecore");
private ASMModel owlMM_EMF = emfamh.loadModel("OWL", emfamh.getMof(),
"ecore/OWL.ecore");
String umlFile = "sample.uml";

ASMModel umlModel = emfamh.loadModel("IN", umlMM_EMF,
URI.createURI(umlFile));
ASMModel owlModel = getOwlMMFromUmlMM(umlModel);
ASMModel xmlOwlModel = getXMLOwlMMFromOwlMM(owlModel);
extractXMLModelToFile(xmlOwlModel, OutputOtherFile);

When I launch it, I get the following exception:

Exception in thread "main" java.util.NoSuchElementException
at
java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedH ashMap.java:382)
at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java: 391)
at
org.eclipse.m2m.atl.engine.extractors.xml.XMLExtractor.extra ct(XMLExtractor.java:45)
at
org.eclipse.m2m.atl.engine.extractors.xml.XMLExtractor.extra ct(XMLExtractor.java:32)
at
com.ibm.rst.sica.UML2OWLConverter.ATLTransformations.extract XMLModelToFile(ATLTransformations.java:347)

in the extractXMLModelToFile(xmlOwlModel, OutputOtherFile) method:

public void extractXMLModelToFile(ASMModel model, String file) {
OutputStream out = null;
Map parameters = Collections.EMPTY_MAP;
XMLExtractor xmle = new XMLExtractor();
try {
out = new FileOutputStream(file);
xmle.extract(model, out, parameters);
out.flush(); out.close(); // close stream
} catch(FileNotFoundException f) {
} catch(IOException io) {
}
}

Please, could you suggest me what I could do to solve the problem?
Many thanks in advance!
Valerio
Re: [ATL] programmatically transformation UML2OWL with EMF [message #69159 is a reply to message #68739] Wed, 12 December 2007 17:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: valerio.summo.gmail.com

Moreover, after these code lines:

ASMModel umlModel = emfamh.loadModel("IN", umlMM_EMF,
URI.createURI(umlFile));
ASMModel owlModel = getOwlMMFromUmlMM(umlModel);

if I put:

emfamh.saveModel(owlModel, "metamodels/ecore/inputUML.ecore", false);

I get an empty inputUML.ecore file, with just these content:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>

Please, any help?



"Valerio Summo" <valerio.summo@gmail.com> wrote in message
news:fjlopq$sru$1@build.eclipse.org...
> Hi all,
> I have an UML file (conform to UML 2.0) and I want to programmatically
> trasform it into an OWL file through an ATL transformation UML2OWL with
> EMF.
>
> This is the build.xml, that works fine:
>
> <am3.loadModel name="umlModel" metamodel="UML"
> path="/UML2OWL/Samples/UMLModels/${model}.uml"/>
> <am3.atl path="/UML2OWL/UML2OWL.asm">
> <inModel name="IN" model="umlModel"/>
> <inModel name="UML" model="UML"/>
> <inModel name="OWL" model="OWL"/>
> <outModel name="OUT" model="owlModel" metamodel="OWL"/>
> </am3.atl>
> <am3.saveModel model="owlModel"
> path="/UML2OWL/Samples/OWLModels/${model}-OWL.ecore"/>
> <am3.atl path="/UML2OWL/OWL/XmlSyntax/OWL2XML.asm">
> <inModel name="IN" model="owlModel"/>
> <inModel name="OWL" model="OWL"/>
> <inModel name="XML" model="XML"/>
> <outModel name="OUT" model="xmlModel" metamodel="XML"/>
> </am3.atl>
> <am3.saveModel model="xmlModel"
> path="/UML2OWL/Samples/OWLFiles/${model}.owl">
> <extractor name="xml"/>
> </am3.saveModel>
> </target>
> <target name="loadModels">
> <!-- Load UML 2.0 metamodel-->
> <am3.loadModel modelHandler="EMF" name="UML" metamodel="MOF"
> nsuri="http://www.eclipse.org/uml2/2.0.0/UML"/>
> <!-- Load OWL metamodel-->
> <am3.loadModel modelHandler="EMF" name="OWL" metamodel="MOF"
> path="/UML2OWL/OWL/OWL.ecore"/>
> <!-- Load XML metamodel-->
> <am3.loadModel modelHandler="EMF" name="XML" metamodel="MOF"
> path="/UML2OWL/AMMACore/XML.ecore"/>
> </target>
>
> and these are my code lines:
>
> private AtlEMFModelHandler emfamh = (AtlEMFModelHandler)
> AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);
> private URL UmlMM2OwlMMurl =
> ATLTransformations.class.getResource(transformationsLocation +
> "UML2OWL.asm");
> private URL OwlMM2XMLOwlMMurl =
> ATLTransformations.class.getResource(transformationsLocation +
> "OWL2XML.asm");
>
> private ASMModel umlMM_EMF = emfamh.loadModel("UML", this.emfamh.getMof(),
> "uri:http://www.eclipse.org/uml2/2.1.0/UML");
> private ASMModel xmlEMFmm = emfamh.loadModel("XML", emfamh.getMof(),
> "xml/xml.ecore");
> private ASMModel owlMM_EMF = emfamh.loadModel("OWL", emfamh.getMof(),
> "ecore/OWL.ecore");
> String umlFile = "sample.uml";
>
> ASMModel umlModel = emfamh.loadModel("IN", umlMM_EMF,
> URI.createURI(umlFile));
> ASMModel owlModel = getOwlMMFromUmlMM(umlModel);
> ASMModel xmlOwlModel = getXMLOwlMMFromOwlMM(owlModel);
> extractXMLModelToFile(xmlOwlModel, OutputOtherFile);
>
> When I launch it, I get the following exception:
>
> Exception in thread "main" java.util.NoSuchElementException
> at
> java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedH ashMap.java:382)
> at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java: 391)
> at
> org.eclipse.m2m.atl.engine.extractors.xml.XMLExtractor.extra ct(XMLExtractor.java:45)
> at
> org.eclipse.m2m.atl.engine.extractors.xml.XMLExtractor.extra ct(XMLExtractor.java:32)
> at
> com.ibm.rst.sica.UML2OWLConverter.ATLTransformations.extract XMLModelToFile(ATLTransformations.java:347)
>
> in the extractXMLModelToFile(xmlOwlModel, OutputOtherFile) method:
>
> public void extractXMLModelToFile(ASMModel model, String file) {
> OutputStream out = null;
> Map parameters = Collections.EMPTY_MAP;
> XMLExtractor xmle = new XMLExtractor();
> try {
> out = new FileOutputStream(file);
> xmle.extract(model, out, parameters);
> out.flush(); out.close(); // close stream
> } catch(FileNotFoundException f) {
> } catch(IOException io) {
> }
> }
>
> Please, could you suggest me what I could do to solve the problem?
> Many thanks in advance!
> Valerio
>
Re: [ATL] programmatically transformation UML2OWL with EMF [message #69526 is a reply to message #69159] Thu, 13 December 2007 18:05 Go to previous message
Eclipse UserFriend
Originally posted by: valerio.summo.gmail.com

Thank you very much to Milan,

I have finally solved the problem.

The correct way to Register UML is:



UMLPackage umlPackage = UMLPackage.eINSTANCE;

EPackage.Registry.INSTANCE.put(umlPackage.getNsURI(), umlPackage);

ResourceSet set = new ResourceSetImpl();

set.getPackageRegistry().put(umlPackage.getNsURI(), umlPackage);

/*

* Load metamodel

*/

umlMM_EMF = emfamh.loadModel("UML", this.emfamh.getMof(),
"uri:http://www.eclipse.org/uml2/2.1.0/UML");



Now the model is loaded in the correct way and it works!



"Valerio Summo" <valerio.summo@gmail.com> wrote in message
news:fjp4re$6gm$1@build.eclipse.org...
> Moreover, after these code lines:
>
> ASMModel umlModel = emfamh.loadModel("IN", umlMM_EMF,
> URI.createURI(umlFile));
> ASMModel owlModel = getOwlMMFromUmlMM(umlModel);
>
> if I put:
>
> emfamh.saveModel(owlModel, "metamodels/ecore/inputUML.ecore", false);
>
> I get an empty inputUML.ecore file, with just these content:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
>
> Please, any help?
>
>
>
> "Valerio Summo" <valerio.summo@gmail.com> wrote in message
> news:fjlopq$sru$1@build.eclipse.org...
>> Hi all,
>> I have an UML file (conform to UML 2.0) and I want to programmatically
>> trasform it into an OWL file through an ATL transformation UML2OWL with
>> EMF.
>>
>> This is the build.xml, that works fine:
>>
>> <am3.loadModel name="umlModel" metamodel="UML"
>> path="/UML2OWL/Samples/UMLModels/${model}.uml"/>
>> <am3.atl path="/UML2OWL/UML2OWL.asm">
>> <inModel name="IN" model="umlModel"/>
>> <inModel name="UML" model="UML"/>
>> <inModel name="OWL" model="OWL"/>
>> <outModel name="OUT" model="owlModel" metamodel="OWL"/>
>> </am3.atl>
>> <am3.saveModel model="owlModel"
>> path="/UML2OWL/Samples/OWLModels/${model}-OWL.ecore"/>
>> <am3.atl path="/UML2OWL/OWL/XmlSyntax/OWL2XML.asm">
>> <inModel name="IN" model="owlModel"/>
>> <inModel name="OWL" model="OWL"/>
>> <inModel name="XML" model="XML"/>
>> <outModel name="OUT" model="xmlModel" metamodel="XML"/>
>> </am3.atl>
>> <am3.saveModel model="xmlModel"
>> path="/UML2OWL/Samples/OWLFiles/${model}.owl">
>> <extractor name="xml"/>
>> </am3.saveModel>
>> </target>
>> <target name="loadModels">
>> <!-- Load UML 2.0 metamodel-->
>> <am3.loadModel modelHandler="EMF" name="UML" metamodel="MOF"
>> nsuri="http://www.eclipse.org/uml2/2.0.0/UML"/>
>> <!-- Load OWL metamodel-->
>> <am3.loadModel modelHandler="EMF" name="OWL" metamodel="MOF"
>> path="/UML2OWL/OWL/OWL.ecore"/>
>> <!-- Load XML metamodel-->
>> <am3.loadModel modelHandler="EMF" name="XML" metamodel="MOF"
>> path="/UML2OWL/AMMACore/XML.ecore"/>
>> </target>
>>
>> and these are my code lines:
>>
>> private AtlEMFModelHandler emfamh = (AtlEMFModelHandler)
>> AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);
>> private URL UmlMM2OwlMMurl =
>> ATLTransformations.class.getResource(transformationsLocation +
>> "UML2OWL.asm");
>> private URL OwlMM2XMLOwlMMurl =
>> ATLTransformations.class.getResource(transformationsLocation +
>> "OWL2XML.asm");
>>
>> private ASMModel umlMM_EMF = emfamh.loadModel("UML",
>> this.emfamh.getMof(), "uri:http://www.eclipse.org/uml2/2.1.0/UML");
>> private ASMModel xmlEMFmm = emfamh.loadModel("XML", emfamh.getMof(),
>> "xml/xml.ecore");
>> private ASMModel owlMM_EMF = emfamh.loadModel("OWL", emfamh.getMof(),
>> "ecore/OWL.ecore");
>> String umlFile = "sample.uml";
>>
>> ASMModel umlModel = emfamh.loadModel("IN", umlMM_EMF,
>> URI.createURI(umlFile));
>> ASMModel owlModel = getOwlMMFromUmlMM(umlModel);
>> ASMModel xmlOwlModel = getXMLOwlMMFromOwlMM(owlModel);
>> extractXMLModelToFile(xmlOwlModel, OutputOtherFile);
>>
>> When I launch it, I get the following exception:
>>
>> Exception in thread "main" java.util.NoSuchElementException
>> at
>> java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedH ashMap.java:382)
>> at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java: 391)
>> at
>> org.eclipse.m2m.atl.engine.extractors.xml.XMLExtractor.extra ct(XMLExtractor.java:45)
>> at
>> org.eclipse.m2m.atl.engine.extractors.xml.XMLExtractor.extra ct(XMLExtractor.java:32)
>> at
>> com.ibm.rst.sica.UML2OWLConverter.ATLTransformations.extract XMLModelToFile(ATLTransformations.java:347)
>>
>> in the extractXMLModelToFile(xmlOwlModel, OutputOtherFile) method:
>>
>> public void extractXMLModelToFile(ASMModel model, String file) {
>> OutputStream out = null;
>> Map parameters = Collections.EMPTY_MAP;
>> XMLExtractor xmle = new XMLExtractor();
>> try {
>> out = new FileOutputStream(file);
>> xmle.extract(model, out, parameters);
>> out.flush(); out.close(); // close stream
>> } catch(FileNotFoundException f) {
>> } catch(IOException io) {
>> }
>> }
>>
>> Please, could you suggest me what I could do to solve the problem?
>> Many thanks in advance!
>> Valerio
>>
>
>
Previous Topic:Why UML2 driver? What's the difference to the EMF driver?
Next Topic:[ATL] Jar files instead of plug-in dependencies?
Goto Forum:
  


Current Time: Sun Apr 11 22:51:18 GMT 2021

Powered by FUDForum. Page generated in 0.02552 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top