Tutorial & Interface
Transformation Using Transaction Attributes
This Interface demonstrates how to utilize Transaction Attributes when transforming documents in the eiConsole, in this example using the filename of the incoming file. Transaction attribute-based transformation may be used when: Data has been stored to a transaction attribute that needs to be utilized in the transformation Data needs to be written from a transformation into a transaction attribute.
The tutorial demonstrates how to utilize transaction attributes in data transformation; this is useful for getting meta information from Listeners, such as when you need to know the filename of a file that was picked up. It can also be used to store information that cannot be stored in the current transaction data or to handle things such as images.
How to Use This Example
Download the INTERFACE file and save it to your local disk.
Open the eiConsole, click on the File drop-down menu and select Import Working Directory/Route/Format. Highlight the name of the file to import and press the Import Selected button. The imported Interface will appear in your current Working Directory.
Next, follow the tutorial and walk through it step-by-step. You may check your work against the provided Route (Sample Data).
Double-click the Interface to Open the Route
This Interface has three functioning pieces; the Listener, the listener transformation, and the transport.
The Listener polls a directory set by a configuration value stored in the environment properties file (included with this Interface) every five seconds. The sample files intended to be used with this Interface are provided alongside this instructional guide; they are Sample2.xml and Sample3.xml.
The transformation is relatively simple, performing a near one-to-one mapping, except for a single field; FileName.
To write a transaction attribute, navigate to the “Custom” tab in your Data Mapper palette, and select “Attribute” – “Get Transaction Attribute”. After dragging and dropping it to the desired Node, it automatically generates the XSLT necessary to read data from a transaction attribute in your XSLT.
It will ask you to provide an attribute name.
In our case, the Filename node is already mapped.
You can test this directly in your XSLT; go to the Testing tab, and on the testing toolbar is an icon of a green pencil and notepad. Clicking this will bring up an attribute editor; this data will be given directly to the transformer when this test is executed. Enter attribute name com.pilotfish.FileName and the value TestName, and hit the Enter.
The new element will appear in the results window:
We use the original file name and extension for the output of this transport, information produced by the directory listener as a transaction attribute; note that, because we have three incoming Transactions which will share this information, the output file name will, subsequent to the first file output, have a number appended to the end.
Run the Testing Mode.
Click on the Execute Test and copy the Sample2.xml file to the polling directory.
Since our sample file is Sample2.xml, the new Node in the newly created file will contain its name – Sample2.
This concludes this demonstration of Using Attributes in Transformations.