Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XMI parsing - creating a navigable model
XMI parsing - creating a navigable model [message #426413] Mon, 05 January 2009 00:01 Go to next message
Eclipse UserFriend
Originally posted by: mchmiel21.tlen.pl

I am looking throug the Internet resources and I am trying to find any
working XMI parser. Without any success...
Netbeans has it, EMF has it... only I cannnot find any code snippets trying
to load and demonstrating the navigation on such model. Can anone please
provide a code snillet loading in my simple app a XMI 1.0 or 1.1. I am
confused Netbeans consortum degraded the code in Netbeans 5.0 and XMI is not
supported in 6.0 - 6.5.


P.S. EMF is complicated I cannot even create a simple model (create model
and draw some UML diagrams) . Why it cannot be done exacly like in Rational
Software Architect? Simple and it works.

Mariusz
Re: XMI parsing - creating a navigable model [message #426414 is a reply to message #426413] Mon, 05 January 2009 01:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090108010904050108050700
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit

Mariusz,

Comments below.

Mariusz Chmielewski wrote:
> I am looking throug the Internet resources and I am trying to find any
> working XMI parser. Without any success...
> Netbeans has it, EMF has it... only I cannnot find any code snippets
> trying to load and demonstrating the navigation on such model.
The very first overview document on the documentation page has snippets:

http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.html

> Can anone please provide a code snillet loading in my simple app a XMI
> 1.0 or 1.1.
EMF supports XMI 2.x.
> I am confused Netbeans consortum degraded the code in Netbeans 5.0 and
> XMI is not supported in 6.0 - 6.5.
Go figure.
>
>
> P.S. EMF is complicated I cannot even create a simple model (create
> model and draw some UML diagrams) .
Flattery will get you everywhere. :-P If you want model diagrams,
you'll need to install Ecore Tools
<http://www.eclipse.org/modeling/emft/?project=ecoretools>

http://www.eclipse.org/modeling/emft/?project=ecoretools

Try the modeling package, if you want all the components already
available rather than having to install them from the update site:
<http://www.eclipse.org/downloads/>

http://www.eclipse.org/downloads/
http://www.eclipse.org/downloads/download.php?file=/technolo gy/epp/downloads/release/ganymede/SR1/eclipse-modeling-ganym ede-SR1-incubation-win32.zip

> Why it cannot be done exacly like in Rational Software Architect?
How much did you pay for RSA? How much did you pay for Eclipse? How
big is the difference?
> Simple and it works.
Try one of the simple tutorials?

Tutorial: Generating an EMF Model
< http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/clibmod/clibmod.html>
Tutorial: Generating an EMF Model using XML Schema
< http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html>

Ask yourself. Does RSA generate a fully functional integrated editor
for my model?

Be sure to invoke "Generate Test Code" and look at the generated
XyzExample.java in the resulting *.tests project. Those are good
snippets for stand alone parsing...
>
> Mariusz
>
>
>

--------------090108010904050108050700
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-2" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Mariusz,<br>
<br>
Comments below.<br>
<br>
Mariusz Chmielewski wrote:
<blockquote cite="mid:gjrikl$dvo$1@build.eclipse.org" type="cite">I am
looking throug the Internet resources and I am trying to find any
working XMI parser. Without any success...
<br>
Netbeans has it, EMF has it... only I cannnot find any code snippets
trying to load and demonstrating the navigation on such model. </blockquote>
The very first overview document on the documentation page has snippets:<br>
<br>
<a
href=" http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.html"> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.html</a><br>
<br>
<blockquote cite="mid:gjrikl$dvo$1@build.eclipse.org" type="cite">Can
anone please provide a code snillet loading in my simple app a XMI 1.0
or 1.1.</blockquote>
EMF supports XMI 2.x.<br>
<blockquote cite="mid:gjrikl$dvo$1@build.eclipse.org" type="cite"> I am
confused Netbeans consortum degraded the code in Netbeans 5.0 and XMI
is not supported in 6.0 - 6.5.
<br>
</blockquote>
Go figure.<br>
<blockquote cite="mid:gjrikl$dvo$1@build.eclipse.org" type="cite"><br>
<br>
P.S. EMF is


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI parsing - creating a navigable model [message #426683 is a reply to message #426414] Sun, 18 January 2009 01:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mchmiel21.tlen.pl

This is a multi-part message in MIME format.

------=_NextPart_000_0025_01C97910.C119C920
Content-Type: text/plain;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

As You wrote before I managed to create the whole presented in tutorial =
model. I serialized it to XMI:
looks like this:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<org.eclipse.example.library:Library xmi:version=3D"2.0" =
xmlns:xmi=3D"http://www.omg.org/XMI" =
xmlns:org.eclipse.example.library=3D"http:///org/eclipse/example/library.=
ecore" name=3D"Skills Center">
<writers name=3D"JRR Tokien" books=3D"//@books.0"/>
<books title=3D"Fellowship of the Ring" pages=3D"324" =
category=3D"ScienceFiction" author=3D"//@writers.0"/>
</org.eclipse.example.library:Library>

the problem is that I want to achieve something compleatly different =
with EMF.=20
First of all I tried to look directly for IBM's XMI toolkit =
http://www.alphaworks.ibm.com/tech/xmitoolkit
with no luck...

I found a code snippet for EMF for loading XMI:

public static void main(String[] args) {
// Create a resource set.
ResourceSet resourceSet =3D new ResourceSetImpl();
// Register the default resource factory -- only needed for =
stand-alone!
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
.put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
// Get the URI of the model file.
URI fileURI =3D URI.createFileURI(new File("model.xmi")
.getAbsolutePath());
// Demand load the resource for this file.
Resource resource =3D resourceSet.getResource(fileURI, true);
// Print the contents of the resource to System.out.
try {
resource.save(System.out, Collections.EMPTY_MAP);
} catch (IOException e) {
}
}


but i get only exceptions concerning=20

Exception in thread "main" =
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedExc=
eption: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with =
uri 'null' not found. =
(file:/C:/Projekty/workspace_guru/OntologyProcessor/sourceMo dels/jc3-iedm=
-oom-xmi-1_0.xmi, 3, 21)
at =
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadExcep=
tion(ResourceSetImpl.java:315)
at =
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(Reso=
urceSetImpl.java:274)
at =
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceS=
etImpl.java:397)
at emf.EMFXMITest.main(EMFXMITest.java:39)

I managed to find that this execption is connected to problem in =
namespace definition... the problem is taht the XMI file i want to load=20
sorry parse with EMF is compleatly creatated outside Eclipse and has =
nothing in common with EMF.=20

Is there a chance to just load XMI, and have a way to process the XMI =
tree? such simple request :-)

Regards




----- Original Message -----=20
From: Ed Merks=20
Newsgroups: eclipse.tools.emf
Sent: Monday, January 05, 2009 2:58 AM
Subject: Re: XMI parsing - creating a navigable model


Mariusz,

Comments below.

Mariusz Chmielewski wrote:=20
I am looking throug the Internet resources and I am trying to find =
any working XMI parser. Without any success...=20
Netbeans has it, EMF has it... only I cannnot find any code snippets =
trying to load and demonstrating the navigation on such model.=20
The very first overview document on the documentation page has =
snippets:

=
http://help.eclipse.org/ganymede/index.jsp?topic=3D/org.ecli pse.emf.doc/r=
eferences/overview/EMF.html


Can anone please provide a code snillet loading in my simple app a =
XMI 1.0 or 1.1.
EMF supports XMI 2.x.

I am confused Netbeans consortum degraded the code in Netbeans 5.0 =
and XMI is not supported in 6.0 - 6.5.=20

Go figure.



P.S. EMF is complicated I cannot even create a simple model (create =
model and draw some UML diagrams) .
Flattery will get you everywhere. :-P If you want model diagrams, =
you'll need to install Ecore Tools

http://www.eclipse.org/modeling/emft/?project=3Decoretools

Try the modeling package, if you want all the components already =
available rather than having to install them from the update site:

http://www.eclipse.org/downloads/
=
http://www.eclipse.org/downloads/download.php?file=3D/techno logy/epp/down=
loads/release/ganymede/SR1/eclipse-modeling-ganymede-SR1-inc ubation-win32=
..zip

Why it cannot be done exacly like in Rational Software Architect?
How much did you pay for RSA? How much did you pay for Eclipse? How =
big is the difference?

Simple and it works.=20

Try one of the simple tutorials?

Tutorial: Generating an EMF Model
Tutorial: Generating an EMF Model using XML Schema

Ask yourself. Does RSA generate a fully functional integrated editor =
for my model?

Be sure to invoke "Generate Test Code" and look at the generated =
XyzExample.java in the resulting *.tests project. Those are good =
snippets for stand alone parsing...


Mariusz=20




------=_NextPart_000_0025_01C97910.C119C920
Content-Type: text/html;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-2>
<META content=3D"MSHTML 6.00.6001.18183" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>As You wrote before I managed to create =
the whole=20
presented in tutorial model. I serialized it to XMI:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>looks like this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;?xml version=3D"1.0"=20
encoding=3D"UTF-8"?&gt;<BR>&lt;org.eclipse.example.library:Library=20
xmi:version=3D"2.0" xmlns:xmi=3D"<A =
href=3D"">http://www.omg.org/XMI</A>"=20
xmlns:org.eclipse.example.library=3D"<A=20
href=3D"">http:///org/eclipse/example/library.ecore</A>" name=3D"Skills=20
Center"&gt;<BR>&nbsp; &lt;writers name=3D"JRR Tokien"=20
books=3D"<A>//@books.0"/</A>&gt;<BR>&nbsp; &lt;books title=3D"Fellowship =
of the=20
Ring" pages=3D"324" category=3D"ScienceFiction"=20
author=3D"<A>//@writers.0"/</A>&gt;<BR>&lt;/org.eclipse.example.library:L=
ibrary&gt;<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the problem is that&nbsp;I want to =
achieve=20
something compleatly different with EMF. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>First of all I tried to look directly =
for IBM's XMI=20
toolkit <A=20
href=3D"">http://www.alphaworks.ibm.com/tech/xmitoolkit</A></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>with no luck...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I found a code snippet for EMF for =
loading=20
XMI:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>public static void main(String[] args)=20
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;// Create a resource=20
set.<BR>&nbsp;&nbsp;ResourceSet resourceSet =3D new =
ResourceSetImpl();<BR>&nbsp;//=20
Register the default resource factory -- only needed for=20
stand-alone!<BR> &nbsp;&nbsp;resourceSet.getResourceFactoryRegistry() .getE=
xtensionToFactoryMap()<BR> &nbsp;&nbsp;&nbsp;&nbsp;.put(Resource.Factor y.R=
egistry.DEFAULT_EXTENSION,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new=20
XMIResourceFactoryImpl());</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;// Get the URI of the model =

file.<BR>&nbsp;&nbsp;URI fileURI =3D URI.createFileURI(new=20
File("model.xmi")<BR> &nbsp;&nbsp;&nbsp;&nbsp;.getAbsolutePath()); </FONT><=
/DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;// Demand load the resource =
for this=20
file.<BR>&nbsp;&nbsp;Resource resource =3D =
resourceSet.getResource(fileURI,=20
true);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;// Print the contents of =
the resource=20
to System.out.<BR>&nbsp;&nbsp;try=20
{<BR>&nbsp;&nbsp;&nbsp;resource.save(System.out,=20
Collections.EMPTY_MAP);<BR>&nbsp;&nbsp;} catch (IOException e)=20
{<BR>&nbsp;&nbsp;}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>but i get only exceptions concerning =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Exception in thread "main"=20
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedExc=
eption:=20
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri =
'null' not=20
found.=20
(file:/C:/Projekty/workspace_guru/OntologyProcessor/sourceMo dels/jc3-iedm=
-oom-xmi-1_0.xmi,=20
3, 21)<BR>&nbsp;at=20
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadExcep=
tion(ResourceSetImpl.java:315)<BR>&nbsp;at=20
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(Reso=
urceSetImpl.java:274)<BR>&nbsp;at=20
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceS=
etImpl.java:397)<BR>&nbsp;at=20
emf.EMFXMITest.main(EMFXMITest.java:39)<BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>I managed to find that this execption =
is connected=20
to problem in namespace definition... the problem is taht the XMI file i =
want to=20
load </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>sorry parse with EMF is compleatly =
creatated=20
outside Eclipse and has nothing in common with EMF. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Is there a chance to just load XMI, and =
have a way=20
to process the XMI tree? such simple request :-)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</DIV></FONT>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A title=3DEd.Merks@gmail.com href=3D"">Ed Merks</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Newsgroups:</B> =
eclipse.tools.emf</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Monday, January 05, 2009 =
2:58=20
AM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: XMI parsing - =
creating a=20
navigable model</DIV>
<DIV><BR></DIV>Mariusz,<BR><BR>Comments below.<BR><BR>Mariusz =
Chmielewski=20
wrote:=20
<BLOCKQUOTE cite=3Dmid:gjrikl$dvo$1@build.eclipse.org type=3D"cite">I =
am looking=20
throug the Internet resources and I am trying to find any working =
XMI=20
parser. Without any success... <BR>Netbeans has it, EMF has it... =
only I=20
cannnot find any code snippets trying to load and demonstrating the=20
navigation on such model. </BLOCKQUOTE>The very first overview =
document on the=20
documentation page has snippets:<BR><BR><A=20
=
href=3D""> http://help.eclipse.org/ganymede/index.jsp?topic=3D/org.ecli pse=
..emf.doc/references/overview/EMF.html</A><BR><BR>
<BLOCKQUOTE cite=3Dmid:gjrikl$dvo$1@build.eclipse.org =
type=3D"cite">Can anone=20
please provide a code snillet loading in my simple app a XMI 1.0 or=20
1.1.</BLOCKQUOTE>EMF supports XMI 2.x.<BR>
<BLOCKQUOTE cite=3Dmid:gjrikl$dvo$1@build.eclipse.org type=3D"cite">I =
am=20
confused Netbeans consortum degraded the code in Netbeans 5.0 and =
XMI is not=20
supported in 6.0 - 6.5. <BR></BLOCKQUOTE>Go figure.<BR>
<BLOCKQUOTE cite=3Dmid:gjrikl$dvo$1@build.eclipse.org =
type=3D"cite"><BR><BR>P.S.=20
EMF is&nbsp; complicated I cannot even create a simple model (create =
model=20
and draw some UML diagrams) .</BLOCKQUOTE>Flattery will get you =
everywhere.=20
:-P &nbsp; If you want model diagrams, you'll need to install Ecore =
Tools<A=20
href=3D""><BR></A>
<BLOCKQUOTE><A=20
=
href=3D"">http://www.eclipse.org/modeling/emft/?project=3Decoretools</A><=
BR></BLOCKQUOTE>Try=20
the modeling package, if you want all the components already available =
rather=20
than having to install them from the update site:<A href=3D""><BR></A>
<BLOCKQUOTE><A href=3D"">http://www.eclipse.org/downloads/</A><BR><A=20
=
href=3D""> http://www.eclipse.org/downloads/download.php?file=3D/techno log=
y/epp/downloads/release/ganymede/SR1/eclipse-modeling-ganyme de-SR1-incuba=
tion-win32.zip</A><BR></BLOCKQUOTE>
<BLOCKQUOTE cite=3Dmid:gjrikl$dvo$1@build.eclipse.org =
type=3D"cite">Why it=20
cannot be done exacly like in Rational Software =
Architect?</BLOCKQUOTE>How=20
much did you pay for RSA?&nbsp; How much did you pay for =
Eclipse?&nbsp; How=20
big is the difference?<BR>
<BLOCKQUOTE cite=3Dmid:gjrikl$dvo$1@build.eclipse.org =
type=3D"cite">Simple and=20
it works. <BR></BLOCKQUOTE>Try one of the simple tutorials?<BR>
<BLOCKQUOTE><A href=3D"">Tutorial: Generating an EMF Model</A><BR><A=20
href=3D"">Tutorial: Generating an EMF Model using XML=20
Schema</A><BR></BLOCKQUOTE>Ask yourself.&nbsp; Does RSA generate a =
fully=20
functional integrated editor for my model?<BR><BR>Be sure to invoke =
"Generate=20
Test Code" and look at the generated XyzExample.java in the resulting =
*.tests=20
project.&nbsp; Those are good snippets for stand alone parsing...<BR>
<BLOCKQUOTE cite=3Dmid:gjrikl$dvo$1@build.eclipse.org =
type=3D"cite"><BR>Mariusz=20
<BR><BR><BR><BR></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML >

------=_NextPart_000_0025_01C97910.C119C920--
Re: XMI parsing - creating a navigable model [message #427005 is a reply to message #426413] Tue, 27 January 2009 23:06 Go to previous message
Tom Morris is currently offline Tom MorrisFriend
Messages: 89
Registered: July 2009
Member
Mariusz Chmielewski wrote:

> I am confused Netbeans consortum degraded the code in Netbeans 5.0 and
> XMI is not supported in 6.0 - 6.5.

Although the Model Data Repository (MDR) is no longer used by NetBeans,
the code is still available from http://mdr.netbeans.org/ and is used
successfully by a number of products to parse XMI 1.x.

Tom
Previous Topic:Reflective set of single valued references
Next Topic:Create genmodel from ecore programmatically
Goto Forum:
  


Current Time: Thu Apr 25 22:52:27 GMT 2024

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

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

Back to the top