Profile picture for user MWZ

With the following report you can see, how easy it is to export ARIS models as an xml file.

This simple report exports the selected models with their object definitions and cxns to an xml file.

(Remark: This report doesn’t handle multiple occurrences of the same object definition in the model.)

To create the xml output object you use the following method:

var xmlOutput = Context.createXMLOutputObject(Context.getSelectedFile(), "Root");

The XML elements that can then be used in the script are defined in org.jdom.*

In this example the different items are written with the function “writeXmlItem”. This function creates a new xml element per item and adds the attributes “Name”, and “Identifier” and the type number as xml attributes.

function writeXmlItem(xmlOutput, xmlParent, oItem, sElement) {
    var xmlItem = xmlOutput.addElement(xmlParent, sElement);
    xmlItem.setAttribute("Name", oItem.Name(g_nLoc));
    xmlItem.setAttribute("TypeNum", oItem.TypeNum());
    xmlItem.setAttribute("ID", getAttrID(oItem));
    return xmlItem;
}

The function “writeXmlCxn” is used to write the connection elements with name of source and target object, the type number and the attribute “Identifier”.

function writeXmlCxn(xmlOutput, xmlParent, oCxn, sElement) {
    var xmlCxn = xmlOutput.addElement(xmlParent, sElement);
    xmlCxn.setAttribute("SourceName", oCxn.SourceObjDef().Name(g_nLoc));
    xmlCxn.setAttribute("TargetName", oCxn.TargetObjDef().Name(g_nLoc));    
    xmlCxn.setAttribute("TypeNum", oCxn.TypeNum());
    xmlCxn.setAttribute("ID", getAttrID(oCxn));
    return xmlCxn;
}

The above used function “getAttrID” to get value of attribute “Identifier” looks like this:

function getAttrID(oItem) {
    return oItem.Attribute(Constants.AT_ID, g_nLoc).getValue();
}

So that the whole script looks as follows:

var g_nLoc = Context.getSelectedLanguage(); 
var xmlOutput = Context.createXMLOutputObject(Context.getSelectedFile(), "Root");

var oSelModels = ArisData.getSelectedModels();
for (var i = 0; i < oSelModels.length; i++) {
    var oModel = oSelModels[i];
    var xmlModel = writeXmlItem(xmlOutput, xmlOutput.getRootElement(), oModel, "Model");
    
    var oObjDefs = oModel.ObjDefList();
    for (var j = 0; j < oObjDefs.length; j++) {
        var oObjDef = oObjDefs[j];
        var xmlObjDef = writeXmlItem(xmlOutput, xmlModel, oObjDef, "ObjDef");
    }
    
    var oCxnDefs = oModel.CxnList();
    for (var j = 0; j < oCxnDefs.length; j++) {
        var oCxnDef =  oCxnDefs[j]
        var xmlCxnDef = writeXmlCxn(xmlOutput, xmlModel, oCxnDef, "CxnDef");
    }
}
xmlOutput.WriteReport();

/****************************************************************************/

function writeXmlItem(xmlOutput, xmlParent, oItem, sElement) {
    var xmlItem = xmlOutput.addElement(xmlParent, sElement);
    xmlItem.setAttribute("Name", oItem.Name(g_nLoc));
    xmlItem.setAttribute("TypeNum", oItem.TypeNum());
    xmlItem.setAttribute("ID", getAttrID(oItem));
    return xmlItem;
}

function writeXmlCxn(xmlOutput, xmlParent, oCxn, sElement) {
    var xmlCxn = xmlOutput.addElement(xmlParent, sElement);
    xmlCxn.setAttribute("SourceName", oCxn.SourceObjDef().Name(g_nLoc));
    xmlCxn.setAttribute("TargetName", oCxn.TargetObjDef().Name(g_nLoc));    
    xmlCxn.setAttribute("TypeNum", oCxn.TypeNum());
    xmlCxn.setAttribute("ID", getAttrID(oCxn));
    return xmlCxn;
}

function getAttrID(oItem) {
    return oItem.Attribute(Constants.AT_ID, g_nLoc).getValue();
}

Here you can download the entire source code from the "XML Export" report.

Note: This article describe how to develop a report in ARIS. See this post for links to similar articles.

by Sergei Real-Picture
Posted on Sat, 06/26/2010 - 11:47

Hi, Michael

Good piece of code, thanks

By the way, do you know how to obtain information about User group, such as

  1. Filters
  2. Access rights to Folders
  3. Functional rights
  4. User list

All this - using Java Script.

Thanks in advance for the piece of code.

Sergei

0
by Deborah Dale
Posted on Sat, 06/16/2012 - 11:17

Is it possible at all to set from here the xlst file that the xml should use?

0
by kalyan talluri
Posted on Tue, 12/09/2014 - 08:38

Hi I need a sample ARIS process (EPC/BPMN) exported into an XML file..can some one help me in getting an XML file

 

0
by Malte Klang
Posted on Wed, 06/08/2016 - 13:27

Hi,

I try to build a soap message

For this I need to set the xmlns:prefix="URI"

Is possible to set this or how it is possible to use a colon in Element Name?

0
by Apuroopa GSL
Posted on Wed, 05/05/2021 - 16:33

hi Michael, 

Can you help on how to handle occurences of an object in a model too

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock