Defining an XML Structure

You can define a simple XML structure or a complex XML structure by adding a Messenger class and a corresponding Serialization. You can create an XML structure either manually or by importing an XML Schema Definition (XSD) file.

Defining a Simple XML Structure Manually

To define a simple XML structure you must add a Messenger class in the model, define Serialization with the necessary attributes and implement the interface into the Messenger Class for processing the XML data.

To manually define a simple XML structure, perform the following:

  1. Right-click the segment, point to Add, and then select Messenger from the context menu.

    The Messenger class with the default name “Messenger1 appears under the segment.

  2. Rename the Messenger class from "Messenger1" to an appropriate name.

  3. Right-click the Messenger class, point to Add, and then select Serialization.

    The Serialization with the default name “I<Messenger name>” appears under the segment.

  4. Rename the Serialization from "IMessenger1" to an appropriate name.

    You can now define the layout of the XML message by adding attributes to the Serialization.

  5. Right-click the Serialization, point to Add, and then select Attribute from the context menu.

    The Add New Attribute dialog box appears.

  6. In the Template box, optionally enter a type or class that this attribute will derive from.

  7. In the Name box, enter an appropriate name.

  8. Click Create.

    You can add more attributes to the Serialization by selecting the Keep Open check box and repeating step 6 through step 8.

  9. In the Properties pane of the attributes change the property of each attribute as required.

You must now add the implements relationship to indicate that the Messenger class will implement the Serialization.

To create the Implements relationship, perform the following:

  1. Right-click the Messenger class, select Quick Actions…, and then select Implement an Interface….

    The Select Interface for <Messenger Name> dialog box appears.

  2. Expand the list and select the Serialization for which you want to create the Implements relationship.

  3. Click OK.

At this stage the definition is still incomplete because the class does not yet have an implementation of all of the attributes in the interface. Therefore, the Errors pane displays a list of errors indicating that the Messenger class does not implement the interface members. To resolve these errors you must Implement the interface members by performing the following:

Note: It is important to understand that it is the interface definitions and not the class definitions that define the messages and their layout.

You can preview the message layout for any class that implements a Serialization. The Message Layout Preview window shows a representation of the corresponding message layout.

To preview the message layout, perform the following:

Defining a Complex XML Structure Manually

To define a complex XML structure manually, perform the following:

  1. Add a Messenger class to a segment and add a Serialization.

    Refer to Defining a Simple XML Structure Manually for more information on adding a Messenger class and Serialization.

  2. Add another Serialization anywhere within the model structure by right-clicking on the element and selecting Serialization.

    For example, if you want to represent the following XML structure, you must add one Serialization to the Messenger class to represent the complete <Customer> message (for example, ICustomer) and another Serialization (for example, IAddress) anywhere within the model structure to represent the <Address> element:

    <?xml version="1.0"?>
    <Customer>
    <Name>John Smith</Name>
    <Age>54</Age>
    <Address>
    <Street>115 Main St</Street>
    <Suburb>Mornington</Suburb>
    </Address>
    </Customer>
  3. Add attributes to the Serialization to define the layout of the XML message.

    For example, you must add attributes, such as Name, Age, and Address to the ICustomer interface and attributes, such as Street and Suburb to the IAddress interface.

    Refer to Defining a Simple XML Structure Manually for more information on adding attributes to the interface.

  4. Define the Address attribute under the ICustomer interface as an instance of the IAddress interface by performing the following:

    1. Open the Properties of the Address attribute in ICustomer interface.

    2. Set the Template property to IAddress.

    The ICustomer interface represents the complete XML message format.

    After adding the Implements relationship, the IAddress interface is shown in the Class View window under the Base Type node as shown in the following image. In this case the Address class implements the ‘IAddress’ interface. Refer to Defining a Simple XML Structure Manually for more information on adding an implements relationship.