Menu

xmi:href problem

Help
Pashec
2009-01-09
2013-04-29
  • Pashec

    Pashec - 2009-01-09

    Hi

    I tried to do generalization but I got such problem. Here is my code

    -------------------------------------------------------------------------------------------------
    NUml.Uml2.Model model = Create.Model();
    model.Name = "ModelName";

    // create a new Class element
    NUml.Uml2.Class baseClass = NUml.Uml2.Create.Class();
    baseClass.Name = "BaseClass";

    NUml.Uml2.Class nestedClass = NUml.Uml2.Create.Class();
    nestedClass.Name = "Class1";
    nestedClass.SuperClass.Add(baseClass);

    // add it to the package
    model.OwnedType.Add(nestedClass);
    model.OwnedType.Add(baseClass);
    -------------------------------------------------------------------------------------------------

    Note I add nestedClass first and then baseClass.
    I get this xmi:

    -------------------------------------------------------------------------------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <xmi:XMI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:version="2.1" xmlns:uml="http://schema.omg.org/spec/uml/2.0" xmlns:xmi="http://schema.omg.org/spec/xmi/2.1">
      <xmi:Extension extender="numl" extenderID="domainInfo" modelDomainUri="http://just_a_sample/" />
      <uml:Model xmi:id="03c1dd17-a997-4374-8fac-000bbbdbf6ae" name="ModelName">
        <ownedMember xmi:type="uml:Class" xmi:id="9318c613-a1af-4428-9f09-30092fdaf5bf" name="Class1">
          <generalization xmi:id="9438013e-10fd-4675-b466-e2bc76a6f644" isSubstitutable="false">
            <general xmi:idref="038b7535-273e-41a8-9f0c-01a1e5e7542a" />
          </generalization>
        </ownedMember>
        <ownedMember xmi:type="uml:Class" xmi:id="bdfc0bed-4cea-464d-a10b-009f0a1e334d" name="BaseClass" />
      </uml:Model>
      <uml:Class xmi:id="038b7535-273e-41a8-9f0c-01a1e5e7542a" xmi:href="#bdfc0bed-4cea-464d-a10b-009f0a1e334d" />
    </xmi:XMI>
    -------------------------------------------------------------------------------------------------

    Note that BaseClass has link xmi:href="#bdfc0bed-4cea-464d-a10b-009f0a1e334d".
    But this link isn't resolved by Enterprise Architect with message in log "Error: Unknown Generalization Source or Target". But when I manually change general xmi:idref to the real BaseClass xmi:id it works fine.

    So could I adjust serialization process to make xmi with real xmi:id without xmi:href?

    P.S. Sorry for large post :).

     
    • Rodolfo Campero

      Rodolfo Campero - 2009-01-09

      Try calling Serialize twice in your code - this is a known issue, but since this kind of indirect referencing is allowed and specified in the XMI standard, it's not a bug. In fact, with nUML is possible for an object to reference objects from another file using xmi:href.

      I use this:
                  driver.Serialize (model, fileName);
                  //serialized twice in order to avoid spurious proxy elements
                  driver.Serialize (model, fileName);

       
    • Pashec

      Pashec - 2009-01-10

      Hi Rodolfo,

      Thanks. It helps.

       

Log in to post a comment.

MongoDB Logo MongoDB