WebSphere Message Brokers
File: ac17280_
Writer: Bill Oppenheimer

Task topic

This build: July 31, 2007 21:18:54

Manipulating paths and types in an XML message

When you refer to or set elements within an XML message body, you must use the correct correlation names, in ESQL field references, to address them . The following table lists the correlation names for all valid elements. For correlation names for attributes XmlDec, and DocTypeDecl, see Accessing attributes in XML messages, Accessing XmlDecl in an XML message, and Accessing DocTypeDecl in an XML message. For information about field references, see ESQL field references.

Syntax element Correlation name
CDataSection (XML.CDataSection)
Comment (XML.Comment)
Content (XML.Content) - (XML.pcdata) is also supported
Element (XML.Element) - (XML.tag) is also supported
EntityReferenceEnd (XML.EntityReferenceEnd)
EntityReferenceStart (XML.EntityReferenceStart)
ProcessingInstruction (XML.ProcessingInstruction)
WhiteSpace (XML.WhiteSpace)

When a type is not present in a path element, the type of the syntax element is not important. That is, a path element of name matches any syntax element with the name of name, regardless of the element type. In the same way that a path element can specify a name and not a type, a path element can specify a type and not a name. This type of path element matches any syntax element that has the specified type, regardless of name. The following is an example of this:

 FIELDNAME(InputBody.(XML.Element)[1])

This example returns the name of the first element in the body of the message. The following example of generic XML shows when it is necessary to use types in paths:

<tag1 attr1='abc'> 
  <attr1>123<attr1> 
</tag1>

The path InputBody.tag1.attr1 refers to the attribute called attr1, because attributes appear before nested elements in a syntax tree generated by an XML parser. To refer to the element called attr1 you must use a path:

InputBody.tag1.(XML.Element)attr1

It is always advisable to include types in these cases to be explicit about which syntax element is being referred to.

The following ESQL:

SET OutputRoot.XMLNS.Element1.(XML.Element)Attribute1 = '123';

is essentially shorthand for the following, fully-qualified path :

SET OutputRoot.XMLNS.(XML.Element)Element1.(XML.Element)Attribute1.
	(XML.Content) = '123';

Consider the following XML:

 <?xml version="1.0"?>
<!DOCTYPE Order SYSTEM "Order.dtd">
<Order>
   <ItemNo>1</ItemNo>
   <Quantity>2</Quantity>
</Order>

The path InputBody.Order refers to the (XML.DocTypeDecl) syntax element, because this appears before the XML Body in the syntax tree and has the same name. To refer to the element ItemNo you need to use a path InputBody.(XML.Element)Order.ItemNo. The following example demonstrates the same idea, using the following XML input message:

<doc><i1>100</i1></doc>

To assign 112233 to <i1>, you must use the following ESQL expression:

SET OutputRoot.XMLNS.(XML.Element)doc.I1=112233;
Related concepts
Message flows overview
ESQL overview
Message modeling
Related tasks
Designing a message flow
Defining message flow content
Managing ESQL files
Related reference
Compute node
Database node
Filter node
ESQL reference
FIELDNAME function
SET statement
ESQL field references
Notices | Trademarks | Downloads | Library | Support | Feedback

Copyright IBM Corporation 1999, 2007Copyright IBM Corporation 1999, 2007. All Rights Reserved.
This build: July 31, 2007 21:18:54

ac17280_ This topic's URL is: