cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT mapping issue

Former Member
0 Kudos

Hi Experts,

I have a problem with 0 to unbounded segment ( record) in xslt mapping, it successfully working with single record. But my requirement like...0 to Unbounded. ( multiple records).

Can anybody help me on this issue asap.

Source xml:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_input xmlns:ns0="http://Ball.com/poc/xslt">

<Record>

<First_Name>raj</First_Name>

<Last_Name>kumar</Last_Name>

<Age>11</Age>

</Record>

<Record>

<First_Name>raj1</First_Name>

<Last_Name>kumar</Last_Name>

<Age>11</Age>

</Record>

</ns0:MT_input>

xslt mapping :

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" xmlns:p2="http://Ball.com/poc/xslt">

<xsl:template match="/">

<p2:MT_Output>

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

<Record>

<Name>

<xsl:value-of select="concat(p2:MT_input/Record/First_Name,p2:MT_input/Record/Last_Name)"/>

</Name>

<Age>

<xsl:value-of select="p2:MT_input/Record/Age"/>

</Age>

</Record>

</xsl:for-each>

</p2:MT_Output>

</xsl:template>

</xsl:transform>

Target xml:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_input xmlns:ns0="http://Ball.com/poc/xslt">

<Record>

<First_Name>raj</First_Name>

<Last_Name>kumar</Last_Name>

<Age>11</Age>

</Record>

<Record>

<First_Name>raj1</First_Name>

<Last_Name>kumar</Last_Name>

<Age>11</Age>

</Record>

</ns0:MT_input>

Edited by: esha nadh on May 6, 2008 11:50 PM

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Use relativ path after for-each:

<xsl:value-of select="concat(First_Name,Last_Name)"/>

Former Member
0 Kudos

Stefen,

Its not working...with that parameter.. Please find the changed code below;

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" xmlns:p2="http://Ball.com/poc/xslt">

<xsl:template match="/">

<p2:MT_Output>

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

<Record>

<Name>

<xsl:value-of select="concat(First_Name,Last_Name)"/>

</Name>

<Age>

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

</Age>

</Record>

</xsl:for-each>

</p2:MT_Output>

</xsl:template>

</xsl:transform>

stefan_grube
Active Contributor
0 Kudos

for-each has to be absolute path:

<xsl:for-each select="p2:MT_input/Record">

Edited by: Stefan Grube on May 7, 2008 12:55 AM

Edited by: Stefan Grube on May 7, 2008 1:20 AM

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks for the help...points rewarded.

Former Member
0 Kudos

Hi esha,

Just use this code, it will suit your requirment:

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" xmlns:p2="http://Ball.com/poc/xslt">
<xsl:template match="/">
<p2:MT_Output xmlns:ns0="http://Ball.com/poc/xslt"> 
<xsl:for-each select="ns0:MT_input/Record">
<Record>
<Name>
<xsl:value-of select="concat(First_Name,' ',Last_Name)"/>
</Name>
<Age>
<xsl:value-of select="Age"/>
</Age>
</Record>
</xsl:for-each>
</p2:MT_Output>
</xsl:template>
</xsl:transform>

you can also give a seperator(as you wish, here i have given a space in the code) between the first name and last name.

--Sankar Choudhury

aashish_sinha
Active Contributor
0 Kudos

Hi,

Use this web log for XSLT mapping

/people/aashish.sinha/blog/2008/01/21/xslt-mapping-for-multiple-segments-of-xml

Regards

Aashish Sinha

PS : reward points if helpful

sumesh_k2
Participant
0 Kudos

Hi Esha,

please find the working XSLT for your scenario.

<?xml version="1.0"?>

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

<xsl:template match="/">

<ns0:MT_input xmlns:ns0="http://Ball.com/poc/xslt">

<xsl:for-each select="ns0:MT_input/Record">

<Record>

<Name>

<xsl:value-of select="concat(First_Name,Last_Name)"/>

</Name>

<Age>

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

</Age>

</Record>

</xsl:for-each>

</ns0:MT_input>

</xsl:template>

</xsl:stylesheet>

Former Member
0 Kudos

Hi

Try with This code for 0 to Unbounded. ( multiple records)

-


<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://Ball.com/poc/xslt">
<xsl:template match="/">
<p2:MT_Output>
<xsl:for-each select="ns0:MT_input/Record">
<Record>
<Name>
<xsl:value-of select="concat(First_Name,Last_Name)"/>
</Name>
<Age>
<xsl:value-of select="Age"/>
</Age>
</Record>
</xsl:for-each>
<p2:MT_Output>
</xsl:template>
</xsl:stylesheet>

-


Let me Know Still if u have issue with XSLT mapping

**Reward points if helpful

Regards

Viswanadh Vadde