XMI Parser [message #418901] |
Thu, 01 May 2008 11:42 |
Eclipse User |
|
|
|
Originally posted by: naeemkhans79.hotmail.com
hallo every one,
I am intermediate level Java programmer. I have to parse the XMI 2.0 to
check the classes, its attributes, data types and relations among classes
(Class diagram converted from UML2 into XMI). I am trying since 2 months.
First I followed a book called Mastering XMI with Netbeans. It was not
good enough. Then I came to EMF and Ecore. I like to have clear example
where I can access my XMI and grab every object in it. Could any one help
me out to make my concept clear with some examples.
I am also trying to get any tutorial about this. But didnt find any.
Your help definitely will bring me out from this problem.
Best Regards,
Naeem Khan
|
|
|
Re: XMI Parser [message #418904 is a reply to message #418901] |
Thu, 01 May 2008 11:58 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------030100080004050309000608
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Naeem,
Comments below.
Khan wrote:
> hallo every one,
>
> I am intermediate level Java programmer. I have to parse the XMI 2.0
> to check the classes, its attributes, data types and relations among
> classes (Class diagram converted from UML2 into XMI). I am trying
> since 2 months. First I followed a book called Mastering XMI with
> Netbeans. It was not good enough. Then I came to EMF and Ecore. I like
> to have clear example where I can access my XMI and grab every object
> in it. Could any one help me out to make my concept clear with some
> examples.
> I am also trying to get any tutorial about this. But didnt find any.
There is a common misconception that you can just throw an XMI
serialization at a system and out will pop well formed model. Of course
this misconception is aided by the fact that this is generally how it's
supposed to work. The misconception part is that you can throw any old
XMI serialized instance at the system with the expectation that nice a
model will pop out. In reality the system must effectively know the
model that corresponds to each namespace mentioned in the XMI
serialization and if it doesn't know that model in intimate detail, the
XMI is just so much meaningless syntax.
Given you have a UML2 serialization, it's best to ask on the UML2
newsgroup how to read it; I've added that group to the "to" list of the
reply. Of course starting with the documentation at their website would
be best:
<http://www.eclipse.org/modeling/mdt/?project=uml2>
http://www.eclipse.org/modeling/mdt/?project=uml2
http://wiki.eclipse.org/index.php/MDT-UML2
>
> Your help definitely will bring me out from this problem.
>
> Best Regards,
> Naeem Khan
>
>
--------------030100080004050309000608
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Naeem,<br>
<br>
Comments below.<br>
<br>
<br>
Khan wrote:
<blockquote
cite="mid:06d44eb0c2099cb2bffcd74b6636103f$1@www.eclipse.org"
type="cite">hallo every one,
<br>
<br>
I am intermediate level Java programmer. I have to parse the XMI 2.0 to
check the classes, its attributes, data types and relations among
classes (Class diagram converted from UML2 into XMI). I am trying since
2 months. First I followed a book called Mastering XMI with Netbeans.
It was not good enough. Then I came to EMF and Ecore. I like to have
clear example where I can access my XMI and grab every object in it.
Could any one help me out to make my concept clear with some examples. <br>
I am also trying to get any tutorial about this. But didnt find any.
<br>
</blockquote>
There is a common misconception that you can just throw an XMI
serialization at a system and out will pop well formed model.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: XMI Parser [message #418909 is a reply to message #418904] |
Thu, 01 May 2008 14:21 |
Eclipse User |
|
|
|
Originally posted by: naeemkhans79.hotmail.com
Thank you for your answer. But I might have wrong conception about reading
XMI files. I have already asked help in UML2 Newsgroup, as you recommend
me. Could you please give me any idea how would you do this task.
Further more, I dont have to generate any UML model. I have already
exported XMI file which I have to parse. How can I do this??
regards,
Khan
|
|
|
|
Re: XMI Parser [message #418916 is a reply to message #418910] |
Thu, 01 May 2008 20:45 |
Eclipse User |
|
|
|
Originally posted by: naeemkhans79.hotmail.com
thanks for giving time. Basically, I am Using EclipseUML 3.3.2 and it is
based on UML 2.0 which is completable with XMI 2.0. If you have any Idea
what should better to use then please let me know. What I did is, I just
made Ecore Model and then opened it with Text Editor, copy the XMI Code
and saved with notepad with XMI Extension. I guess It is damn what I
did??? :-) But your recommendation are really welcome.
Regards,
Khan
|
|
|
|
Re: XMI Parser [message #418919 is a reply to message #418917] |
Fri, 02 May 2008 09:28 |
Eclipse User |
|
|
|
Originally posted by: naeemkhans79.hotmail.com
ja sure, below you can see the code of copied file as XMI from Ecore Model.
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="myFactory">
<eClassifiers xsi:type="ecore:EClass" name="Customer">
<eOperations name="getCstID" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EBigInteger"/>
<eOperations name="getCustomerStatus" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="CstID"
eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EBigInteger"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="CustomerStatus"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</eClassifiers>
</ecore:EPackage>
I like to parse this file and grab the object like Class Customer, Its
Properties and data types, and relations. What I have written the code in
java is you see here.
package src;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
public class parser {
public static void main(String[] args){
// create resource set and resource
try{
ResourceSet resourceSet = new ResourceSetImpl();
// Register XML resource factory
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xmi",
new XMIResourceFactoryImpl());
URI uri =
org.eclipse.emf.common.util.URI.createURI("C:/EcoreCustomer.XMI ");
Resource resource = resourceSet.createResource(uri);
TreeIterator ti = resource.getAllContents();
while (ti.hasNext()){
System.out.println(ti.getClass().getSimpleName());
}
}// end of try
catch (NullPointerException e){
e.getStackTrace();
}
}
}
Am I doing in the right thing to grab the XMI file saved on C: drive???
please help me out.
Khan
|
|
|
|
Re: XMI Parser [message #418925 is a reply to message #418921] |
Fri, 02 May 2008 15:17 |
Eclipse User |
|
|
|
Originally posted by: naeemkhans79.hotmail.com
Ed Merks,
If I change the suffix in lower case would it work, will I be able to read
XMI??? As you said, it is totally unrelated for UML instance. Well Merks,
I only have to write a java class where I can read stored Xmi file,
supposedly I have already converted XMI file saved some where on my
computer. In this case, am I going right???
|
|
|
|
Re: XMI Parser [message #418928 is a reply to message #418926] |
Fri, 02 May 2008 16:22 |
Eclipse User |
|
|
|
Originally posted by: naeemkhans79.hotmail.com
where can i find EMF tutorials and how can I generate Test Code?? can you
send me a link of that tutorial???
|
|
|
|
Re: XMI Parser [message #418943 is a reply to message #418929] |
Sun, 04 May 2008 16:38 |
Eclipse User |
|
|
|
Originally posted by: naeemkhans79.hotmail.com
hi Ed Merks,
I am back to you after having detail EMF tutorial and your fantastic
online demostration of EMF round trip. Ecore to Java and back to it.
Well, EMF it very cool thing to facilitate modeling and programing world.
I can now create Ecore model based on any UML class diagram. and then What
I understood is to generate EMF Model which is called *.genmodel to
generate java codes.
I saw in your presentation project architecture which you created as Empty
EMF Project. It provides you Model folder and META-INF folder and other
two things I have seen (Plug-in Dependencies, and JRE System Library) that
I dont get any, when I create any Empty EMF Project.
But code generator I have seen. I will also generate code in my case
depending upon what I have made UML Class diagram. SO far it is fine, and
I uderstood. But later I need to parse the generated classes. Could you
please guide me how can i do this???
Regards,
Khan
|
|
|
|
Re: XMI Parser [message #418945 is a reply to message #418944] |
Sun, 04 May 2008 17:45 |
Eclipse User |
|
|
|
Originally posted by: naeemkhans79.hotmail.com
of course, that was not in tutorial but I have seen similar example in
your live demonstration (uploaded at eclipse.org) that generates *.tests
folders. But please recommend me how can I parse UML model which is
generated as classes by *.genmodel (generate options).
|
|
|
Re: XMI Parser [message #418946 is a reply to message #418945] |
Sun, 04 May 2008 20:45 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Khan,
I'm not sure if you mean instances of UML itself or just a model for
which you happened to use UML as the way to define it. If the former,
the using the generated example is good, if the latter, then using the
documentation from the UML website is good.
Khan wrote:
> of course, that was not in tutorial but I have seen similar example in
> your live demonstration (uploaded at eclipse.org) that generates
> *.tests folders. But please recommend me how can I parse UML model
> which is generated as classes by *.genmodel (generate options).
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02100 seconds