sivakumar kala
sivakumar kala

Reputation: 27

Xslt mapping for multiple values to one

i have source XML as like below

<Input>    
<email-addresses>
    <type>work</type>
    <value>[email protected]</value>
    </email-addresses>
    <email-addresses>
    <type>personal</type>
    <value>[email protected]</value>
    </email-addresses>
</Input>

Output should be like below

<output>
<emailwork>[email protected]</emailwork>
<emailper>[email protected]</emailper>
</output>

I am using below xslt mapping in my code to get the above output

 <output>
<xsl:if test "Input/email-address/type='work'">
<emailwork>
<xsl:value of select= "Input/email-address/value">
</emailwork>

</xsl:if>
<xsl:if test "Input/email-address/type='personal'">
<emailper>
<xsl:value of select= "Input/email-address/value">
</emailper>

</xsl:if>
 </output>

but it always returns the first emailaddress which appears in the payload.

Kindly help

Upvotes: 0

Views: 218

Answers (1)

Manisha Nagpal
Manisha Nagpal

Reputation: 173

You need to iterate through your payload, so that xslt will go through all the records. Try adding for-each loop to your xslt.

Upvotes: 0

Related Questions