on 05-06-2008 10:25 PM
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
Use relativ path after for-each:
<xsl:value-of select="concat(First_Name,Last_Name)"/>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
Thanks for the help...points rewarded.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.