[Newbie] Help with ReadingModelSample.java NSUML1_4

[email protected] Wed, 12 Mar 2003 10:09:32 -0700
Newsgroups gmane.comp.java.netbeans.modules.mdr.devel
Message-ID <[email protected]>
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.");
  }
}