Creating a Data Processor Transformation for an XML Source

Creating a Data Processor Transformation for an XML Source

Step 2. Configure the XMap

Step 2. Configure the XMap

Configure a Data Processor transformation XMap in the XMap editor. Create mapping statements by dragging nodes from the input schema to the output schema and define the statements in the mapping statement grid.
You want to map the client data as partner data. You want to compute how many transactions each client has performed and store this data.
  1. To open the XMap editor, click the XMap object.
    The XMap editor displays the input schema to the left and the output schema to the right, as in the following figure:
  2. To map the total number of transactions per customer from the input XML to the output XML, complete the following steps:
    1. Drag the mouse from the
      Transaction
      input schema node to the
      Transaction
      output schema node.
      Both schema nodes are repeating nodes, so the XMap editor creates a Repeating Group statement in the grid. Statements under the Repeating Group statement are iterated for each instance of input data.
      To find the total transactions for each customer, search for transactions for the same customer using the PartnerName element with the dp:input() function. Use the XPath editor to enter the following expression in the
      Output
      field:
      ns2:Transaction[ns2:Customer=dp:input()/ns1:PartnerName]
      To open the XPath editor, click the arrow to the right of the
      Output
      field. The XPath editor displays the schema to the left and the expression to the right, as in the following figure:
    2. To create a Router statement that finds buy and sell transaction data, in the
      Name
      column, right-click and select
      New
      Router
      . Name the statement
      transaction type
      .
      To ensure that the Router is part of the Repeating Group, right-click and select
      Demote
      .
    3. To create an Option statement that finds buy transaction data, in the
      Name
      column right click and select
      New
      Option
      .
      Use the XPath editor to enter the following expression in the
      Condition
      field:
      @type="B"
    4. To add the amount of each buy transaction that the transformation finds in the input to the total transaction amount in the output, drag the mouse from the
      Amount
      input schema node to the
      Total
      output schema node.
      The XMap editor creates a Map statement in the grid.
      To ensure that the transformation only adds a transaction input amount if it exists, use the XPath editor to enter the following expression in the
      Input
      field:
      if (exists(dp:output()/ns2:Total)) then
      . Then use the XPath editor to enter the following expression in the
      Output
      field:
      ns2:Total
    5. To create an Option statement that finds sell transaction data, in the
      Name
      column, right-click and select
      New
      Option
      .
      Use the XPath editor to enter the following expression in the
      Condition
      field:
      @type="S"
    6. To add a sell transaction to the total number of transactions in the output XML, drag the mouse from the
      Amount
      input schema node to the
      Total
      output schema node.
      The XMap editor creates a Map statement in the grid.
      Use the XPath editor to enter the following expression in the
      Input
      field:
      if (exists(dp:output()/ns2:Total)) then
      . Use the XPath editor to enter the following expression in the
      Output
      field:
      ns2:Total
    The following figure shows how the XMap links the transaction data from the XML input to the XML output:
  3. To map customer data from the XML input to the XML output, complete the following steps:
    1. Drag the mouse from the
      Partner
      input schema node to the
      Transaction
      output schema node.
      Both schema nodes are repeating nodes, so the XMap editor creates a Repeating Group statement in the grid. Statements under the Repeating Group statement are iterated for each instance of input data.
      Use the XPath editor to enter the following expression in the
      Output
      field:
      ns2:Transaction[ns2:Customer=dp:input()/ns1:Name]
    2. Drag the mouse from the
      Name
      input schema node to the
      Customer
      output schema node.
      The XMap editor creates a Map statement in the grid. This statement passes the name of the customer to the output XML.
    3. Drag the mouse from the
      Address
      input schema node to the
      Address
      output schema node.
      The XMap editor creates a Map statement in the grid.
      This statement passes the customer address to the output XML.
    4. Drag the mouse from the
      Phone
      input schema node to the
      Phone
      output schema node.
      The XMap editor creates a Map statement in the grid. This statement passes the customer phone number to the output XML.
    The following figure shows how the XMap links the customer data from the XML input to the XML output:

0 COMMENTS

We’d like to hear from you!