Archi Forum

Archi => Archi Development => Topic started by: thope@ozemail.com.au on April 08, 2019, 07:01:46 AM

Title: CSV to XML
Post by: thope@ozemail.com.au on April 08, 2019, 07:01:46 AM
Hi All,

I am trying to write a javascript that can be run in Archi, to directly input and change values in the model's XML.
I am not sure if such a feat is possible within Archi and was hoping someone could tell me, or suggest an alternative.
I've been looking at using JQuery to write from CSV into XML but i believe this does not work in Archi.

The larger scope is: I have a csv File that I wish to read data from, take specific data from the csv file and write it into an existing model on Archi.

Cheers,
Roman
Title: Re: CSV to XML
Post by: Phil Beauvoir on April 08, 2019, 08:51:44 AM
I think you have two options, depending on the form of data you have.

(1) You can import and update a model with csv if the csv is in the correct csv format. So you would need to get your csv data into this format. More details in the Archi User Guide.

(2) It's also possible to update/modify a model using jArchi. This would entail writing a script in JavaScript to (a) read the csv file (b) parse it (c) cherry pick the data and modify a model with this data.

Phil
Title: Re: CSV to XML
Post by: Jean-Baptiste Sarrodie on April 08, 2019, 19:08:08 PM
Hi,

Here is an example using jArchi: https://gist.github.com/smileham/1e57a5946235e780dee5a824f664aa3d

Regards,

JB
Title: Re: CSV to XML
Post by: thope@ozemail.com.au on April 10, 2019, 02:00:24 AM
Thank you for all your replies,

I have been looking at option two from Phil, as it seems to be more closely aligned with what i've been trying to do.
I've looked into the example given by JB, where the user looks like its using papa parse to extract from a csv into a new csv file format,
which is half of what I need. However, I', still unsure if I can inject the extracted csv data into an existing model's XML.

I guess my question is, how do I modify a model's XML using javascript.

Cheers,
Roman
Title: Re: CSV to XML
Post by: Jean-Baptiste Sarrodie on April 10, 2019, 06:48:39 AM
Hi,

You do not modify le XML, you edit the model itself in memory using jArchi's API (or through CSV import). Then you simply generate your report. In this (automated) process no XML file is created because you never save the model in the native format.

Regards

JB
Title: Re: CSV to XML
Post by: Stanley on September 17, 2019, 23:03:20 PM
Hi

Is there a way to massively update and delete elements and its relationships in a waterfall way with jArchi on the XML?

Best regards,
Title: Re: CSV to XML
Post by: Jean-Baptiste Sarrodie on September 18, 2019, 06:50:25 AM
Hi,

You can do almost whatever you want with jArchi. You can have a look at its API: https://github.com/archimatetool/archi-scripting-plugin/wiki

Regards,

JB