on 03-17-2011 12:39 PM
Hi Team,
I have one requirements which I am explaining below:
Source structure should be:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Student xmlns:ns0="urn:bp:xi:hr:edm:test:100">
<Data>
<FName>
<LName>
<Marks> Here Data fiels is 0......Unbounded.
<Maths>
<Science>
</ns0:MT_Student>
and Target structure must be like below:
<MT_Student_Result>
<Data>
<Name> Here data field is 0......Unbounded.
<Marks>
<Total_Marks>
In the target structure Filed "Name" is obtained by concating "FName" and "LName" in the source structure
and the field "Total_Marks" is the sum of field "Maths" and "Science" in the source structure.
I have used XSLT mapping to obtain this.I have got the value of the "Name" field in the Target structure as required but I am not getting the value of the field "Total_Marks" in the target structure as required.Every time I am putting any value the result is comming as "NaN" as a value of the field "Total_Marks".Can you explain what is the issue?I am providing the code that I have done
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" xmlns:fo="urn:bp:xi:hr:edm:test:100" xmlns:ns0="urn:bp:xi:hr:edm:test:100">
<xsl:template match="/">
<MT_Student_Result>
<xsl:for-each select="ns0:MT_Student/Data">
<xsl:variable name="name" select="FName"/>
<xsl:variable name="surname" select="LName"/>
<Data>
<Name>
<xsl:value-of select="concat($name,'',$surname)"/>
</Name>
<Marks>
<Total_Marks>
<xsl:variable name="maths" select="ns0:MT_Student/Data/Marks/Maths"/>
<xsl:variable name="science" select="ns0:MT_Student/Data/Marks/Science"/>
<xsl:value-of select="($maths+$science)" />
</Total_Marks>
</Marks>
</Data>
</xsl:for-each>
</MT_Student_Result>
</xsl:template>
</xsl:transform>
Edited by: ATANU1 on Mar 17, 2011 1:40 PM
Hi,
Use this:
<xsl:variable name="maths" select="Marks/Maths"/>
<xsl:variable name="science" select="Marks/Science"/>
<xsl:value-of select="($maths+$science)" />
Thanks
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please try this.....
<Total_Marks>
<xsl:variable name="maths" select="Maths"/>
<xsl:variable name="science" select="Science"/>
<xsl:value-of select="sum ( ($maths,$science) )" />
</Total_Marks>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hei,
you have to add the namespace prefix to each element of the path (and of course: check out if the hierarchy is matching)
ns0:MT_Student/ns0:Data/ns0:Marks/ns0:Science
Regards,
Udo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Usually, i map all fields (and make concatenation or similar) with the visual mapping, and then I trasform message with XSLT mapping.
For Marks fields, i think that you have to insert in Xslt mapping, a for-each iteration...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.