OpenPonk / xmi

Materialization and serialization between XMI files and XMI graphs.
MIT License
4 stars 1 forks source link

trouble loading Power System Common Information Model exported from EnterpriseArchitect #1

Open bencoman opened 5 years ago

bencoman commented 5 years ago

Howdy,

I'm having trouble loading the attached XMI into OpenPlonk. It was exported from Enterprise Architect like this... 194220_orig

Any interest to help get it working? i.e. is it a good use case for you? (if not, thats cool, just close this ticket) [EDIT: Deleted failed upload link.]

Background info... https://sparxsystems.com/enterprise_architect_user_guide/14.0/model_publishing/importexport.html https://sparxsystems.com/enterprise_architect_user_guide/14.0/model_publishing/limitationxmi.html

bencoman commented 5 years ago

I got a bit further by forcing the encoding...

OPUmlClassEditorPlugin>>importToPackage: aPackage
    FDOpenFileDialog new
    whenSelected: [ :file | |model xmi|
        xmi := file fullName asFileReference binaryReadStreamDo: [ :in | 
            | bytes encoder |
            bytes := in upToEnd.
            encoder := ZnCharacterEncoder newForEncoding: 'cp1252'.
            encoder decodeBytes: bytes  ].
    model := OPUMLXMIReader read: xmi.

but it would be great if that could be determined dynamically from the first line of the file <?xml version="1.0" encoding="windows-1252"?>

peteruhnak commented 5 years ago

Could you please upload the file again or send it to me via mail? It seems that GitHub messed up the upload.

bencoman commented 5 years ago

This upload seems to have worked... iec61970cim17v23a_iec61968cim13v12_iec62325cim03v14.zip

peteruhnak commented 5 years ago

There seems to be several issues so far that I need to address.. (this is more of a todo list for me)

  1. encoding XMLDOMParser handles this automatically internally, but I need to pass a binary read stream, instead of the (default) text stream.

  2. Security limit This can be configured globally and locally... e.g.

XMLParserLimits defaultReadLimit: file size
"or"
dom := (XMLDOMParser on: stream) usesNamespaces: false; documentReadLimit: stream size; parseDocument.
  1. Incorrect representation of upper value

For some reason (EA's backwards compatibility maybe?) EA represents an unlimited upper value of a property (attribute) as an Integer with value n. However the spec states that it should be UnlimitedNatural with value * ... but this is easy to modify for me.

<upperValue xmi:type="uml:LiteralInteger" xmi:id="EAID_LI000782__826C_44f6_8B37_E168629E4395" value="n"/>
  1. Incorrect representation of InstanceSpecification

A harder problem is InstanceSpecification (see chapter 9.8 of UML 2.5 specs). For some reason the element contains ownedAtribute as children, however this is not a valid element; instead it should be represented as Slots... so I don't know why EA generates this

<packagedElement xmi:type="uml:InstanceSpecification" xmi:id="EAID_B2E53EF1_F2BE_4b05_BAC3_A0BB508D4AAD" name="4" visibility="public">
    <ownedAttribute xmi:type="uml:Property" xmi:id="EAID_dst82C702_0877_488d_BB29_24487D9DB406" visibility="public" association="EAID_3482C702_0877_488d_BB29_24487D9DB406" isStatic="false" isReadOnly="false" isDerived="false" isOrdered="false" isUnique="true" isDerivedUnion="false" aggregation="none">
        <type xmi:idref="EAID_FFC2FB67_AF8D_4efe_8844_F10C6AD3122D"/>
    </ownedAttribute>
    <ownedAttribute xmi:type="uml:Property" xmi:id="EAID_dst7CC185_CF5A_49d2_A179_0DE8B4C703A7" name="TargetObject" visibility="public" association="EAID_F37CC185_CF5A_49d2_A179_0DE8B4C703A7" isStatic="false" isReadOnly="false" isDerived="false" isOrdered="false" isUnique="true" isDerivedUnion="false" aggregation="none">
        <type xmi:idref="EAID_C5C1CA1E_0CAE_4f31_882A_AFAC16DE86A0"/>
    </ownedAttribute>
    <ownedAttribute xmi:type="uml:Property" xmi:id="EAID_dst088919_EB57_4f4c_8DE4_ADB900406DC6" visibility="public" association="EAID_F9088919_EB57_4f4c_8DE4_ADB900406DC6" isStatic="false" isReadOnly="false" isDerived="false" isOrdered="false" isUnique="true" isDerivedUnion="false" aggregation="none">
        <type xmi:idref="EAID_11777CB9_3BCA_45c7_BC26_F8F1AF933702"/>
    </ownedAttribute>
</packagedElement>
  1. Profiles

The model contains four or five profiles... I do support Profiles to some extent, however the Profile elements must be actually implemented as Pharo classes... I have generator for that, but I encountered some issues with primitive types, and it needs to be more easily available.


I will be looking at these issues over the next week or so. All except #4 are fairly straight-forward, but #4 I am not quite clear yet as to why is EA doing that... if you could look into that, that would be great.

bencoman commented 5 years ago

Big thanks for having a look at this Peter.

Now I'm not at all familiar with XMI and well out of my depth here, but after floundering around for a few hours the following seemed interesting...

https://www.sparxsystems.com.au/bin/UML2SuperStructure.pdf

http://cobweb.cs.uga.edu/~kochut/teaching/x050/UML-2.5.pdf

I don't quite grok the meaning of the term "subsets" is used here.
It tastes a bit like "inheritance" or "overrides".

bencoman commented 5 years ago

hi peter, was that information sufficient, or do you need more? Or should I try other options? The source EA file is Microsoft Access format and a few few years ago I managed to open it directly a grok the raw tables.