cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT Mapping issue

Former Member
0 Kudos

Hi ,

I'm working on a requirement to convert xml payload to table format .I'm getting syntax errors when tried to test it .Could you please check my code and let me know for any mistakes .

XML Payload:

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

<ns0:PensionErrorReports xmlns:ns0="urn:XYZ:HR:PensionDetails"><FROM>XYZ@gmail.com</FROM><TO>XYZ@gmail.com</TO><Pension_ErrorReports><PayrollNumber>123</PayrollNumber><EMPLOYEE_INITIALS>Nimmagadda</EMPLOYEE_INITIALS><EDIT_NAME>Venkat</EDIT_NAME><COMMENT>testing for emp1</COMMENT><DateOfTransfer>19/03/2014</DateOfTransfer></Pension_ErrorReports><Pension_ErrorReports><PayrollNumber>345</PayrollNumber><EMPLOYEE_INITIALS>Nimmagadda</EMPLOYEE_INITIALS><EDIT_NAME>Venkat</EDIT_NAME><COMMENT>testing for emp2</COMMENT><DateOfTransfer>19/03/2014</DateOfTransfer></Pension_ErrorReports></ns0:PensionErrorReports>

XSLT Code:

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

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:ns0="urn:XYZ:HR:PensionDetails">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

  <xsl:variable name="break"><br></xsl:variable>

  <xsl:variable name="tableB"><table></xsl:variable>

  <xsl:variable name="tableE"></table></xsl:variable>

  <xsl:variable name="trB"><tr></xsl:variable>

  <xsl:variable name="trE"></tr></xsl:variable>

  <xsl:variable name="tdB"><td></xsl:variable>

  <xsl:variable name="tdE"></td></xsl:variable>

  <xsl:variable name="nbsp"> </xsl:variable>

  <xsl:variable name="thB"><tr BGCOLOR="#CCCC99"></xsl:variable>

<xsl:template match="/">

<ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">

  <Subject>Error Report of ZZZZ</Subject>

<From>

  <xsl:value-of select="ns0:PensionErrorReports/FROM" />

  </From>

<To>

  <xsl:value-of select="ns0:PensionErrorReports/TO" />

  </To>

  <Content_Type>text/html</Content_Type>

<Content>

<b>

  <xsl:text>Hi Team \n\r There was an error from SAP ECC while processing IDOC for the interface <ZZZZ>. Below are the details. Please take required action immediately.</xsl:text>

  </b>

  <xsl:value-of select="$break" />

  <xsl:value-of select="$break" />

  <xsl:value-of select="$tableB" />

  <xsl:value-of select="$thB" />

  <xsl:value-of select="$tdB" />

<b>

  <xsl:text>Payroll number</xsl:text>

  </b>

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$tdB" />

<b>

  <xsl:text>Name</xsl:text>

  </b>

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$tdB" />

<b>

  <xsl:text>Formatted Name of Emp or Applicant</xsl:text>

  </b>

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$tdB" />

<b>

  <xsl:text>COMMENT</xsl:text>

  </b>

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$tdB" />

<b>

  <xsl:text>Date of Transfer</xsl:text>

  </b>

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$trE" />

<xsl:for-each select="ns0:PensionErrorReports/Pension_ErrorReports">

  <xsl:value-of select="$trB" />

  <xsl:value-of select="$tdB" />

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

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$tdB" />

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

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$tdB" />

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

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$tdB" />

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

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$tdB" />

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

  <xsl:value-of select="$nbsp" />

  <xsl:value-of select="$tdE" />

  <xsl:value-of select="$trE" />

  </xsl:for-each>

  <xsl:value-of select="$tableE" />

  <xsl:value-of select="$break" />

  <xsl:value-of select="$break" />

  </Content>

  </ns1:Mail>

  </xsl:template>

  </xsl:stylesheet>

Regards

Venkat

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

I have found out the problems in your code. Change the below declarations of xsl variable

<xsl:variable name="break"><br></xsl:variable>

  <xsl:variable name="tableB"><table></xsl:variable>

  <xsl:variable name="tableE"></table></xsl:variable>

  <xsl:variable name="trB"><tr></xsl:variable>

  <xsl:variable name="trE"></tr></xsl:variable>

  <xsl:variable name="tdB"><td></xsl:variable>

  <xsl:variable name="tdE"></td></xsl:variable>

  <xsl:variable name="nbsp"> </xsl:variable>

  <xsl:variable name="thB"><tr BGCOLOR="#CCCC99"></xsl:variable>

The correct way to declare this would be like below

<xsl:variable name="break">&lt;br&gt;</xsl:variable>

  <xsl:variable name="tableB">&lt;table BORDER="5"&gt;</xsl:variable>

  <xsl:variable name="tableE">&lt;/table&gt;</xsl:variable>

  <xsl:variable name="trB">&lt;tr&gt;</xsl:variable>

  <xsl:variable name="trE">&lt;/tr&gt;</xsl:variable>

  <xsl:variable name="tdB">&lt;td&gt;</xsl:variable>

  <xsl:variable name="tdE">&lt;/td&gt;</xsl:variable>

  <xsl:variable name="nbsp"> </xsl:variable>

  <xsl:variable name="thB">&lt;tr BGCOLOR="#CCCC99"&gt;</xsl:variable>

Also change this line

<xsl:text>Hi Team \n\r There was an error from SAP ECC while processing IDOC for the interface <ZZZZ>. Below are the details. Please take required action immediately.</xsl:text>


remove the < and > from <zzzz>.


So the correct line would be


<xsl:text>Hi Team \n\r There was an error from SAP ECC while processing IDOC for the interface ZZZZ. Below are the details. Please take required action immediately.</xsl:text>


Make these changes and save the xsl file. Change the imported archive to have the changed XSL file.

Then make a test. Your code should work now.


Let me know if there are any issues.


Thanks

Indrajit

Former Member
0 Kudos

Hi ,

Thanks buddy .Sorry for the delay in response .I could able to draft a mail using mail package.

By mistake I pasted xslt code in browser rather than source code .

remove the < and > from <zzzz>. -->It helped me .



Though I'm inserting new line in text in run time it's not appearing in mail ?


Hi Team, &#10; There was an error from SAP ECC while processing IDOC for the interface HRI060. Below are the details. Please take required action immediately 


I tried (&#10;&#xa;) for line insertion ,but no luck.


Regards

Venkat

Former Member
0 Kudos

Hi Venkat

I don't think we can add \n\r in xml field content. You can add one more text line in the xsl code like below

<b>

  <xsl:text>Hi Team,</xsl:text>

</b>

<b>

  <xsl:text>There was an error from SAP ECC while processing IDOC for the interface HRI060. Below are the details. Please take required action immediately.</xsl:text>

</b>

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Venkat

I don't think you can send the data in tabular format using mail package. The body of the email has to be the content of field <CONTENT> of mail package.

We can pass HTML data inside the xml field using CDATA but I don't think that will display as html table in the email body.

Without mail package it would have been very easy. Please check the doc below which is also sending HTML content in the body of the email