Connecting Apama Applications to External Components > Using Standard Adapters > Using Adapter Plug-ins > The XML codec plug-in > Examples of conversions
Examples of conversions
Suppose that the value of the XMLField property is Test, and the value of the trimXMLText property is true. Consider the following XML:
<?xml version="1.0" encoding="UTF-8"?>
  <Message>
    <ElementA>
      Hello there
      <ElementB/>
      !
      <ElementC/>
      <![CDATA[Sample CDATA (with < and > comparison operators). ]]>
      <ElementB att1="X" att2="Y">
        <![CDATA[More CDATA in the same element.]]>
      </ElementB>
    </ElementA>
  </Message>
With sibling order suffixing, this XML maps to the following normalized event fields:
"Test.Message/"                                =
"Test.Message/ElementA#1/"                     =
"Test.Message/ElementA#1/text()#1"             = "Hello there"
"Test.Message/ElementA#1/ElementB#2/"          =
"Test.Message/ElementA#1/text()#3"             = "!"
"Test.Message/ElementA#1/ElementC#4/"          =
"Test.Message/ElementA#1/CDATA()#5"            =
"Sample CDATA (with < and > comparison operators). "
"Test.Message/ElementA#1/ElementB#6/"          =
"Test.Message/ElementA#1/ElementB#6/@att1"     = "X"
"Test.Message/ElementA#1/ElementB#6/@att2"     = "Y"
"Test.Message/ElementA#1/ElementB#6/CDATA()#1" =
"More CDATA in the same element."   
With twin order suffixing, the same XML maps to the following normalized event fields:
"Test.Message/"                             =
"Test.Message/ElementA/"                    =
"Test.Message/ElementA/text()"              = "Hello there"
"Test.Message/ElementA/ElementB/"           =
"Test.Message/ElementA/text()[2]"           = "!"
"Test.Message/ElementA/ElementC/"           =
"Test.Message/ElementA/CDATA()"             =
"Sample CDATA (with < and > comparison operators). "
"Test.Message/ElementA/ElementB[2]/"        =
"Test.Message/ElementA/ElementB[2]/@att1"   = "X"
"Test.Message/ElementA/ElementB[2]/@att2"   = "Y"
"Test.Message/ElementA/ElementB[2]/CDATA()" = "More CDATA in the same element."
To construct the XML above (assuming element ordering matters, but allowing for text() concatenation), the following name/value pairs are all that is required:
"Test.Message/ElementA#1/text()#1"             = "Hello there"
"Test.Message/ElementA#1/ElementB#2/"          =
"Test.Message/ElementA#1/text()#3"             = "!"
"Test.Message/ElementA#1/ElementC#4/"          =
"Test.Message/ElementA#1/CDATA()#5"            =
"Sample CDATA (with < and > comparison operators). "
"Test.Message/ElementA#1/ElementB#6/@att1"     = "X"
"Test.Message/ElementA#1/ElementB#6/@att2"     = "Y"
"Test.Message/ElementA#1/ElementB#6/CDATA()#1" = "More CDATA in the same element."
With both sibling order suffixing and twin order suffixing set to true, the XML codec generates two field/value pairs for each node. For example, the same XML used in the previous two examples maps to the following:
"Test.Message/"                                =
"Test.Message/ElementA/"                       =
"Test.Message/ElementA#1/"                     =
"Test.Message/ElementA/text()"                 = "Hello there"
"Test.Message/ElementA#1/text()#1"             = "Hello there"
"Test.Message/ElementA/ElementB/"              =
"Test.Message/ElementA#1/ElementB#2/"          =
"Test.Message/ElementA/text()[2]"              = "!"
"Test.Message/ElementA#1/text()#3"             = "!"
"Test.Message/ElementA/ElementC/"              =
"Test.Message/ElementA#1/ElementC#4/"          =
"Test.Message/ElementA/CDATA()"                =
"Sample CDATA (with < and > comparison operators). "
"Test.Message/ElementA#1/CDATA()#5"            =
"Sample CDATA (with < and > comparison operators). "
"Test.Message/ElementA/ElementB[2]/"           =
"Test.Message/ElementA#1/ElementB#6/"          =
"Test.Message/ElementA/ElementB[2]/@att1"      = "X"
"Test.Message/ElementA#1/ElementB#6/@att1"     = "X"
"Test.Message/ElementA/ElementB[2]/@att2"      = "Y"
"Test.Message/ElementA#1/ElementB#6/@att2"     = "Y"
"Test.Message/ElementA/ElementB[2]/CDATA()"    = "More CDATA in the same element."
"Test.Message/ElementA#1/ElementB#6/CDATA()#1" = "More CDATA in the same element."
Since the suffix properties are orthogonal, you can set both to true, and the XML codec generates normalized fields with each kind of suffix. This allows you to use the same instance of the XML codec for XML elements that need sibling suffixing and XML elements that need twin suffixing. While this impacts memory usage according to the amount of XML data being normalized, you can specify mapping rules to filter for the fields of interest.
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.