Storing data in an XML file can provide an acceptable format for importing that data into another system. Another use for an XML target is to create messages in a Message Queue to be retrieved by another system. See
Capturing Processed XML Messages.
Using an XML file as a target requires some preliminary setup before loading data into that file. The process to setup and use an XML file as a target is as follows:
- Create an XDR file as a schema
- Create the XML Target Connection in the DTS
- Map the fields in the DTS file and run it to populate the XML file
Creating An XDR File
To use XML as a target, an XDR or XSD file is required. The easiest way to generate an XDR file is through the Query Publisher in the TIBCO Scribe® Insight Console. In this example the only reason for creating a query publisher is to generate the XDR file.
Create A Query Publisher
- In the TIBCO Scribe® Insight Console, navigate to Integration Server > Publishers/Bridges.
- Click Add at the top of the screen.
- Step 1 Publisher/Bridge Type: In the Publisher/Bridge type drop-down select Query Publisher.
- Give the Publisher a name.
- Step 2 Source Connection: Click Source Connect and select a source connection. It can be an Adapter or SQL Server. In this example an Account table in SQL Server is used. Connect to SQL Server using ODBC or a Native SQL connection.
The Source connection used should mirror the data that you want to place in the XML file or in the Message Queue. For example, if you want to move Contacts or Accounts into an XML file, make sure that is the entity you are using in the Source Connection and that it has the fields you need.
- Step 3 Configure Source: Click Source Configure and select the entity, such as Account.
- Step 4 Publisher/Bridge Properties: Enter a name in the Root Element Name field, such as Account.
- Enter a message label for queue, such as SQL_Accounts.
- Click the Grouping button and enter Group information. Refer to the Group The Data section below for steps.
- Step 5 Activation: Set Status to Paused. You don’t need to run this publisher.
- Click Finish to save.
Group The Data
To create a single XML file containing multiple Account records, the data must be grouped. Grouping is required to generate the proper XML and XDR files. Without grouping a single record is written to the output file.
- Open your new Publisher and click on Step 4 Publisher/Bridge Properties.
- Click the Grouping button.
- Right-click on the Group Name, such as <Accounts>, and select Add Repeating Group.
- Right-click on <RepeatingElement> and use the rename option to give the label a meaningful name.
- Click on the top element/node to view the fields.
- Select the appropriate fields and drag them to the newly created repeating group.
- In this case, there is not a parent/child relationship so all fields are selected. In the case of a Sales Header/Sales Detail scenario, the sales detail line records would be moved to the repeating group and the sales header fields would remain where they are in the top element.
Generate The XDR File
The XDR file is crucial to defining the XML file to be created. Once grouping has been defined click the
Generate XDR button to create an XDR file used by the DTS. If the XML file you generate later is not correct, return to the Grouping, modify it, and regenerate the XDR file.
Create The XML Target Connection In The DTS
- Click the Connections button on the TIBCO Scribe® Insight Workbench Toolbar.
- In the Connection Manager, click New.
- Select XML and click OK.
- On the Connection Wizard click Next, then Use as a Target.
- Specify the File connection method, the location of the XDR/XSD file, and the name of the output file.
- On the Workbench click Configure Source.
- Select a Source database and select the Accounts entity.
- Click OK to save it.
- On the Workbench click Configure Steps.
- Click Add and select the XML Target Connection.
- Under XML Objects select Accounts.
- Under Operation select Insert and click Add Insert Step.
Note: The XML Component Target Settings screen displays the first time you add an Insert Step. After that it is accessed through the Connections Window by editing the XML Connection, and selecting DTS Connection Settings > Adapter Settings for the XML connection.
- On the XML Component Target Settings screen select the Accounts label in the tree that is not the top level, but the level that is the equivalent of the Repeating Group.
- Click the Repeating Node checkbox.
- In the Node Break box set the AccountID as the Node Break.
- Click OK to save.
Map Fields And Run The DTS
Map the appropriate fields in the DTS and run it.
Verify that the XML file is correct.
Note On Repeating Nodes It is important to understand how repeating nodes work in TIBCO Scribe® Insight when using XML files. A repeating node is used to specify which data should be grouped together within the XML file. Typically this is used when multiple records exist in the same XML file. In the example below, the repeating node would be set on the Account node if there were more than one account record in the XML file.
TIBCO Scribe® Insight's XML adapter does not handle repeating sibling nodes (nodes at the same level), but can handle multiple repeating child nodes (parent/child relationships). Setting a Repeating Node on Node 1 and Node 2 on the following is fine.
Example 1
But the following is not:
- Top Level
- Node 1
- Node 2
- Node 3
- Node 4
Example 2
In this case there are several customers with multiple addresses and phone numbers. While you can specify Customer and Address as repeating nodes, you cannot also specify Phone Info as a repeating node, because Address and Phone Info are siblings. Customers --Customer ----Name ----Addresses --------Address ------------Street ------------City ------------State ------------Zip ----Phone Numbers --------Phone Info ------------Number ------------Type