Hi All,
Before telling the requirement I would show you my source schema, Sample file and target schema so that you can easily understand the Scenario:
Source Schema:
In this Product node is Set max occur=Unbound
Sample Source File:
Target Schema:
In Target Schema Count max occur =Unbound.
Now my requirement is that I have to take the value of element Cost price from all repeated node from source and Add it and assign to Count in target schema and element name "CostPrice" should be assigned to CountName Attribute.
For Example Output would be like:
As you can see we have Cost price repeated three times in source file and values are 40,50,30 so addition will be 120. So we have assigned 120 to count and under attribute "countname" we assigned the name of element from where we received these values for this example that is "CostPrice".
The same thing we want to do with SellPrice, So my final output would look like:
Solution:
To achieve this target we would use Scripting functoid and under that we will select Inline XSLT Call Template.
The map will look like:
Under scripting Functoid we have selected Inline XSLT Call Tempelate like below.
Here is the XSLT code written Under the tempelate:
<xsl:template name="MyXsltConcatTemplate">
<xsl:variable name="var:v2" select="sum(/s0:Products/Product/Prices/CostPrice)" />
<xsl:variable name="var:v4" select="sum(/s0:Products/Product/Prices/SellPrice)" />
<Counts>
<Count>
<xsl:attribute name="countname">CostPrice</xsl:attribute>
<xsl:value-of select="$var:v2" />
</Count>
<Count>
<xsl:attribute name="countname">SellPrice</xsl:attribute>
<xsl:value-of select="$var:v4" />
</Count>
</Counts>
</xsl:template>
Thanks.
Anshu Kumar