Author Topic: xmi:id how to?  (Read 15954 times)

ngong

  • EA User
  • **
  • Posts: 269
  • Karma: +1/-2
    • View Profile
xmi:id how to?
« on: November 14, 2016, 06:03:45 am »
I have been successful so far in generating xmi files for to import in an eap file. So far it work by keeping xmi:id just unique, no more rules. However, now I started to produce tags against some profile. When I use an arbitrary - but unique - xmi:id for a tag element, it will not be imported.
What I did was manually enter tags in the eap file and then exporting the package, copying the xmi:id's to my file to get imported. That works.
What I found out so far is, that I shall not change the first 24 characters for the tag's xmi:id. For uniqueness I may change the last 17 characters.

Is there anywhere a rule that I can follow, to successfully produce the first 24 characters of an xmi:id?

Here you can see the xmi file that can be imported successfully. E.g. when I change the beginning of the xmi:id EAID_EC46D93B_5E30_7e5e_0000_000000000001 the tag Bit_No will not be imported.

Code: [Select]
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmlns:uml="http://www.omg.org/spec/UML/20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:SignalProfile="http://www.sparxsystems.com/profiles/SignalProfile/1.0">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model">
<packagedElement xmi:type="uml:Package" xmi:id="RSCID_Signals" name="Signals">
<packagedElement xmi:type="uml:Interface" xmi:id="RSCID_Signal1" name="Signal1" isAbstract="true"/>
<packagedElement xmi:type="uml:Interface" xmi:id="RSCID_Signal2" name="Signal2" isAbstract="true"/>
</packagedElement>
<profileApplication xmi:type="uml:ProfileApplication" xmi:id="profileap_13E3FB92-0">
<appliedProfile xmi:type="uml:Profile" href="http://www.sparxsystems.com/profiles/SignalProfile/1.0#13E3FB92-0"/>
</profileApplication>
</uml:Model>
<xmi:Extension extender="Enterprise Architect" extenderID="6.5">
<elements>
<element xmi:idref="RSCID_Signal1" xmi:type="uml:Interface" name="Signal1" scope="public">
                <properties documentation="comment to Signal Function of Signal1" isSpecification="false" sType="Interface" nType="0" scope="public" stereotype="Signal" isRoot="false" isLeaf="false" isAbstract="true"/>
<tags>
<tag xmi:id="EAID_EC46D93B_5E30_7e5e_0000_000000000001" name="Bit_No" value="3" modelElement="RSCID_Signal1"/>
<tag xmi:id="EAID_9A779570_3D05_a03d_0000_000000000002" name="Byte_No" value="1" modelElement="RSCID_Signal1"/>
<tag xmi:id="EAID_640BFE5F_7DD4_4a7d_0000_000000000003" name="Cycle Time" value="CycleTime_100#NOTES#Values: CycleTime_40,CycleTime_100,CycleTime_1000,CycleTime_10000,NoCycleTime&#xA;" modelElement="RSCID_Signal1"/>
<tag xmi:id="EAID_04C5B725_62DA_ee62_0000_000000000004" name="Default" value="6" modelElement="RSCID_Signal1"/>
<tag xmi:id="EAID_A1E56D61_FA76_75fa_0000_000000000005" name="direction" value="s#NOTES#Values: r,s&#xA;" modelElement="RSCID_Signal1"/>
<tag xmi:id="EAID_7DCA38DC_C011_cdc0_0000_000000000006" name="Launch Parameter" value="LaunchParameter_20#NOTES#Values: LaunchParameter_10,LaunchParameter_20,LaunchParameter_100,LaunchParameter_200,NoLaunchParameter&#xA;" modelElement="RSCID_Signal1"/>
<tag xmi:id="EAID_462950BD_42D2_6942_0000_000000000007" name="Launch Type" value="CyclicAndChange#NOTES#Values: Cyclic,CyclicAndChange,Spontanious,None&#xA;" modelElement="RSCID_Signal1"/>
<tag xmi:id="EAID_034EE602_6F17_866f_0000_000000000008" name="Length" value="3" modelElement="RSCID_Signal1"/>
<tag xmi:id="EAID_736065D1_2526_7c25_0000_000000000009" name="Not_Available" modelElement="RSCID_Signal1"/>
</tags>
                <xrefs value="$XREFPROP=$NAM=Stereotypes$NAM;$TYP=element property$TYP;$VIS=Public$VIS;$PAR=0$PAR;$DES=@STEREO;Name=Signal;FQName=SignalProfile::Signal;@ENDSTEREO;$DES;$SUP=&lt;none&gt;$SUP;$ENDXREF;"/>
</element>
<element xmi:idref="RSCID_Signal2" xmi:type="uml:Interface" name="Signal2" scope="public">
                <properties documentation="comment to Signal Function of Signal2" isSpecification="false" sType="Interface" nType="0" scope="public" stereotype="Signal" isRoot="false" isLeaf="false" isAbstract="true"/>
<tags>
<tag xmi:id="EAID_EC46D93B_5E30_7e5e_0000_000000000010" name="Bit_No" value="0" modelElement="RSCID_Signal2"/>
<tag xmi:id="EAID_9A779570_3D05_a03d_0000_000000000011" name="Byte_No" value="1" modelElement="RSCID_Signal2"/>
<tag xmi:id="EAID_640BFE5F_7DD4_4a7d_0000_000000000012" name="Cycle Time" value="CycleTime_100#NOTES#Values: CycleTime_40,CycleTime_100,CycleTime_1000,CycleTime_10000,NoCycleTime&#xA;" modelElement="RSCID_Signal2"/>
<tag xmi:id="EAID_04C5B725_62DA_ee62_0000_000000000013" name="Default" value="27" modelElement="RSCID_Signal2"/>
<tag xmi:id="EAID_A1E56D61_FA76_75fa_0000_000000000014" name="direction" value="s#NOTES#Values: r,s&#xA;" modelElement="RSCID_Signal2"/>
<tag xmi:id="EAID_7DCA38DC_C011_cdc0_0000_000000000015" name="Launch Parameter" value="LaunchParameter_100#NOTES#Values: LaunchParameter_10,LaunchParameter_20,LaunchParameter_100,LaunchParameter_200,NoLaunchParameter&#xA;" modelElement="RSCID_Signal2"/>
<tag xmi:id="EAID_462950BD_42D2_6942_0000_000000000016" name="Launch Type" value="CyclicAndChange#NOTES#Values: Cyclic,CyclicAndChange,Spontanious,None&#xA;" modelElement="RSCID_Signal2"/>
<tag xmi:id="EAID_034EE602_6F17_866f_0000_000000000017" name="Length" value="5" modelElement="RSCID_Signal2"/>
<tag xmi:id="EAID_736065D1_2526_7c25_0000_000000000018" name="Not_Available" modelElement="RSCID_Signal2"/>
</tags>
<xrefs value="$XREFPROP=$NAM=Stereotypes$NAM;$TYP=element property$TYP;$VIS=Public$VIS;$PAR=0$PAR;$DES=@STEREO;Name=Signal;FQName=SignalProfile::Signal;@ENDSTEREO;$DES;$SUP=&lt;none&gt;$SUP;$ENDXREF;"/>
  </element>
</elements>
</xmi:Extension>
</xmi:XMI>
« Last Edit: November 14, 2016, 06:07:47 am by ngong »
Rolf

qwerty

  • EA Guru
  • *****
  • Posts: 13551
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: xmi:id how to?
« Reply #1 on: November 14, 2016, 08:07:00 am »
I remember that some GUID are not really arbitrary numbers but somehow merged with their related parents. Especially TVs seemed to be candidates for that (also operations, parameters and things like that; also Package/Element share the same GUID). I don't remember any details. But you should make an export of a model an check that whether there are any of those relations.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8030
  • Karma: +118/-20
    • View Profile
Re: xmi:id how to?
« Reply #2 on: November 14, 2016, 09:34:45 am »
You are asking for trouble by generating XMI and claiming it's been generated by Enterprise Architect.

Best case, it works and you will be highly likely to get duplicate guid issues in the future because your guid aren't properly unique. In general I would expect some part of the XMI import process to fail because what you've generated doesn't match what's expected.

However, if your trying to generate tagged value guids for tags coming from a profile, copy the first half from a tag EA created.


ngong

  • EA User
  • **
  • Posts: 269
  • Karma: +1/-2
    • View Profile
Re: xmi:id how to?
« Reply #3 on: November 15, 2016, 08:43:35 pm »
Yes, thank you qwerty and Simon,

seems my knowledge comes close to what is known.

About the idea not using the API but XMI: I have a dream: XMI holds what is in the model - and - in an openly specified way. My lifecycle tools would work regardless what modelling tool to use. We are getting closer.
And I agree: xmi:id should be a surrogate, unique but without further information.

I did what you said: getting information about the xmi:id from experience exporting packages.

I was wondering whether there is some documentation about it. I could not find any.

Rolf


Rolf

qwerty

  • EA Guru
  • *****
  • Posts: 13551
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: xmi:id how to?
« Reply #4 on: November 15, 2016, 09:31:24 pm »
You did not find it since it's not documented. Sort of proprietary knowledge. You will only find the OMG-docs and they don't have those details.

Edit: Of course, see Simon's valid reply below.

q.
« Last Edit: November 16, 2016, 08:57:15 am by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8030
  • Karma: +118/-20
    • View Profile
Re: xmi:id how to?
« Reply #5 on: November 16, 2016, 08:38:04 am »
If you want to have your tools work regardless of the modelling tool to use, don't pretend the XMI is coming from Enterprise Architect. You'll get better results all round by focusing on standards compliance. It won't guarantee 100% compatibility with all tools, but if your goal is to work with multiple tools, it is the way to go.

ngong

  • EA User
  • **
  • Posts: 269
  • Karma: +1/-2
    • View Profile
Re: xmi:id how to?
« Reply #6 on: November 18, 2016, 12:32:30 am »
Hi, Simon

everyone in the UML world knows that XMI like UML is an OMG standard. That is not the point.

XMI uses an xmi:id attribute as a surrogates for each UML element, uniquely. From the XMI standard afaik tool vendors like Sparx may choose their algorithm to find a unique code given to xmi:id in order to uniquely identify a UML element.

XMI is ment to be vendor independent.

I am not sure whether Tags are properly reflected in the XMI exported by EA. I tried to find that in the XMI 2.4.1 spec but without success in the time I could spend for it. Tags are exported by EA solely in the vendor specific part of the XMI albeit they are part of the UML specification. I would expect Tags in the UML part of the EA XMI export, not the vendor specific part - but I am not sure about this, yet.

On import of XMI, in general the EA tool excepts any value for xmi:id attribute, as long as it is unique per UML element. This is imported for XMI interchange.

For this general rule EA import has at least one exception: Tags - in the vendor specific part of the XMI, that is not standardized for exchange. xmi:id attributs in this part - at least for tags - have to follow the Sparx way of unique key generation.

My question is: why violating the requirements for xmi:id attributes in the vendor specific part? And if there is a good reason: am I able to reflect that key generation in my process tools?

Now these questions are rhetorical as I have accepted not to get a sufficient answer - there are proprietary algorithms in the vendor specific part of XMI export.
Rolf

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8030
  • Karma: +118/-20
    • View Profile
Re: xmi:id how to?
« Reply #7 on: November 18, 2016, 08:54:41 am »
I am not sure whether Tags are properly reflected in the XMI exported by EA. I tried to find that in the XMI 2.4.1 spec but without success in the time I could spend for it. Tags are exported by EA solely in the vendor specific part of the XMI albeit they are part of the UML specification. I would expect Tags in the UML part of the EA XMI export, not the vendor specific part - but I am not sure about this, yet.
Actually, tags are in the standard location, as shown in this example of a single SysML 1.4 block.
Code: [Select]
<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmlns:uml="http://www.omg.org/spec/UML/20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:SysML="http://www.omg.org/spec/SysML/20150709/SysML">
<xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
<uml:Model xmi:type="uml:Model" name="EA_Model">
<packagedElement xmi:type="uml:Package" xmi:id="EAPK_00F1305B_910B_451b_8A55_AC8DA1A40EF2" name="Package1">
<packagedElement xmi:type="uml:Class" xmi:id="EAID_DF734F58_D860_4bdb_9BD0_6B159AB9B671" name="Block1"/>
</packagedElement>
<profileApplication xmi:type="uml:ProfileApplication" xmi:id="profileap_5CBC4E1F-6">
<appliedProfile xmi:type="uml:Profile" href="http://www.omg.org/spec/SysML/20150709/SysML.xmi#_SysML__0"/>
</profileApplication>
</uml:Model>
<SysML:block base_Class="EAID_DF734F58_D860_4bdb_9BD0_6B159AB9B671" isEncapsulated="false"/>
</xmi:XMI>

On import of XMI, in general the EA tool excepts any value for xmi:id attribute, as long as it is unique per UML element. This is imported for XMI interchange.
Yes, but import of our xmi is the only time it won't generate it's own ids. So by saying that your XMI is generated by EA, and then not using real random guids, sooner or later you are going to end up with issues of duplicate guids.

For this general rule EA import has at least one exception: Tags - in the vendor specific part of the XMI, that is not standardized for exchange. xmi:id attributs in this part - at least for tags - have to follow the Sparx way of unique key generation.
That's just it. The Vendor specific section only has to have significance to the one tool exporting it. Your complaint is that it's too similar to the rest of the XMI. If it was a single raw base64 chunk (eg. memory dump that could be read by EA lightning fast), you wouldn't be trying to recreate it. Equally, it could be a single CDATA section containing sql statements to regenerate the model. It could be turtle encoded rdf triples.

While the xmi:id for a tagged value looks like a normal id, that is a nicety for other tools that may read the EA extensions and recreate them. If you want to use XMI to import tagged values into EA, use the standard format shown above. Your users (and probably the future you) will thank you for it.

ngong

  • EA User
  • **
  • Posts: 269
  • Karma: +1/-2
    • View Profile
Re: xmi:id how to?
« Reply #8 on: November 18, 2016, 09:54:47 pm »
Thank you very much for this superb answer, Simon.
The XMI snippet about a Tag export from SysML to XMI looks very promising.
I will investigate it. Do you think I can repeat that in plain UML?
I must say, I have not understood it fully, yet. Could not identify the Tag-name and Tag-value.
One fear of mine: Is XMI spec silent about this? Does it have to be covered by vendor-extension?
Rolf

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8030
  • Karma: +118/-20
    • View Profile
Re: xmi:id how to?
« Reply #9 on: November 21, 2016, 08:39:12 am »
This is how XMI expects tagged values to be exported. EA creates an additional copy in its private data. But the standard way is this.

I must say, I have not understood it fully, yet. Could not identify the Tag-name and Tag-value.

Red = Profile
Blue = Stereotype
Green = Tag name
Orange = Tag value
Teal = Element


<?xml version="1.0" encoding="windows-1252"?>
<xmi:XMI xmlns:uml="http://www.omg.org/spec/UML/20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:SysML="http://www.omg.org/spec/SysML/20150709/SysML">
   <xmi:Documentation exporter="Enterprise Architect" exporterVersion="6.5"/>
   <uml:Model xmi:type="uml:Model" name="EA_Model">
      <packagedElement xmi:type="uml:Package" xmi:id="EAPK_00F1305B_910B_451b_8A55_AC8DA1A40EF2" name="Package1">
         <packagedElement xmi:type="uml:Class" xmi:id="EAID_DF734F58_D860_4bdb_9BD0_6B159AB9B671" name="Block1"/>
      </packagedElement>
      <profileApplication xmi:type="uml:ProfileApplication" xmi:id="profileap_5CBC4E1F-6">
         <appliedProfile xmi:type="uml:Profile" href="http://www.omg.org/spec/SysML/20150709/SysML.xmi#_SysML__0"/>
      </profileApplication>
   </uml:Model>
   <SysML:block base_Class="EAID_DF734F58_D860_4bdb_9BD0_6B159AB9B671" isEncapsulated="false"/>
</xmi:XMI>


A profile is identified using a URI and is mapped to a namespace prefix. At the global level, all stereotype applications are emitted as elements named with the stereotype and prefixed with the profile. After specifying the element that this application is for, all the tagged values are emitted.