August 16, 2023

Configuring tXMLMap for transformation – Docs for ESB 6.x

Configuring tXMLMap for transformation

  1. Double-click the tXMLMap component to open its Map Editor.

    Use_Case_tXMLMap5.png

    Note that the input area is already filled with the default basic XML
    structure and the top table is the main input table.
  2. In the row1 input table, right-click the Customer node and from the contextual menu select
    Import From File. In the pop-up dialog box,
    browse to the XML source file to import therefrom the XML tree structure used by
    the data to be received by tXMLMap. In this
    scenario, the XML source file is Customer.xml, which is the
    input data to the tFileInputXML component
    labelled Customers.

    Note:

    You can also import an XML tree from an XSD file. When importing either an
    input or an output XML tree structure from an XSD file, you can choose an
    element as the root of your XML tree. For more information on importing an
    XML tree structure from an XSD file, see
    Talend Studio
    User Guide
    .

  3. In the imported XML tree, right-click the Customer node
    and from the contextual menu select As loop
    element
    to set it as the loop element.

    Use_Case_tXMLMap7.png

  4. On the lower part of this map editor, click the Schema
    editor
    tab to display the corresponding view. Then on the right
    side of this view, add one column Customer_States of
    Document type to the
    Customer schema table. The corresponding XML root is
    added automatically to the Customer output
    table on the top right side which represents the output flow.

    Use_Case_tXMLMap11.png

  5. In the Customer output table, right-click the Customer_States node and from the contextual menu select
    Import From File. In the pop-up dialog box,
    browse to the XML file from which the XML tree structure is imported. In this
    scenario, it is Customer_State.xml.

    Use_Case_tXMLMap9.png

  6. Right-click the customer node and from the contextual
    menu select As loop element to set it as the
    loop element.
  7. In the row1 input table, click the
    id node and drop it to the Expression column in the row of the @id node in the Customer
    output table.

    Use_Case_tXMLMapBasicMap.png

    Do the same to map CustomerName to
    CustomerName, CustomerAddress to
    CustomerAddress, and idState to
    idState from the input table to the output
    table.
    Note:

    In some circumstances, you may have to keep empty elements in your output XML tree. If
    so, you can use tXMLMap to manage them. For
    further information about how to manage empty elements using tXMLMap, see
    Talend Studio
    User Guide
    .

  8. On the top of the Customer output table,
    click the wrench icon and set the value of the All in
    one
    property to true to generate
    a single XML flow. For further information about the All
    in one
    feature, see
    Talend Studio User
    Guide
    .

    use_case-txmlmap_all_in_one.png

  9. Click OK to validate the changes and close
    the Map Editor.

    Note:

    If you close the Map Editor without having set the
    required loop elements as described earlier in this scenario, the root
    element will be automatically set as the loop element.


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x