none
Mapping parent and it's child records to the same recurring output RRS feed

  • Question

  • Hello!

    I am currently working on a large transformation that needs to map a source message with multiple transactions of different types to the same recurring record type in the output message. The problem is that the source message includes child records of the transactions that also needs to be mapped to the same output record type.

    Here's a simplified example to illustrate the problem:

    Input message:

    <root>
    	<transaction 1>
    		<values 1>
    			<v 1>
    		</values 1>
    		<child 1>
    			<childvalue 1>
    		</child 1>
    	</transaction 1>
    	
    	<transaction 2>
    		<values 2>
    			<v 2>
    		</values 2>
    		<child 2>
    			<childvalue 2>
    		</child 2>
    	</transaction 2>
    	
    	<transaction 3>
    		<values 3>
    			<v 3>
    		</values 3>
    	</transaction 3>
    </root>

    I want this example, with three transactions and two child records to map to 5 recurring records in the output schema. See example below:

    Output:

    <root>
    	<line 1>
    		<v 1>
    	</line 1>
    	
    	<line 2>
    		<childvalue 1>
    	</line 2>
    	
    	<line 3>
    		<v 2>
    	</line 3>
    	
    	<line 4>
    		<childvalue 2>
    	</line 4>
    	
    	<line 5>
    		<v 3>
    	</line 5>
    </root>

    When using looping functoids the desired output is not returned. Nested loops seem to map to the same output lines. For example the input above would give an aggregated version of <line 1> where the values are <v 1childvalue 1>, the child record values get added to the parent node output. I have also tried the Table Looping functoid on the child records to no avail (the table loop seems to not execute at all within a looping functoids scope).

    Thank you in advance!


    • Edited by Knackebro Wednesday, April 22, 2015 11:48 AM
    Wednesday, April 22, 2015 11:27 AM

Answers

  • Hi,

    You can make a use of XSL scripting. Drag a scripting functoid and put below XSL code under Inline XSLT window:

    <xsl:variable name="unique-Values" select="//Transaction[not(Values=preceding-sibling::Transaction/Values)]/Values" />

    <xsl:for-each select="$unique-Values">

          <xsl:variable name="current-Values" select="current()" />

          <xsl:if test="string-length($current-Values) > 0">

                <root>

                      <line>

                            <xsl:value-of select="$current-Values" />

                      </line>

                      <line>

                            <xsl:value-of select="//Transaction[Values=$current-Values]/Child" />

                      </line>                

    </root>          

          </xsl:if>  

    </xsl:for-each>

    Here I have assumed that you have created your schemas as per below structure: 

    Source Schema:
    root
    -----Transaction
    ----------Values
    ----------Child

    and destination schema :

    root
    -----line

    Hope this helps.

    Thanks

    • Marked as answer by Angie Xu Wednesday, April 29, 2015 1:30 AM
    Wednesday, April 22, 2015 1:26 PM

All replies

  • Hi,

    You can make a use of XSL scripting. Drag a scripting functoid and put below XSL code under Inline XSLT window:

    <xsl:variable name="unique-Values" select="//Transaction[not(Values=preceding-sibling::Transaction/Values)]/Values" />

    <xsl:for-each select="$unique-Values">

          <xsl:variable name="current-Values" select="current()" />

          <xsl:if test="string-length($current-Values) > 0">

                <root>

                      <line>

                            <xsl:value-of select="$current-Values" />

                      </line>

                      <line>

                            <xsl:value-of select="//Transaction[Values=$current-Values]/Child" />

                      </line>                

    </root>          

          </xsl:if>  

    </xsl:for-each>

    Here I have assumed that you have created your schemas as per below structure: 

    Source Schema:
    root
    -----Transaction
    ----------Values
    ----------Child

    and destination schema :

    root
    -----line

    Hope this helps.

    Thanks

    • Marked as answer by Angie Xu Wednesday, April 29, 2015 1:30 AM
    Wednesday, April 22, 2015 1:26 PM
  • Thank you, I'll try this solution out!
    Thursday, April 23, 2015 6:22 AM