Re: [Newbie] Help with ReadingModelSample.java NSUML1_4

Martin Matula <[email protected]> Wed, 12 Mar 2003 21:17:48 +0100
Newsgroups gmane.comp.java.netbeans.modules.mdr.devel
Message-ID <[email protected]>
Yes, unless the file is empty, there should be at least one root object 
- typically an instance of MofPackage.
Martin

[email protected] wrote:
> Martin, Sorry for the confusion, I haven't really had a chance to look at the architecture of MDR and made some wrong assumption about how this sample works.  I guess the model would be expressed in novosoft mdf objects (not familiar with this framework yet) not MDR objects.  Bottom line, I was hoping to use the sample code as a means to read in an XMI file and examine the resulting model through the instanciated model class objects (be them MDF, MDR, or JMI, etc. objects).  I would have expected there to be >0 root objects when reading in the example XMI file supplied with the sample program.  Thanks, Doug.
> 
> -----Original Message-----
> From: Martin Matula [mailto:[email protected]]
> Sent: Wednesday, March 12, 2003 11:04 AM
> To: [email protected]
> Subject: Re: [mdr-dev] [Newbie] Help with ReadingModelSample.java
> NSUML1_4
> 
> 
> Hi,
> I am not sure what you are asking for. Are you looking for a code that 
> does the same thing on top of MDR?
> Martin
> 
> [email protected] wrote:
> 
>>Downloaded and built nsuml1_4 code and samples.  I'm interested in scoping what is requires to read in a  MOF 1.3 compient XMI 1.x file into MDR objects using the framework.  The ReadingModelSample.java example looks like a great place to start, but it doesn't generate the results I would expect.  Shouldn't there be a number of root objects?
>>
>>Here is the output generated by running the sample:
>>--------------------------------------------------------------------------
>>
>>
>>>0
>>>All is O.K. 
>>
>>
>>
>>Here is the source for the sample:
>>--------------------------------------------------------------------------
>>package samples;
>>import java.io.*;
>>import java.util.*;
>>import javax.jmi.model.*;
>>import javax.jmi.reflect.*;
>>import ru.novosoft.uml.*;
>>import ru.novosoft.uml.impl.*;
>>import ru.novosoft.uml.foundation.core.*;
>>import ru.novosoft.uml.impl.foundation.core.*;
>>import ru.novosoft.mdf.ext.*;
>>import ru.novosoft.mdf.impl.*;
>>import ru.novosoft.mdf.ext.xmi.*;
>>
>>/**
>> * Demonstrate a model (metamodel) reading into given extent.
>> */
>>public class ReadingModelSample
>>{
>>  public static final String extPkg = "ru.novosoft.mdf.mof.impl.model.MOFModelPackageImpl";
>>
>>  public static void main(String[] args) {
>>    try {
>>      MDFOutermostPackage extent = (MDFOutermostPackage)Class.forName(extPkg).newInstance();
>>      String version = "1.1";   // XMI version.
>>
>>      // getting reader object with specified XMI version from outermost extent
>>      XMIReader xmiReader = (XMIReader)extent.getXMIReader(version);  
>>      xmiReader.read(extent, "./model/test.xml");     // reading metamodel from file
>>
>>      // here MOF outermost package will contain read metamodel
>>      System.out.println("" + extent.getRoots().size());
>>    } 
>>    catch (Exception ex) {
>>      ex.printStackTrace();
>>      System.exit(1);
>>    } 
>>   
>>    System.out.println("All is O.K.");
>>  }
>>}
>>
> 
>