Author Topic: XML output of script which is custom input to template fragment  (Read 1741 times)

Gaikwadk

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Hello All,
       I have written a Jscript which returns output field in XML format, which is a field I am including in template fragment as a custom field.
But as observed there is a fixed format for the XML output.
<EADATA>

 <Dataset_0>

   <Data>

     <Row>
            <MyData> name</Mydata>
       
     </Row>

   </Data>

 </Dataset_0>

</EADATA>

Now if I want another row inside <Row> then I am not able to create new row inside the existing row.

var xmlRow1 = xmlDOM.createElement( "Row1" );
xmlRow.appendChild(xmlRow1);

or is there any changes in the name of field to be made if I add another row inside existing row,which I will be including in Custom field inside fragment.

custom>
{MyData}
<custom

Please suggest any solution.
with example will be good for undersatnding.
Thank you.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8204
  • Karma: +193/-23
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: XML output of script which is custom input to template fragment
« Reply #1 on: May 23, 2016, 07:30:35 pm »
You should create a new row as a sibling to the existing row node, not inside the row node.
See https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/tree/master/Projects/Project%20A/Template%20Fragments for some real world examples.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1261
  • Karma: +91/-8
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: XML output of script which is custom input to template fragment
« Reply #2 on: May 23, 2016, 08:38:01 pm »
What Geert said. Plus:

The format expected in a "script" template fragment is the same as the XML format for search results, which you can use in Repository.RunModelSearch(). The structure is
Code: (XML) [Select]
<EADATA> (singleton)
    <Dataset_0> (singleton)
        <Data> (singleton)
            <Row>
                <column_name_1> ... </column_name_1>
                <column_name_2> ... </column_name_2>
                ...
            </Row>
            <Row>
                <column_name_1> ... </column_name_1>
                <column_name_2> ... </column_name_2>
                ...
            </Row>
...

The set of columns must be the same in each row.

Why do we need both <Dataset_0> and <Data>? Yes. Next question?

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8204
  • Karma: +193/-23
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: XML output of script which is custom input to template fragment
« Reply #3 on: May 23, 2016, 11:07:51 pm »
The format expected in a "script" template fragment is the same as the XML format for search results,
IIRC it's almost/i] the same, but not quite.
I don't remember the exact differences though.

Geert

Gaikwadk

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: XML output of script which is custom input to template fragment
« Reply #4 on: May 26, 2016, 02:50:22 pm »
Thanks uffe & Geert for the reply.