Sample formatter
Distribution provides a sample formatter class that can add custom attributes to a routing file.
If a route file schema is not defined, the sample formatter converts a HashMap that contains the custom
attribute definition into an XML string. For example,
<name-1>value-1</name-1>......<name-n>value-n</name-n>. Then, it
inserts the XML string in the correct place in the input routing file under the destRouting
element.
If an XSD file is configured to be used, a custom attribute name is assumed to have an equivalent element
name in the XSD. The element name from the XSD is where the custom attribute value is to be inserted into the
XML file. If a custom attribute does not have an equivalent XSD entry, its XML node is added to the
destRouting root node. XSD elements that do not have a corresponding custom attribute are
ignored.
The new routing file is returned to Distribution as a Java™ String.
The following sections contain some examples of using the formatter and then information about locating the sample formatter code.
Example 1
productSupplier =
IBM is used. The XSD for this example is defined as shown.
<xs:element name="productSupplier">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Product Supplier"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="productInfo">
<xs:complexType>
<xs:sequence>
<xs:element ref="productSupplier"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="destRouting">
<xs:complexType>
<xs:sequence>
<xs:element ref="icpcsRouting"/>
<xs:element ref="productInfo"/>
</xs:sequence>
</xs:complexType>
</xs:element><destinations>
<destRouting>
<icpcsRouting>
<outgoing>
<channelDefName>Channel name</channelDefName>
</outgoing>
</icpcsRouting>
<productInfo>
<productSupplier>IBM</productSupplier>
</productInfo>
</destRouting>
</destinations>Example 2
<xs:element name="destRouting">
<xs:complexType>
<xs:sequence>
<xs:element ref="icpcsRouting"/>
</xs:sequence>
</xs:complexType>
</xs:element><destinations>
<destRouting>
<icpcsRouting>
<outgoing>
<channelDefName>Channel name</channelDefName>
</outgoing>
</icpcsRouting>
<productSupplier>IBM</productSupplier>
</destRouting>
</destinations>The XML route file would look the same if an XSD was not specified with same formatter and custom attribute.
Example 3
<destinations>
<destRouting>
<icpcsRouting>
<outgoing>
<channelDefName>Channel name</channelDefName>
</outgoing>
</icpcsRouting>
</destRouting>
</destinations>No custom attributes are in the XML route file because the default formatter does not include custom attributes.
Sample formatter code
Distribution provides a sample formatter class,
com.ibm.paydir.utilities.rtefile.samples.PayDirRouteFileFormatterImpl, which is found in the
sdk_distribution/samples directory.
The sample formatter that is provided by Distribution can be used as-is or modified to add extra functions. If the sample formatter is modified, make sure to change the package and class name so Distribution uses the new formatter instead of the sample one.
RteServices that has
the following methods: createStr- Converts a HashMap into a string of names and values.insertXml- Inserts a string into an existing XML string. The XML string is searched for the tag that is specified and the new string is inserted after that tag.
The files for the software development kit (SDK) are provided in the FTM artifacts pod and must be downloaded from the pod. For more information about getting files from the artifacts container for your offering, see Getting the files from the artifacts container for your FTM offering.