Home » Modeling » EMF » EMF and ArgoUML
EMF and ArgoUML [message #714242] |
Wed, 10 August 2011 06:22 |
Eclipse User |
|
|
|
Originally posted by: Emil Huseynli
Hello,
I'm generating XMI-file by following code:
> private void testEMF(MModel model) {
> // Create a resource set.
> ResourceSet resourceSet = new ResourceSetImpl();
>
> // Register the default resource factory -- only needed for stand-alone!
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
> Resource.Factory.Registry.DEFAULT_EXTENSION, new CustomXMIResourceFactoryImpl());
>
> // Get the URI of the model file.
> URI fileURI = URI.createFileURI(new File("mylibrary.xmi").getAbsolutePath());
>
> // Create a resource for this file.
> Resource resource = resourceSet.createResource(fileURI);
>
> EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
> EClass purchaseOrderClass = ecoreFactory.createEClass();
> purchaseOrderClass.setName("PurchaseOrder");
> EAttribute shipTo = ecoreFactory.createEAttribute();
> shipTo.setName("shipTo");
> shipTo.setEType(EcorePackage.Literals.ESTRING);
> purchaseOrderClass.getEStructuralFeatures().add(shipTo);
>
> EPackage poPackage = ecoreFactory.createEPackage();
> poPackage.setName("po");
> poPackage.setNsPrefix("po");
> poPackage.setNsURI("http://www.example.com/SimplePO");
> poPackage.getEClassifiers().add(purchaseOrderClass);
>
> resource.getContents().add(poPackage);
>
> // Save the contents of the resource to the file system.
> try
> {
> resource.save(Collections.EMPTY_MAP);
> }
> catch (IOException e) {}
> }
Resulted XMI-file content is:
> <?xml version="1.0" encoding="ASCII"?>
> <ecore:EPackage xmi:version="1.2" xmlns:xmi="http://schema.omg.org/spec/XMI/1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="po" nsURI="http://www.example.com/SimplePO" nsPrefix="po">
> <eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="shipTo">
> <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
Trying to import that XMI-file in other UML-tools, such as ArgoUML or
Umbrello fails, exceptions are different during parsing, i'll post them,
but think something is absolutely wrong with my XMI, can anybody explain
what i'm doing wrong?
Best regards,
Emil
|
|
|
Re: EMF and ArgoUML [message #714390 is a reply to message #714242] |
Wed, 10 August 2011 13:08 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Emil,
I'm not sure why you'd expect a UML tool to import Ecore instances. If
you want something UML tools can interchange, you need to be looking at
the UML2 project; it provides an API for creating UML2 instances.
On 09/08/2011 11:22 PM, Emil Huseynli wrote:
> Hello,
>
> I'm generating XMI-file by following code:
>
>> private void testEMF(MModel model) {
>> // Create a resource set.
>> ResourceSet resourceSet = new ResourceSetImpl();
>>
>> // Register the default resource factory -- only needed for
>> stand-alone!
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
>> Resource.Factory.Registry.DEFAULT_EXTENSION, new
>> CustomXMIResourceFactoryImpl());
>>
>> // Get the URI of the model file.
>> URI fileURI = URI.createFileURI(new
>> File("mylibrary.xmi").getAbsolutePath());
>>
>> // Create a resource for this file.
>> Resource resource = resourceSet.createResource(fileURI);
>>
>> EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
>> EClass purchaseOrderClass = ecoreFactory.createEClass();
>> purchaseOrderClass.setName("PurchaseOrder");
>> EAttribute shipTo = ecoreFactory.createEAttribute();
>> shipTo.setName("shipTo");
>> shipTo.setEType(EcorePackage.Literals.ESTRING);
>> purchaseOrderClass.getEStructuralFeatures().add(shipTo);
>>
>> EPackage poPackage = ecoreFactory.createEPackage();
>> poPackage.setName("po");
>> poPackage.setNsPrefix("po");
>> poPackage.setNsURI("http://www.example.com/SimplePO");
>> poPackage.getEClassifiers().add(purchaseOrderClass);
>>
>> resource.getContents().add(poPackage);
>>
>> // Save the contents of the resource to the file system.
>> try
>> {
>> resource.save(Collections.EMPTY_MAP);
>> }
>> catch (IOException e) {}
>> }
>
> Resulted XMI-file content is:
>
>> <?xml version="1.0" encoding="ASCII"?>
>> <ecore:EPackage xmi:version="1.2"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/1.2"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="po"
>> nsURI="http://www.example.com/SimplePO" nsPrefix="po">
>> <eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="shipTo">
>> <eType xsi:type="ecore:EDataType"
>> href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>> </eStructuralFeatures>
>> </eClassifiers>
>> </ecore:EPackage>
>
> Trying to import that XMI-file in other UML-tools, such as ArgoUML or
> Umbrello fails, exceptions are different during parsing, i'll post
> them, but think something is absolutely wrong with my XMI, can anybody
> explain what i'm doing wrong?
>
>
> Best regards,
> Emil
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: EMF and ArgoUML [message #714502 is a reply to message #714390] |
Wed, 10 August 2011 16:48 |
Eclipse User |
|
|
|
Originally posted by: Emil Huseynli
What's the purpose of the possibility to save/load of ECore instances to
XMI-file? What's the benefit of such serialization? where it can be used?
On 10.08.2011 15:08, Ed Merks wrote:
> Emil,
>
> I'm not sure why you'd expect a UML tool to import Ecore instances. If
> you want something UML tools can interchange, you need to be looking at
> the UML2 project; it provides an API for creating UML2 instances.
>
>
> On 09/08/2011 11:22 PM, Emil Huseynli wrote:
>> Hello,
>>
>> I'm generating XMI-file by following code:
>>
>>> private void testEMF(MModel model) {
>>> // Create a resource set.
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>
>>> // Register the default resource factory -- only needed for stand-alone!
>>> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
>>> Resource.Factory.Registry.DEFAULT_EXTENSION, new
>>> CustomXMIResourceFactoryImpl());
>>>
>>> // Get the URI of the model file.
>>> URI fileURI = URI.createFileURI(new
>>> File("mylibrary.xmi").getAbsolutePath());
>>>
>>> // Create a resource for this file.
>>> Resource resource = resourceSet.createResource(fileURI);
>>>
>>> EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
>>> EClass purchaseOrderClass = ecoreFactory.createEClass();
>>> purchaseOrderClass.setName("PurchaseOrder");
>>> EAttribute shipTo = ecoreFactory.createEAttribute();
>>> shipTo.setName("shipTo");
>>> shipTo.setEType(EcorePackage.Literals.ESTRING);
>>> purchaseOrderClass.getEStructuralFeatures().add(shipTo);
>>>
>>> EPackage poPackage = ecoreFactory.createEPackage();
>>> poPackage.setName("po");
>>> poPackage.setNsPrefix("po");
>>> poPackage.setNsURI("http://www.example.com/SimplePO");
>>> poPackage.getEClassifiers().add(purchaseOrderClass);
>>>
>>> resource.getContents().add(poPackage);
>>>
>>> // Save the contents of the resource to the file system.
>>> try
>>> {
>>> resource.save(Collections.EMPTY_MAP);
>>> }
>>> catch (IOException e) {}
>>> }
>>
>> Resulted XMI-file content is:
>>
>>> <?xml version="1.0" encoding="ASCII"?>
>>> <ecore:EPackage xmi:version="1.2"
>>> xmlns:xmi="http://schema.omg.org/spec/XMI/1.2"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="po"
>>> nsURI="http://www.example.com/SimplePO" nsPrefix="po">
>>> <eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="shipTo">
>>> <eType xsi:type="ecore:EDataType"
>>> href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>> </eStructuralFeatures>
>>> </eClassifiers>
>>> </ecore:EPackage>
>>
>> Trying to import that XMI-file in other UML-tools, such as ArgoUML or
>> Umbrello fails, exceptions are different during parsing, i'll post
>> them, but think something is absolutely wrong with my XMI, can anybody
>> explain what i'm doing wrong?
>>
>>
>> Best regards,
>> Emil
|
|
|
Re: EMF and ArgoUML [message #714512 is a reply to message #714502] |
Wed, 10 August 2011 17:03 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Emil,<br>
<br>
I don't get the sense that you've read the introductory information
that's available. Best you read this:<br>
<blockquote><a
href="http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.emf.doc/references/overview/EMF.html">http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.emf.doc/references/overview/EMF.html</a><br>
</blockquote>
<br>
<br>
On 10/08/2011 9:48 AM, Emil Huseynli wrote:
<blockquote cite="mid:j1uc73$vg7$1@news.eclipse.org" type="cite">What's
the purpose of the possibility to save/load of ECore instances to
XMI-file? What's the benefit of such serialization? where it can
be used?
<br>
<br>
On 10.08.2011 15:08, Ed Merks wrote:
<br>
<blockquote type="cite">Emil,
<br>
<br>
I'm not sure why you'd expect a UML tool to import Ecore
instances. If
<br>
you want something UML tools can interchange, you need to be
looking at
<br>
the UML2 project; it provides an API for creating UML2
instances.
<br>
<br>
<br>
On 09/08/2011 11:22 PM, Emil Huseynli wrote:
<br>
<blockquote type="cite">Hello,
<br>
<br>
I'm generating XMI-file by following code:
<br>
<br>
<blockquote type="cite">private void testEMF(MModel model) {
<br>
// Create a resource set.
<br>
ResourceSet resourceSet = new ResourceSetImpl();
<br>
<br>
// Register the default resource factory -- only needed for
stand-alone!
<br>
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
<br>
Resource.Factory.Registry.DEFAULT_EXTENSION, new
<br>
CustomXMIResourceFactoryImpl());
<br>
<br>
// Get the URI of the model file.
<br>
URI fileURI = URI.createFileURI(new
<br>
File("mylibrary.xmi").getAbsolutePath());
<br>
<br>
// Create a resource for this file.
<br>
Resource resource = resourceSet.createResource(fileURI);
<br>
<br>
EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
<br>
EClass purchaseOrderClass = ecoreFactory.createEClass();
<br>
purchaseOrderClass.setName("PurchaseOrder");
<br>
EAttribute shipTo = ecoreFactory.createEAttribute();
<br>
shipTo.setName("shipTo");
<br>
shipTo.setEType(EcorePackage.Literals.ESTRING);
<br>
purchaseOrderClass.getEStructuralFeatures().add(shipTo);
<br>
<br>
EPackage poPackage = ecoreFactory.createEPackage();
<br>
poPackage.setName("po");
<br>
poPackage.setNsPrefix("po");
<br>
poPackage.setNsURI(<a class="moz-txt-link-rfc2396E" href="http://www.example.com/SimplePO">"http://www.example.com/SimplePO"</a>);
<br>
poPackage.getEClassifiers().add(purchaseOrderClass);
<br>
<br>
resource.getContents().add(poPackage);
<br>
<br>
// Save the contents of the resource to the file system.
<br>
try
<br>
{
<br>
resource.save(Collections.EMPTY_MAP);
<br>
}
<br>
catch (IOException e) {}
<br>
}
<br>
</blockquote>
<br>
Resulted XMI-file content is:
<br>
<br>
<blockquote type="cite"><?xml version="1.0"
encoding="ASCII"?>
<br>
<ecore:EPackage xmi:version="1.2"
<br>
xmlns:xmi=<a class="moz-txt-link-rfc2396E" href="http://schema.omg.org/spec/XMI/1.2">"http://schema.omg.org/spec/XMI/1.2"</a>
<br>
xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
<br>
xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
name="po"
<br>
nsURI=<a class="moz-txt-link-rfc2396E" href="http://www.example.com/SimplePO">"http://www.example.com/SimplePO"</a> nsPrefix="po">
<br>
<eClassifiers xsi:type="ecore:EClass"
name="PurchaseOrder">
<br>
<eStructuralFeatures xsi:type="ecore:EAttribute"
name="shipTo">
<br>
<eType xsi:type="ecore:EDataType"
<br>
href=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore#//EString">"http://www.eclipse.org/emf/2002/Ecore#//EString"</a>/>
<br>
</eStructuralFeatures>
<br>
</eClassifiers>
<br>
</ecore:EPackage>
<br>
</blockquote>
<br>
Trying to import that XMI-file in other UML-tools, such as
ArgoUML or
<br>
Umbrello fails, exceptions are different during parsing, i'll
post
<br>
them, but think something is absolutely wrong with my XMI, can
anybody
<br>
explain what i'm doing wrong?
<br>
<br>
<br>
Best regards,
<br>
Emil
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
</body>
</html>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: EMF and ArgoUML [message #714513 is a reply to message #714512] |
Wed, 10 August 2011 17:05 |
Eclipse User |
|
|
|
Originally posted by: Emil Huseynli
ok :) thanks!
On 10.08.2011 19:03, Ed Merks wrote:
> Emil,
>
> I don't get the sense that you've read the introductory information
> that's available. Best you read this:
>
> http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.emf.doc/references/overview/EMF.html
>
>
>
> On 10/08/2011 9:48 AM, Emil Huseynli wrote:
>> What's the purpose of the possibility to save/load of ECore instances
>> to XMI-file? What's the benefit of such serialization? where it can be
>> used?
>>
>> On 10.08.2011 15:08, Ed Merks wrote:
>>> Emil,
>>>
>>> I'm not sure why you'd expect a UML tool to import Ecore instances. If
>>> you want something UML tools can interchange, you need to be looking at
>>> the UML2 project; it provides an API for creating UML2 instances.
>>>
>>>
>>> On 09/08/2011 11:22 PM, Emil Huseynli wrote:
>>>> Hello,
>>>>
>>>> I'm generating XMI-file by following code:
>>>>
>>>>> private void testEMF(MModel model) {
>>>>> // Create a resource set.
>>>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>>>
>>>>> // Register the default resource factory -- only needed for
>>>>> stand-alone!
>>>>> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
>>>>>
>>>>> Resource.Factory.Registry.DEFAULT_EXTENSION, new
>>>>> CustomXMIResourceFactoryImpl());
>>>>>
>>>>> // Get the URI of the model file.
>>>>> URI fileURI = URI.createFileURI(new
>>>>> File("mylibrary.xmi").getAbsolutePath());
>>>>>
>>>>> // Create a resource for this file.
>>>>> Resource resource = resourceSet.createResource(fileURI);
>>>>>
>>>>> EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
>>>>> EClass purchaseOrderClass = ecoreFactory.createEClass();
>>>>> purchaseOrderClass.setName("PurchaseOrder");
>>>>> EAttribute shipTo = ecoreFactory.createEAttribute();
>>>>> shipTo.setName("shipTo");
>>>>> shipTo.setEType(EcorePackage.Literals.ESTRING);
>>>>> purchaseOrderClass.getEStructuralFeatures().add(shipTo);
>>>>>
>>>>> EPackage poPackage = ecoreFactory.createEPackage();
>>>>> poPackage.setName("po");
>>>>> poPackage.setNsPrefix("po");
>>>>> poPackage.setNsURI("http://www.example.com/SimplePO");
>>>>> poPackage.getEClassifiers().add(purchaseOrderClass);
>>>>>
>>>>> resource.getContents().add(poPackage);
>>>>>
>>>>> // Save the contents of the resource to the file system.
>>>>> try
>>>>> {
>>>>> resource.save(Collections.EMPTY_MAP);
>>>>> }
>>>>> catch (IOException e) {}
>>>>> }
>>>>
>>>> Resulted XMI-file content is:
>>>>
>>>>> <?xml version="1.0" encoding="ASCII"?>
>>>>> <ecore:EPackage xmi:version="1.2"
>>>>> xmlns:xmi="http://schema.omg.org/spec/XMI/1.2"
>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="po"
>>>>> nsURI="http://www.example.com/SimplePO" nsPrefix="po">
>>>>> <eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder">
>>>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="shipTo">
>>>>> <eType xsi:type="ecore:EDataType"
>>>>> href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>>>>> </eStructuralFeatures>
>>>>> </eClassifiers>
>>>>> </ecore:EPackage>
>>>>
>>>> Trying to import that XMI-file in other UML-tools, such as ArgoUML or
>>>> Umbrello fails, exceptions are different during parsing, i'll post
>>>> them, but think something is absolutely wrong with my XMI, can anybody
>>>> explain what i'm doing wrong?
>>>>
>>>>
>>>> Best regards,
>>>> Emil
>>
|
|
|
Goto Forum:
Current Time: Fri Apr 26 14:19:43 GMT 2024
Powered by FUDForum. Page generated in 0.03645 seconds
|