Search code examples
c#xmladd-inenterprise-architect

Enterprise Architect Model Search XML Format


I have written a few Add-Ins for Enterprise Architect in C#. I want to add a complex model search now in a similar manner. I have no issue running my add-in search. I believe my issue is with the XML Model Search Format. The only documentation that I can find is here.

I tried to use the example JScript and VB Script files in EA "JScript - Model Search (Attributes) Example". I cannot get that to give me output when I run it in EA. That has to be user error, I believe. I am using that code as an example to try to properly output my search results from a C# add-in.

I can't figure out what the value for <ReportViewData UID=\"MySearchID\" > should be? It seems like it should be the UID of the search. How does one find that? It is missing from the JScript example, as far as I can tell.

Does anyone have a properly formatted XML Search Format file I can test? Just modifying a known working file by hand to match an element in my repo and importing the results would be a huge help. I can't find any documentation other than what I have linked above.


Solution

  • My big issue was not using the out keyword in my C# function for the XMLResults value. The function declaration in Thomas's answer was that fix.

    The value for "MySearchID" is the GUID for the search. After creating the add-in search using the builder in EA export the search as XML. The XML export file contains the GUID for the search. Use that value to replace "MySearchID". Here is my XML output generated by a C# add-in as an example of a file that has worked:

    <ReportViewData UID="{74945F94-D210-4f45-8639-784DAE0DAB1F}">
      <Fields>
        <Field name="CLASSGUID" />
        <Field name="CLASSTYPE" />
        <Field name="Object" />
        <Field name="Type" />
        <Field name="Stereotype" />
      </Fields>
      <Rows>
        <Row>
          <Field name="CLASSGUID" value="{A16DD03A-B1B2-4269-A058-0AB14B933388}" />
          <Field name="CLASSTYPE" value="Class" />
          <Field name="Object" value="Class1" />
          <Field name="Type" value="Class" />
          <Field name="Stereotype" value="AffineConversion" />
        </Row>
        <Row>
          <Field name="CLASSGUID" value="{44E11CA0-1FAE-47ee-9088-D3106F320C57}" />
          <Field name="CLASSTYPE" value="Class" />
          <Field name="Object" value="Class2" />
          <Field name="Type" value="Class" />
          <Field name="Stereotype" value="MessagePort" />
        </Row>
      </Rows>
    </ReportViewData>