Customer Portal

Refering fields from the parent node in nested child nodes

Comments 3

  • Avatar
    avackova
    0
    Comment actions Permalink
    Hello TAV,
    your mapping should look likefollows:
    <Mappings>
    <Mapping element="orders">
    <Mapping element="order" outPort="0">
    <Mapping element="item" outPort="1" generatedKey="oid" parentKey="orderid"/>
    </Mapping>
    </Mapping>
    </Mappings>


    Field oid describes order id and belongs to port 1 metadata. Field orderid belongs to port 0 metadata and is read from the input file.
  • Avatar
    tav
    0
    Comment actions Permalink
    Hi,

    How do I refer fields from a child node in another child node? For example :-


    <order>
    <orderdata>
    <orderid>11ORD</orderid>
    </orderdata>
    <items>
    <item>
    <itemid>ITMID</itemid>
    <quantity>20</quantity>
    </item>
    </items>
    </order>


    If I am writing order data records and item records to 2 different CSV files how can I refer to the order id so I can write it as a field in the item records CSV file.
  • Avatar
    avackova
    0
    Comment actions Permalink
    Try following mapping:
    <Mappings>
    <Mapping element="order" outPort="0" >
    <Mapping element="item" outPort="1" generatedKey="oid" parentKey="orderid"/>
    </Mapping>
    </Mappings>

    For more complicated structure you will have to add artificial key field and fulfil it with sequence value - see sequenceField in XMExtract. Then you can use MergeJoin to join data due to this special field.

Please sign in to leave a comment.