Composer User's Guide

CHAPTER 6

Creating an XML Map Component

In many ways, the Composer XML Map Component is the simplest yet most important of Composer's component types. You will use it to perform XML transformations of input documents to output documents. It is essential that you understand how XML Map Components (and related resources) work if you are to build useful Composer services.

This chapter introduces you to XML Map Components and describes how they work within an exteNd Composer service. After reading this chapter, you will understand what comprises an XML Map component, what it can do, and how to design, create, and use an XML Map component.

 
Top of page

What is an XML Map Component?

An XML Map component is an object that accepts one or more XML documents as inputs, uses a collection of actions to operate on these inputs and returns an XML document as output.

6inputoutput

An XML Map component can perform simple data manipulation, such as mapping and transferring data from one XML document to another. It can also carry out sophisticated manipulations, such as transforming both the data and structure of a document. You can even create XML Map components that process XSL, send mail, and post and receive XML documents using the HTTP protocol.

The concept behind a component is to pass one or more XML documents in as inputs, process these inputs, and return one output XML document. The output XML document is then used as input for other components or returned as the final output of a service. In this way, you can create components that work together in a service to carry out complete business-to-business solutions.

 
Top of section

Using XML Template Sample Documents to Build an XML Map Component

The XML documents you use when building an XML Map component are samples of the actual documents that will be processed in a running application. Sample documents are added to Composer in XML template objects. You use samples of documents whose structure and data representation are identical to the documents that will be processed. The illustration below shows the difference between documents you use for building purposes and those that are actually processed by the component.

The samples used to build a component are not actually used, or even referred to by name, at runtime. They are simply templates that represent the structure and data to be manipulated. The samples are temporary aids that help you construct processing actions that perform the correct runtime manipulations. What exteNd actually uses at runtime to process XML data is an object representation of the XML document called a DOM.

 
Top of page

What is a DOM?

In the XML Map component editor, a sample document is represented in a format recommended by the W3C known as the document object model (DOM). A DOM is an XML document constructed as an object in a software program's memory. It provides standard methods for manipulating the object. Using DOMs, Composer lets you build XML documents, navigate within their structure, and add, modify or delete elements and content. Anything found within an XML document can be manipulated using a DOM method. Composer supports all DOM methods recommended by the W3C ECMA to DOM Binding Specification (See http://www.w3.org/).

NOTE:   In some dialogs, Composer refers to DOMs as Messages.

 
Top of section

Understanding DOM Structure

When the XML Map component editor is active, every sample document is converted to a DOM.

DOMs are used because:

A DOM is organized hierarchically, which means it forms a tree structure. To understand how a particular DOM is structured, it's often useful to be able to view the DOM from different perspectives. For example, sometimes it's helpful to see the raw text of the XML document underlying the DOM. Other times, you may be interested in seeing a summary view of the data (rather than the element and attribute names) in a document. Composer allows you to change views as necessary in order to switch between tree, text, and summary presentations.

To change views, simply right-click inside any DOM window, then select the view you want to see from the View submenu. The three available view types are shown below.

6xmldoc01

Elements in a DOM are defined by tags in an XML document. For instance, in the above example, there is an element tag in the XML document named <INVENTORYSTATUS>. The tag has an end tag (</INVENTORYSTATUS). All structural elements within <INVENTORYSTATUS> and </INVENTORYSTATUS>, such as <SKU>, are represented at a lower (or in DOM terminology, descendant) level in the DOM tree.

All element names are case-sensitive, meaning that <INVOICENO> is not the same as <InvoiceNo>.

An element in a DOM tree is referred to as a node. A collection of nodes is represented in a hierarchy and is referred to by the following naming conventions:

Node Type

Description

Root

The topmost element in a DOM tree from which all other elements are descendants. Only one is allowed.

Descendant

Any node that is below (contained within) another node

Child

The immediate descendant of a node

Sibling

All nodes that share the same parent node

Ancestor

Any node that is above (contains) another node

Parent

The immediate ancestor of a node

Leaf

Any node without a descendant

Each element type in a DOM has its own icon, as identified below.

 
Top of section

Using DOMs at Runtime

It is through DOMs that components pass and return data to one another in a running application. At runtime, when a component is executed, it is passed a DOM. The passed DOM becomes the Input Part to be operated on. As each of the component's mapping actions executes, the Output Part is created, element by element.

 
Top of section

DOM Behaviors during Runtime

The first time you open a component, the original samples are loaded into the Input and Ouput DOMs. When you begin animation, the Input Part remains and the Temp and Ouput DOMs are cleared from any data originally contained in them. At the end of execution, data appears in all DOMs.

 
Top of section

Creating Different Types of Messages

When you create an XML Map component, you select input and output XML templates for it. However, within the Component Editor you can also:

 
Top of page

Creating an XML Map Component

The first step in creating an XML Map component is to specify the XML templates for the component. For more information, see Creating an XML Template.

Once you've specified the XML templates, you can create your component, using the template's sample documents to represent the inputs and output processed by your component.

NOTE:   Various other component types (such as the JDBC Component, JMS Component, etc.) are covered in detail in the appropriate Enterprise Connect product user guides. The same basic principles are used in the creation and editing of all components, however. Also, the various Basic Actions (see next chapter) available in the XML Map Component are also available in all other Composer component types.

Procedure To create an XML Map component:

  1. From the Composer File menu, select New then xObject. Select the Component tab and then XML Map. The New xObject dialog box appears.

    6NewXMLMap01

  2. Type a Name for the component.

  3. Optionally, type Description information.

  4. Click Next. A new panel appears as follows.

    6newxmltmpl02

  5. Specify the Input and Output templates (also called Messages).

  6. Select an XML template as an output using the same methods described in the previous step.

    NOTE:   You can specify an output XML template that contains no structure by selecting {ANY} as the Output template. For more information, see Creating an Output Document without Using a Template.

  7. Click Next to go the Temp an d Fault XML template dialog. If desired, specify a template to be used as a scratchpad under the "Temp Message" pane of the dialog window. This can be useful if you need a place to hold values that will only be used temporarily during the execution of your component or are for reference only. Under the "Fault Message" pane, select an XML template to be used to pass back to clients when a fault condition occurs.

    6NewXMLTmpl02b

  8. As above, to add additional XML templates, click Add and choose a Part Name, a Template Category and Template Name for each. Repeat as many times as desired. To remove an input XML template, select an entry and click Delete. Temp and Fault Message Parts are discussed in more detail below, beginning on page 118.

  9. Click Next. For several of the component types, the Connection Info panel will appear, allowing you to select a previously created Connection Resource.

  10. Click Finish. The component is created and the XML Map Component Editor appears.

6newxmltmpl03

 
Top of page

Namespaces and Output Parts

You should be aware that when a new XML Map Component is created whose Output template uses namespaces, a new Map action will automatically be placed into the action list, mapping the namespace URI to an attribute in the Output Part. It's important not only that you not delete this Map action, but that you avoid accidentally overwriting it. An overwrite can happen if you place a Component action downstream of the namespace-URI Map action, and the Component action returns its results to the Output Part. The solution in this case is to move (by Cut and Paste) the original Map action to a spot downstream of the Component action.

 
Top of page

Understanding the XML Map Component Editor

The XML Map Component Editor is where you specify the mapping, transformation, and transfer of all input and output structure and data.

The XML Map Component Editor provides a logical working environment for the inputs, output, and actions of your component. The XML Map component editor is composed of multiple Mapping panes and a single Action Model pane. The Mapping panes display the XML for your sample Input and Output message parts. The Action Model pane displays actions that operate on the Mapping panes.

The following illustration shows the XML Map Component Editor with its menu and toolbar, one input Part, one output Part, and several actions in the Action Model pane.

 
Top of section

About the Menu and Toolbar

The main menu in Composer and it's sub-menus and toolbar options change according to the type of component you currently have open in the Component Editor. The following component-specific options occur on the main menubar when an XML Map Component is open.

XMLMap Component Menu

Options

File

You can create, open and delete any type of component from the File menu, just as you can from the Composer File menu.

Some menu choices have implications that are particularly significant for XML Map Components:

Save saves the inputs, output and actions in the component

Save As... saves the component under a new name and allows you to change the inputs, output, and actions. See Saving Your Component.

Save All... saves all components currently open

Save XML As . . . allows you to save the structure of the message Part into an XML document. See Saving a DOM as an XML Document.

Load XML Sample . . . allows you to load other sample documents from a template into a message part for testing the component. See Loading a Sample Document.

Properties lets you view the component's templates and other information. See Viewing Component Properties.

Print lets you print your component

Edit

You can undo or redo an action, cut, copy, and paste text anywhere in the component editor. In addition, you can do the following:

Find finds an element in a mapping pane or text in the Action Model. See Finding a Document Element.

Find Next finds the next element in a mapping pane or text in the Action Model. See Finding the Next Document Element.

Replace replaces selected text in the Action Model only. See Replacing Text in the Action Model.

View

Navigator Tabs toggles the visibility of the nav frame at the left of the Composer main window. Use this command to hide or unhide the whole nav frame.

Output Tabs toggles the visibility of the Message frame at the bottom of the Composer main window. Use this command to hide or unhide the whole Message frame.

Document Tabs toggles the visibility of the XML Document Tabs in the Component Editor.

XML Documents brings up a submenu with the following choices:

  • Show/Hide allows you to change the order and visibility of all message parts associated with the open component (see "To set the visibilities of XML documents:" below)

  • Collapse All hides all XML nodes except for the root node in all mapping panes.

  • Expand All displays all XML nodes in all mapping panes.

  • (as Tree, as Text, as Stylized) displays controls how XML contents are displayed in the Component Editor.

Window Layout allows you to specify which DOMs to display and how to arrange the DOM and Action Model panes within the component window. See Using Window Layout and Show/Hide in the Component Editor.

Component

Execute—Runs the component from start to finish, for testing purposes.

Reload XML Documents reloads the original samples from the Input and Output templates, clearing whatever is currently shown in the XML message panes. See Reloading an XML Document.

Add Watch allows you to identify certain data items and examine their data values during the execution of a component as a debugging aid.

Action

New Action contains all actions that you can add to the Action Model.

Edit allows you to edit a selected action

Disable allows you to disable a selected action

Animate

This menu contains all processing animation tools that you can use to test the component. The Toolbar contains buttons that allow you to run animation tools. For more information, see Testing and Debugging.

Many of the menu items are on the toolbar. Rest your mouse on a toolbar item for a brief description of it.

 
Top of section

Using Window Layout and Show/Hide in the Compo nent Editor

The panes of the component editor can be displayed, hidden, repositioned and resized, making it easier for you to work with their contents. Use the Window Layout option and the Show/Hide option from the View Menu.

Procedure To arrange the panes of the component editor:

  1. Select Window Layout from the View menu. The Window Layout dialog appears and allows you to adjust the placement of the panels in the Window.

    6WindowLayoutPanel

  2. Select the orientation of the XML documents and Action Model as follows:

  3. Click OK.

  4. If you're not satisfied with the result, select View then Window Layout, and then click the Reset button. The panes revert to the default setting.

Procedure To set the visibilities of XML documents:

  1. Select View/XML Documents>Show/Hide . The Show/Hide dialog displays the visibility status of XML documents.

    NOTE:   The Input and Output XML documents default to the Show column. DOMs created as a result of a component action default to Hide.

    6WindowLayoutXMLLayout

  2. Select any XML documents you want to be displayed from the Hide column and click the left-triangle button. Conversely, select any XML Documents that you don't want to display from the Show column and click the right-triangle button.

  3. Select the XML document you want to display as the top document and click the up-triangle button until the document is displayed at the level you want in the Show column.

    NOTE:   If you selected a left-to-right orientation in the preceding procedure ("To arrange the panes of the component editor:", above), the order of your XML documents appears from left-to-right: Higher-precedence documents will appear on the left.

  4. Continue to select XML documents in the Show column and use the up and down buttons as necessary until the XML documents are in the desired order.

  5. Click OK. The Window Layout dialog closes and the Component editor is rearranged accordingly.

Managing Document Panes from within the XML Panel

Individual XML document panels can be maximized, normalized or closed using icons located within the header area of the document panel:

Clicking the Maximize icon will cause the document to take over the entire XML Panel area, temporarily hiding any other open message Parts. Once a document has been maximized, the icon will change to the Normalize icon, so you can restore the document to its previous size.

Clicking the Close icon will hide the document from view. Closing all XML documents leaves the XML Panel open but empty. To re-open a document when the editor panel is in this state, click with the RMB. A context menu is displayed, from which you can select a document to open.

6XMLRMBmenu

 
Top of section

About the Mapping Panes

The default XML Map component editor has the following window pane configuration:

Note that there is a color coding aspect of the mapping pane. Red indicates the first direct mapping of an element, so that if you wanted to look at what elements in the output tree have been mapped, you can identify that by the color red. Green indicates the first occurrence of the element that has a repeat alias defined for it.

NOTE:   You must use Window Layout discussed above to display a dynamically created message part, such as mapping panes created dynamically by the XML Interchange action.

 
Top of section

About the Input Mapping Pane

The Input Mapping pane displays one sample document from the input XML template as a document object in the Component Editor. (If your component contains multiple templates, each input message is displayed in its own pane.) The panes can be sized by dragging borders up, down, left, or right.

If your component contains multiple input XML templates, they are displayed with the following names:

Display Order

Document Name

First template

Input

Second template

Input1

Additional templates

Inputn: (n = the template order minus one. For instance, the the last input template is the fifth input template, the DOM name will be Input4.)

The template display order is determined by the order you specified when selecting XML templates at the time of the component creation. You can change this order using the up and down arrows using View>XML Documents>Show/Hide, as indicated above.

About DOM Elements and Data Values

Each input pane consists of two areas: the DOM tree and the Data values. The following illustration shows an Input Part with several elements and data for those elements.

Notice that when you select an XML element, the element name appears in the status bar showing the fully qualified element name. Any data associated with the element (from the XML document) appears in the Data area. Although the data is not used when the component processes at runtime, the data is helpful for setting up and testing the component. You can leave the data in the DOM elements, or you can change the data. For more information on changing the data, see Editing a Value for a Document Element (Edit Data command).

About the Input Mapping Pane Context Menu

The Input Mapping pane has a context menu you can access to perform tasks on the Input Parts. To access the context menu, click the right-mouse button anywhere in the pane. The context menu is shown below.

6inputcontext01

Creating a Repeat for Element, Declare Alias, or Declare Group Action

You can create a Repeat for Element, Declare Alias, or Declare Group action on an element that repeats in the Input Part. See The Declare Alias Action.

You can also create a group of DOM elements which aids in transforming DOM elements into a structure that is different from their original positions in the sample document. When you create a group, you can perform aggregate operations against a group. For instance, you can arrange DOM elements into a group by U.S. state (e.g., Alabama, Arizona) then sum the total sales by each state.

Groups always work in conjunction with a Repeat for Group action. For more information about creating and using groups, see The Repeat for Group Action.

Editing a Value for a Document Element (Edit Data command)

You can select an element in an Input Part and set the value for it. This is helpful when you run the animation tools to test the component.

NOTE:   The value is temporary for the editing session.

Procedure To edit a value for a Document element:

  1. Select an XML element from your document.

  2. Click the right-mouse button in the input pane.

  3. Select Edit Data.

    6EditData

  4. Notice that the document element you selected appears in the dialog box. Type in the value you wish to set for the element.

  5. Click OK. The value appears in the Data area, next to the element you selected.

Add to Display

Use this context menu option to add additional XML documents to the display area of the XML Panel. When you select Add to Display from the menu, a list appears containing the currently unopened documents associated with the component, as well as the PROJECT variable and _SystemFault. Select from this list to open any of these items.

View Commands

You can view individual XML Message Parts as a Tree, as Text, or in stylized form (using an XSL stylesheet).

Tree View

The default view displays the Message Part as a tree, as shown below.

6ViewDOMasTree

This view allows you to edit element and attribute values (that is, document data) but not the structure of the XML.

Text View

In Text View, you can see and edit the complete XML file, including structural elements.

Display the Message Part as text by clicking on the right mouse button (anywhere in the XML panel) and selecting View, then As Text. The XML then appears in plain-text form, as shown here.

6ViewDOMasText

Text view offers a convenient way to inspect non-content-model portions of the Input, Temp or Output Parts, such as comments, processing instructions, DOCTYPE declarations, and so forth.

NOTE:   The Text view, like the Tree view, is updated dynamically during animation so you can see the results of individual Map actions as they are executed.

Stylized View

When the Stylized view is selected (by clicking with the RMB and selecting View>As Stylized), you get a view of the XML message contents that looks like this:

6ViewDOMasStyled

This view gives a "report" style overview of the XML contents so that you can see at a glance what the content is for all attributes and elements.

NOTE:   The default XSL stylesheet that Composer relies on for creation of this view can be found inside the xcd-all.jar file in your \bin directory; its name is default.xsl. You can edit or replace this file by extracting (unzipping) it from the jar file and reinserting an editing version in the same place in the jar.

Show Comments

Another View function is Show Comments which allows you to toggle the visibility of comments in the source XML file. Comments, signified by markers <!-- and --> wrapping a section of content, constitute DOM nodes, but you may not always want to view them, particularly if you have a lengthy document.

Expanding a Document Tree

You can display all elements in a document tree by clicking the right-mouse button and selecting View>Expand Tree.

Another way to expand the tree is by clicking on the plus icon just to the left of the Part name (e.g., the word Input) at the top left-hand corner of the pane .

Collapsing a Document Tree

You can hide all elements in a document tree by clicking the right-mouse button and selecting View>Collapse Tree.

Another way to collapse the tree is by clicking on the minus icon just to the left of Part name (e.g., the word Input) at the top left-hand corner of the pane.

Reloading a Document Tree

You can reset a specific XML Message by bringing up the context menu and selecting View>Reload Tree. This allows you to reload an individual document tree within the XML Map component. You may wish to reload a tree if during testing, you halted animation, leaving the document in an unfinished state.

Launch Editor

Selecting Launch Editor from the context menu opens your document in the default XML editor you specified during installation.

Load XML Sample

The Load XML Sample function available in the context menu allows you to load other sample documents from a template into a message part for testing the component. See Loading a Sample Document.

Save XML As

Selecting Save XML As from the context menu allows you to save the structure of the currently open Message Part into an XML document. See Saving a DOM as an XML Document.

Finding a Document Element

You can search for element names and element data using the Find command (which appears in the XML Panel context menu). The Find dialog allows you to enter a value and search the document tree. You can search for partial words or whole words only, and you can ignore the text case when searching. The Find Text dialog box is shown below.

Finding the Next Document Element

You can search for the next occurrence of a word or string you searched for previously. There is no dialog box when you select Find Next or press the F3 key. Instead, Composer locates the next occurrence of the last find. If no match is found, nothing happens.

Validating a Dom

You can validate the DOM against its DTD or schema definition file by picking Validate from the context menu. Validating is useful during the construction and testing of your component.

 
Top of section

About the Output Mapping Pane

The Output Mapping pane displays the Output Part. The Output Mapping pane also has a context menu, as shown.

6outputcontext01

The options on the Output Mapping pane context menu are similar to the ones on the input mapping pane context menu, but with the differences described below.

Mapping an Input Element to an Output Element

You can use the Map action by selecting it from the right-mouse context menu.

Setting a Value

The Edit Data option on the Output Part allows you to inspect the value of a node but not change it.

 
Top of section

About the Action Model Pane

All components have a single Action Model. The Action Model represents the mappings, transformations, and other actions that will be performed on XML documents during runtime processing. The Action Model Pane is also resizable within the XML Map Component Editor window. Most of your activity that takes place in the Action Model pane involves adding and editing actions.

About the Action Model Context Menu

If you right-click in the Action Model, you see the menu shown below.

6actionpanecontext01

From this menu, you can select actions and perform other tasks.

Replacing Text in the Action Model

You can replace a word or string using the Replace option on the right mouse menu or on the component editor Edit menu.

Procedure To replace text:

  1. Right click in the Action Model and select Replace (or select an action and select Replace from the Edit menu).

    6replacedlg

  2. Enter the search text and click OK.

  3. Composer finds the first occurrence and asks you to confirm the replacement. You can then replace the next or all occurrences.

 
Top of section

Adding Actions to a Component

Once you have specified the Input and Output templates, the XML Map Editor opens, and you are ready to start adding actions. Actions are the processing steps that take place within the component. You will read more about actions in later topics.

Within components, you add actions to map DOM elements, read and write data from files, send e-mails, and other common tasks. A collection of actions is referred to as an Action Model.

An action in the Action Model is displayed as a line and contains an icon for the action type along with an abbreviated definition of the action. Some actions are subordinate to other actions. For instance, you can create a Repeat action that controls loop processing, then add actions inside the loop. The actions inside the loop are subordinate to the Repeat action and appear indented beneath it. They process as long as the Repeat action is true.

Procedure To add actions to the Action Model:

  1. Position the cursor in the Action Model pane above where you want the next action inserted.

  2. Add an action using any of following methods. The new action is inserted below the line you highlighted.

NOTE:   You can reorder actions in the Action Model by dragging them to a new position.

Once you've created the Action Model, and before you process the component with live data, you should test the component. Perform testing by using Composer's Animation tools. With the Animation tools, you can set breakpoints, start a animation, step into and over actions, and pause the animation.

 
Top of section

Creating an Output Document without Using a Template

You can specify an output XML template that contains no structure by selecting {SYSTEM}{ANY} as the Output template when you create the component. You can then build the Output Message Part dynamically by mapping input Part elements to output Part elements that do not yet exist.

For example, the following illustration shows a component with an input Part containing elements, and an output Part that has no elements.

6blankoutput01

Notice there is nothing in the output document. To dynamically build an output document, you can map input Part elements to a structure in the output Part that does not exist. In the next illustration, the Seller in the input Part is mapped to a line item called Buyer in the output Part.

6MAPAction106

The next illustration shows the resulting XML Document Panels.

7NewMapDOMresult

You can create any output document structure by mapping an input document element to an output XPath. Make sure you map to a fully-qualified document name.

NOTE:   In reality, Output and Temp Message Parts are always built dynamically. The presence of a sample document is merely a productivity aid to help you define actions.

If the Output Part you created can be used for building other components, you may want to save it as an XML document and use it as a sample inside an XML Template. See Saving a DOM as an XML Document for more information.

 
Top of page

Using Temp and Fault Messages with a Component

In addition to creating Input and Output Message Parts, you can also create Temporary and Fault Message Parts. Temp Parts are used as work areas for performing complex manipulations of between Input and Output Parts. Within a Temp document pane, you can add elements from any of the Input Parts by using any of the five mapping methods. See About the Action Model Pane.

Fault Documents allow you to pass information back to clients when a fault condition occurs in a component or service. In Composer, a Fault is, essentially, an in-memory XML document or Message Part, defined along with a component, just like Input, Output and Temp Parts. Fault Message Parts are used to store information received when a Fault or Error occurs in your service or component. It is a good programming practice to anticipate places in your program where errors may occur and surround them with Try/On Fault and Throw Fault actions. (See "The Throw Fault Action" on page 169 for an example demonstrating the use Fault documents in fault-related actions.)

 
Top of section

Creating a Temporary Message Part

The Temp Part differs from the Input and Output Parts in the directionality of actions allowed. The Temp Part can be both a source and a target of mapping actions, whereas the Input Parts are only sources and the Output Part is only a target. You can add more than one temporary Part (you are only limited by memory), and you can delete them whenever you wish. Also, you can assign your own name to temporary Parts by typing over the Temp label. Temporary Message Parts can either be defined during the creation of a component (see "To create an XML Map component:" on page 103), or they can be added to an existing component.

Procedure To add a temporary Message Part to an existing component:

  1. From the File menu, choose Properties. The Properties dialog appears.

    6addtempdom01

  2. Click on the Messages tab.

  3. Click on the Temp Documents tab.

  4. Click the Add button at the far right. Selections for Part, Template Category and Template Name become available.

  5. Enter an Part (your own label) for the temporary message part.

  6. Select an XML Category from the Template Category dropdown menu.

  7. Select an XML Template from the Template Name dropdown menu.

  8. Click OK.

  9. Open the component. By default, the Component Editor will probably only show the Input and Output parts. To make the Temp document visible, go to the View menu and select Show/Hide to add the Temp Part you just created.

    NOTE:   Alternatively, you can click with the RMB in the Component Editor and select Add to Display, then pick the Temp document from the list.

The XML Map Component Editor displays a Temp message pane, as shown in the next illustration.

6addtempdom03

NOTE:   You can also create a document object dynamically without using a template, as described in Creating an Output Document without Using a Template.

 
Top of section

Creating a Fault Message Part

The _SystemFault Document

You can define the XML yourself for your Fault document, using your favorite editor, or you can use the default one provided by Composer, which is called _SystemFault. The XML information contained in _SystemFault also gets written to a global object called ERROR. The structure of the _SystemFault document is shown below:

8systemfault

Beneath the FaultInfo root are the following elements:

NOTE:   By default, the Fault document will not be visible in the Component Editor. To View it, click with your RMB, select Add to Display and choose _SystemFault.

 
Top of section

Creating a Custom Fault Document

The procedure for adding Fault Message Parts to your component is very similar to the procedure for adding Input, Output and Temp Parts. You begin by using your favorite editor to create an XML document that will be used to hold fault information. You can create as many Fault Message Parts as you need (you are limited only by memory) and Fault documents can have any structure that makes sense to your application.

You might want to use a custom Fault Part along with the _SystemFault document. For example, you could use the DateTime, Component and Message elements from _SystemFault to populate your own Fault document which woul also contain information about the service itself, a log message indicating the last action that was sucessfully executed and some information from the Input document that might have been missed due to the application halting before completion. Below is an example depicting a custom Fault message.

6CustomFaultUsage

Once you've decided what Faults you need to capture and created the XML structures to support them, the Parts can either be defined during the creation of a component, or added to an existing component.

Procedure To add a Fault Part to an existing component:

  1. From the File menu, choose Properties. The Properties dialog appears.

  2. Click on the Messages tab.

  3. Click on the Fault Documents tab.

    6FaultPart

  4. Click the Add button at the far right. Selections for Part, Template Category and Template Name become available.

    NOTE:   If you do not specify a Fault Part, error information will go into the basic fault document, called _SystemFault.

  5. Enter a Part (your own label) for the fault message part.

  6. Select an XML Category from the Template Category dropdown menu.

  7. Select an XML Template from the Template Name dropdown menu.

  8. Repeat as necessary for additional Fault documents.

  9. Click OK.

  10. Open the component. By default, the Component Editor will probably only show the Input and Output parts. To make the Fault Part visible, go to the View menu and select Show/Hide to add the Fault Part you just created.

    NOTE:   Alternatively, you can click with the RMB in the Component Editor and select Add to Display, then pick the Fault document from the list.

 
Top of page

Reloading an XML Document

If you have made changes to the document structures through mapping, and wish to return the Message Parts to their original state, you can reload the XML documents. When you reload the XML documents, all Parts, including Temp and Fault (if these were created) are returned to the state defined by the input and output XML documents. Keep in mind, however, the Map actions in the Action Model pane remain.Thus, if you were to execute the component, all Map actions will run.

The illustration below shows a component that contains several Map actions that are reflected in the Input, Output, and Temp Parts.

6reload02

Notice the detail in the XML and the Map actions in the Action Model pane. The next illustration shows the same screen after the XML documents have been reloaded.

6reload01

The documents are back to their original state but the Action Model pane remains the same. Reloading XML documents is accomplished by selecting Reload XML Documents from the Component menu.

 
Top of page

Loading a Sample Document

You can load different sample documents into any of the DOMs and use the new DOM structures for mapping elements or testing the Action Model. Loading a different sample document from your template allows you to test if your Action Model can handle all cases of XML documents your component might receive at runtime.

When you load an XML sample, the DOM changes, but the Action Model remains unchanged. When you are finished testing with the sample XML document, you can reload the original XML document(s) by repeating the Load XML Sample procedure.

Procedure To load a sample document:

  1. From the File menu, select Load XML Sample. Alternatively, click with the RMB in the XML Editor Panel and select Load XML Sample from the context menu. The Load XML File dialog appears.

    6loadsample01

  2. Select appropriate message Part from the Part dropdown box where you want the new sample document loaded.

  3. If you want to load a sample document that is not included in the original XML template, click File Name and type the name of the file. Alternatively, you can click Browse and find the file on your computer or network. You may also read in a file from a URL by explicitly preceding your filename with "http://," "https://" or "ftp."

  4. If you want to load an XML file that is included in the original XML template, click Sample and select the XML document.

  5. Check Default if you want to make the selected sample the default XML document for the selected Part in this component only. (This does not apply to the file name option).

  6. Click OK.

 
Top of page

Adding a Watch Variable

During the execution of your component, it can be very useful to examine the value of certain variables as a debugging aid. For this purpose, Composer offers a Watch List, and the ability to create Watch variables to add to the list.

You can identify the following objects as Watch variables:

Procedure To add an item to the Watch Variable List

  1. From the Component Menu, select Add Watch.

  2. The Add Watch Dialog displays, giving you access to all the Variables, ECMAScript Functions and Methods and Operators associated with your project.

    6AddWatch

  3. Doubleclick on the item you wish to add to the Watch list and click OK.

  4. During the execution of your component, click on the Watch tab in the Output pane to view the status of the items in your Watch List.

    6WatchList

The use of a Watch List, including examples of how this could be used as a debugging aid, are discussed in greater detail in Chapter 12.

 
Top of page

Saving Your Component

Save your component often to make sure your work is not lost due to hardware or software failures. You can also save the component with a different name, making a backup copy. When you save it with another name, you can also change the XML properties, including the input and output XML templates.

Procedure To save the component with a new name:

  1. From the File menu, select Save As.

  2. In the Name field, type a new name.

  3. To change input and output XML documents, click the XML Property Info tab.

  4. Change or add input XML documents.

  5. Change the output XML document.

  6. Click OK.

NOTE:   If you have more than one component open at a time, clicking on File>Save All (or pressing Ctrl-Shift-A) will save all the open components at once. Similarly, File>Close All (Ctrl-Shift-F4) will save all components at once.

 
Top of page

Saving a DOM as an XML Document

You can also save any DOM as an XML document. This creates (or overwrites) an XML document that contains the structure and data of the DOM. The following illustration shows an Output Part and the resulting XML document.

Procedure To save an in-memory DOM to an XML file:

  1. From the File menu, select Save XML As. The Save XML As dialog box appears.

    6outputxml02

  2. Use the pulldown menu under Part to select the source DOM that you want to save to disk. In the above example, Output is selected.

  3. Check the Save as File radio button.

  4. Type a path and name for the XML document, or click Browse and select a path.

    NOTE:   If you select an existing XML document, it will be overwritten with the source DOM's structure and data.

  5. Click OK.

 
Top of page

Saving an XML File as a Template

Any DOM that's visible in the component editor can be saved as an XML Template directly (rather than first saving the DOM to a file, then importing it into a template). The target Template does not have to exist already; you can create one on-the-fly.

Procedure To save a DOM to an XML Template:

  1. From the File menu, select Save XML As. The Save XML As dialog box appears (as shown above).

  2. Use the pulldown menu under XML Document to select the source DOM that you want to save as a template.

  3. Check the Save as Template radio button.

  4. If you are creating a template on-the-fly, enter a name for the Category (or else pick an existing category from the pulldown menu provided).

  5. If you are creating a template on-the-fly, enter a name under Template Name (or else pick an existing XML Template name from the pulldown menu).

  6. Enter a Sample Name for this XML document. (This will be the name of the file on disk. The file will be saved under \xmlcategories\[CategoryName]\imports in your project directory.)

  7. Click OK. You will see the new XML Template appear in the Instance Pane of Composer's nav frame.

During on-the-fly creation of an XML Template using the above technique, you will not be prompted for any additional information (such as schema name or XSL stylesheet) to associate with the new template. If you want to inspect or edit the validation, stylesheet, or other properties of the new template, follow the procedure outlined below.

 
Top of page

Inspecting and/or Editing XML Template Properties

At any after an XML Template has been created, you can inspect or change its properties. See"Editing an XML Template" on page 94.

 
Top of page

Avoiding Out-of-Memory Problems

When you are working with large DOMs, it is advised that at design time, to avoid memory errors, you add the following line to the xconfig.xml file. See the sample xconfig file excerpt below.

Line to add (or edit): <VM_PARAMS>-Xms64m-Xmx128m</VM_PARAMS>

To adjust available memory for deployed services (in the runtime environment), you will have to alter the VM command-line options for the app server's VM. Consult your app server documentation for information on how to do this.

You can avoid many out-of-memory problems (at runtime as well as design time) by appropriate use of Performance Filters as described in the next section.

 
Top of page

Using Performance Filters

The Define Performance Filter command (under the Component menu on Composer's main menubar) offers the potential for greatly improved performance when processing large incoming documents. It also offers significant benefits in terms of memory conservation, since a filtered document can require much less memory at runtime than an unfiltered document.

Performance filters work by stripping superfluous document elements (and attributes) from incoming XML documents. You specify which elements to ignore; Composer does the rest. In essence, the input document is "rewritten" on the fly in much-streamlined form, eliminating parts of the XML that are not necessary for your service. This results in a smaller in-memory DOM.

Document filtering is useful because it is very common for a service to operate on only a few XPath locations in a given type of document. For example, one service might operate on the "Customer Info" nodes in an order form; a different service might operate on the "Product Request Detail" nodes of the same order form; and so on. It makes sense for each service to see and use only the portions of the document that apply to that service.

Procedure To create a Performance Filter

  1. Open a Service xObject, if one is not already open.

    NOTE:   Performance filters cannot be defined on Components. They can be defined on Service xObjects only.

  2. Under the Component menu on Composer's main menubar, select Define Performance Filter. A dialog appears.

    8PerformanceFilter

    Note that the document shown in tree-view form in this dialog is the Input document for the service. (It is not possible to view other documents in this dialog.)

  3. Check the checkbox(es) next to the nodes you want to keep in the document. Unchecked nodes will be stripped off (discarded) so that the parsed DOM does not contain the elements in question. (See additional discussion below.)

  4. Click OK to dismiss the dialog.

In the preceding illustration, the incoming document, with root node DoctorResp, will have a /physician node with a /patients node under it at runtime, and the /patients element, in turn, will have a PatientData element under it. Likewise, the latter will have child nodes LastName and FirstName. But since Physician is not checked, the incoming document will not have anything under the XPath:

  DoctorResp/physician/patients/PatientData/Physician

NOTE:   At design time, you will initially, upon opening a service, see the complete (non-filtered) Input document, with all its nodes present in tree view, even if you have defined a Performance Filter. But when you begin stepping through the action model in animation mode, the document tree view will update to show the reduced (filtered) runtime structure of the document.

 
Top of page

Viewing Component Properties

You can inspect (and in some cases edit) various properties of a component at any time.

Procedure To view or change component properties:

  1. Select Properties from Composer's File menu. The Properties Dialog will appear. Note that the dialog has three tabs:

    6properties

  2. To view or edit descriptive commentary for this component, click the Headers tab and enter the desired information.

  3. To view or change XML template choices, click the Messages tab. You can add or remove template documents and/or template categories as need be.

  4. If your component uses special Connection Resources, click the Connections tab to view Connection Resource info for this component. (Not applicable to ordinary XML Map components.)

  5. Click OK to dismiss the dialog.

  6. Save your component.

 
Top of page

Printing a Component

You can print the contents of a component. The printout contains:

Procedure To print a component:

  1. From the File menu, select Print.

  2. Select a printer.

  3. Click OK.

 
Top of page

Designing, Testing, and Running a Component

The following table shows how sample documents are used when designing, testing, and running a component.

DOM


While designing in Composer

While using Animation Tools in Composer

While executing in Server

Input

Samples can be loaded and used as design time aids for building actions and test data.

The default sample document is loaded and used to simulate a runtime Input Part.

XML data is passed in by another component, a service, or a Service Trigger.

Temp(n)

Samples can be loaded and used as design time aids for building actions and test data.

The sample document is not loaded. The Part is built by the Action Model.

The Part is built by the Action Model

Output

Samples can be loaded and used as design time aids for building actions.

The sample document is not loaded. The Part is built by the Action Model.

The Part is built by the Action Model

Fault

Samples can be loaded and used as design time aids for building actions and test data.

The sample documents is not loaded. The Part is built by the Action Model.

The Part is built by the Action Model



Copyright © 2004 Novell, Inc. All rights reserved. Copyright © 1997, 1998, 1999, 2000, 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.  more ...