cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping

Former Member
0 Kudos

I have a mapping question. I am trying to map the following structure: How do I achieve the creation of one node <Invoice_Main> if Invoice node exist in input.

<Vendor>

<Invoice></Invoice>

<Invoice></Invoice>

</Vendor>

to output structure

<Vendor>

<Invoice_Main>

<Invoice_Detl></Invoice_Detl>

<Invoice_Detl></Invoice_Detl>

</Invoice_Main>

</Vendor>

I check If Invoice Node exists and then use CreateIF to create Invoice_main Node.. This works fine for first record, but for the second record the creation of Invoice_detl node fails.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi SSG

Solution for your requirement using XSLT is very straightforward.

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>

<xsl:template match="/Vendor">

<Vendor>

<xsl:if test="count(Invoice) > 0">

<Invoice_Main>

<xsl:for-each select="Invoice">

<Invoice_Detl>

<xsl:value-of select="."/>

</Invoice_Detl>

</xsl:for-each>

</Invoice_Main>

</xsl:if>

</Vendor>

</xsl:template>

</xsl:stylesheet>

cheers

Sameer

Former Member
0 Kudos

Sameer thanx, appreciate your help.. Is it possible to do this via message mapping? If so do we need to do it through advanced functions?

Former Member
0 Kudos

If i have multiple occurance of Vendor with each vendor having one instance of Invoice, this works fine..My mapping fails while creating invoice_detl target for the second vendor instance (when the first vendor instance has two or more invoice records)..

Former Member
0 Kudos

Answers (0)