Skip to Content
0
Former Member
Mar 16, 2009 at 12:23 PM

XSLT Mapping code

66 Views

i want to produce correct output, which is mentioned in the the blog /people/prasadbabu.nemalikanti3/blog/2006/03/30/xpath-functions-in-xslt-mapping

i think there was an error in the XSLT coding.

i modified the code as follows:

<xsl:transform version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:sap="http://www.sap.com/sapxsl"

xmlns:p2="urn://Mapping">

<xsl:template match="/">

<p2:MT_STUD>

<Records>

<xsl:for-each select="p2:MT_STUD_SORC/Records/Student_ID">

<Student_ID>

<Name>

<xsl:value-of select="concat(concat (p2:MT_STUD_SORC/Records/Student_ID/Fname,' '),p2:MT_STUD_SORC/Records/Student_ID/Lname)"/>

</Name>

<Year_Birth>

<xsl:value-of select="substring(p2:MT_STUD_SORC/Records/Student_ID/DOB,1,4)"/>

</Year_Birth>

<Month_Birth>

<xsl:value-of select="substring(p2:MT_STUD_SORC/Records/Student_ID/DOB,5,2)"/>

</Month_Birth>

<Date_Birth>

<xsl:value-of select="substring(p2:MT_STUD_SORC/Records/Student_ID/DOB,7,8)"/>

</Date_Birth>

<Marks>

<Science>

<xsl:value-of select="p2:MT_STUD_SORC/Records/Student_ID/Marks/Science"/>

</Science>

<Maths>

<xsl:value-of select="p2:MT_STUD_SORC/Records/Student_ID/Marks/Maths"/>

</Maths>

<Language>

<xsl:value-of select="p2:MT_STUD_SORC/Records/Student_ID/Marks/Language"/>

</Language>

<Total_Marks>

<xsl:value-of select="sum(p2:MT_STUD_SORC/Records/Student_ID/Marks/Sciense, p2:MT_STUD_SORC/Records/Student_ID/Marks/Maths, p2:MT_STUD_SORC/Records/Student_ID/Marks/Language)"/>

</Total_Marks>

</Marks>

</Student_ID>

</xsl:for-each>

<No_Students>

<xsl:value-of select="count(p2:MT_STUD_SORC/Records/Student_ID)"/>

</No_Students>

</Records>

</p2:MT_STUD>

</xsl:template>

</xsl:transform>

here inthis i got two errors, one is SUM function have improper arguments,

and the second one is, i am unable to produce the multiple students at the receiver side.

can any body modify and correct this code?

Thanks ,

kumar