Author Topic: XMI export in XMI 2.1 with VBScript  (Read 4187 times)

Popoff

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
XMI export in XMI 2.1 with VBScript
« on: November 27, 2014, 12:46:03 am »
Hello all,

I am trying to export a given package as an XMI file using the 2.1 format of XMI.
With the EA interface, you just have to select "UML 2.1 (XMI 2.1)" item in the "XML Type" list.

But how to achieve this in a VBScript running from within EA (via the "Scripting" feature)?
The export format is normally defined by the EA.EnumXMIType enumeration, but VBScript can't access this information, precisely because it is an Enum type.

Here below is an extract of my code, it performs the export using the default XMI 1.1 format, because of the 0 value set to the XmiExportType variable. Which explicit value instead of 0 should I put to have a XMI 2.1 export (in other words, the hard value matching EA.EnumXMIType.xmiEA21)?

Code: [Select]
set projectInterface = Repository.GetProjectInterface()
XmiExportType = 0 ' this value is for xmiEADefault. And for xmiEA21 ???
result = projectInterface.ExportPackageXMI("EAPK_8EBC14C6_C767_4df0_9EC2_5FF5B8433A8D", XmiExportType, 0, -1, 1, 0, "export.xml")

I have tried several other values at random, without success.

Thank you

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: XMI export in XMI 2.1 with VBScript
« Reply #1 on: November 27, 2014, 03:46:26 am »
Try counting those up from 0
Quote
xmiEADefault
xmiRoseDefault
xmiEA10
xmiEA11
xmiEA12
xmiEA20
xmiEA21
xmiMOF13
xmiMOF14
xmiRose10
xmiRose11
xmiRose12
(from the Help)

q.

Popoff

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: XMI export in XMI 2.1 with VBScript
« Reply #2 on: November 27, 2014, 06:10:53 am »
Hi,

Nope, that is indeed one of the first things I have tried (1,2, etc.. until 6), and it always gives XMI 1.1 which is the default behavior.
I also tried 2^2, 2^3... 2^6 etc, same result.

It looks like as long as the provided value is not convenient for (i.e not understood by) the ExportPackageXMI function, it falls back to that default behavior.

And there is no documentation online on how to use this function in a VBScript context to do what I need. Or it is hard to find.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: XMI export in XMI 2.1 with VBScript
« Reply #3 on: November 27, 2014, 08:22:14 am »
Yep. The docu has some flaws. Maybe Roy reads this and corrects it. Additional just drop Sparx support a line and let us know their answer.

q.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: XMI export in XMI 2.1 with VBScript
« Reply #4 on: November 27, 2014, 09:19:25 am »
See Local Scripts.EAConstants-VBScript in the Scripting window.  You will find these values defined under the EnumXMIType heading.

Popoff

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: XMI export in XMI 2.1 with VBScript
« Reply #5 on: November 27, 2014, 07:50:08 pm »
OMG the answer was actually -almost- in front of my eyes since the beginning...!
Many thanks Aaron.

Still, as suggested by qwerty I think some lines about this should be added to the documentation (not only for the VBS usage of ExportPackageXMI but in the general case of using EA enumerated values within a VBS), with a reference to these .vbs samples. Otherwise it is impossible to guess which values are expected.

Alright, topic closed, thanks again.