This topic provides guidance for writing your message processing node to ensure that it functions correctly. It explains how you can use your message processing node to navigate a message.
A syntax element with connections to other elements
Syntax element tree
The element A is the root element of the tree. It has no parent because it is the root. It has a first child of element B. Because A has no other children, element B is also the last child of A.
Element B has three children: elements C, D, and E. Element C is the first child of B; element E is the last child of B.
Element C has two siblings: elements D and E. The next sibling of element C is element D. The next sibling of element D is element E. The previous sibling of element E is element D. The previous sibling of element D is element C.
First generation of syntax elements in a typical message
These elements at the first generation are often referred to as "folders", in which syntax elements that represent message headers and message content data are stored. In this example, the first child of root is the Properties folder. The next sibling of Properties is the folder for the MQMD of the incoming WebSphere MQ messages. The next sibling is the folder for the MQRFH2 header. Finally, there is the folder that represents the message content, which (in this example) is an XML message.
The figure above includes an MQMD and an MQRFH2 header. All messages received by an MQmessage processing node include an MQMD header, there are a number of other headers than can also be included.
<Business>
<Product type='messaging'></Product>
<Company>
<Title>IBM</Title>
<Location>Hursley</Location>
<Department>WebSphere MQ</Department>
</Company>
</Business>
You can use node utility functions and methods (or the similar parser utility functions) to navigate through a message. Taking the XML message shown above, you need to call cniRootElement first, with the message received by the node as input to this function. In Java you need to call getRootElement on the incoming MbMessage. This returns an MbElement that represents the root of the element. The root element should not be modified by a user-defined node.
The figure above shows that the last child of the root element is the folder containing the XML parse tree. You can navigate to this folder by calling cniLastChild (with the output of the previous call as input to this function) in a C node, or by calling the method getLastChild on the root element, in a Java node.
There is one element only (<Business>) at the top level of the message, so calling cniFirstChild (in C) or getFirstChild (in Java) moves to this point in the tree. You can use cniElementType or getElementType to get its type (which is name), followed by cniElementName or getName to return the name itself (Business).
<Business> has two children, <Product> and <Company>, so you can use cniFirstChild or getFirstChild followed by cniNextSibling or getNextSiblingto navigate to them in turn.
<Product> has an attribute (type='messaging'), which is a child element. Use cniFirstChild or getFirstChildagain to navigate to this element, and cniElementType or getType to return its type (which is name-value). Use cniElementName or getName as before to get the name. To get the value, call cniElementValueType to return the type, followed by the appropriate function in the cniElementValue group. In this example it will be cniElementCharacterValue. In Java use the method getValue, which will return a Java object representing the element value.
<Company> has three children, each one having a child that is a value element (IBM, Hursley, and WebSphere MQ). You can use the functions already described to navigate to them and access their values.
Other functions are available to copy the element tree (or part of it). The copy can then be modified by adding or removing elements, and changing their names and values, to create an output message.
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
as01395_ |