Reputation: 167
How to create mapping when on input we will have two schema's and on output will be one schema and some condition across mapping ?
Input is an inline schema and contains Invoices and Customers schema's. Both of them have CustomerNumber and DepartmentCode exist only on Invoices schema.
[CONDITION]
Mapp only this DepartmentCode if CustomerNumber is same on both Invoice and Customer data (line).
If Invoice.CustomerNumber == Customer.CustomerNumber then map Invoice.DepartmentCode.
I've tried to use loop, equal and value mapping functoid's but without expected results, second think I've tried to use "Inline xslt call template" but I've got an error on processing.
[Code of XSLT functoid]
<xsl:template name="GetDepartmenCodeByCustomerNumber">
<xsl:param name="CustomerNumber" />
<xsl:if test="$CustomerNumber != ''">
<xsl:element name="DepartmentCode">
<xsl:value-of select="//s1:Customer[s1:CustomerNumber=$CustomerNumber]/s1:DepartmentCode/text()" />
</xsl:element>
</xsl:if>
</xsl:template>
Example:
Input
<ROOT>
<Invoices>
<Invoice>
<CustomerNumber>123</CustomerNumber>
<DepartmentCode>321</DepartmentCode>
</Invoice>
</Invoices>
<Customers>
<Customer>
<CustomerNumber>123</CustomerNumber>
</Customer>
<Customer>
<CustomerNumber>222</CustomerNumber>
</Customer>
</Customers>
</ROOT>
Expect
<Document>
<CustomerNumber>123</CustomerNumber>
<DepartmentCode>321</DepartmentCode>
</Document>
For example I need to equal CustomerNumber from Invoice and Customer segment.
Upvotes: 1
Views: 1367
Reputation: 307
You need to make a "double" loop because I guess you have multiple Invoices and Customers. A xslt is a good solution, but if you only need these two fields you can use a map like this:
Loop the invoice to a Table Looping adding its two children and a Cumulative Concatenate of all the CNumb (adding some special character to allow the search later, for example @CNumb@) from Customers. Use the Table Extractors to get all the values and check if each CNumb from Invoices is in the concatenation or not, sending the result of the comparison to the loop element in destination schema.
Upvotes: 2