on 10-15-2013 1:52 PM
Hi Experts,
I have a requirement to create an HTML Email using the XSLT Mapping in SAP PI 7.31 java stack.
Below is the source structure:
<Content>
<header>
<section>
<para1>
<para2>
<para3>...
<LineItem1>
<LineItem2>
<LineItem3>.....
Above structure needs to be mapped to standard mail package <content> field. How to iterate the section segment which contains
multiple <para> tags and <LineItem> tags in XSLT mapping. I have tried below XSLT mapping code -
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://sap.com/xi/XI/Mail/30">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<Mail xmlns="http://sap.com/xi/XI/Mail/30">
<xsl:for-each select="//Mail"/>
<Content>
<xsl:value-of select="ns0:Mail/Content/Header"/>
<xsl:for-each select="//Paragraph">
<xsl:value-of select="//Paragraph"/>
</xsl:for-each>
<xsl:for-each select="//LineItems">
<xsl:value-of select="//LineItems"/>
</xsl:for-each>
<xsl:value-of select="ns0:Mail/Content/Footer"/>
</Content>
</Mail>
</xsl:template>
</xsl:stylesheet>
Above code always gives me the first para value duplicated for all the other para values and first LineItem value duplicated for all the other LineItems.
Please help me correcting this XSLT mapping code. If any one already worked on such scenario, please share sample code.
Hi Vishwanath,
If you are using //Paragraph it is meant to take the first occurrence only so you are getting the repeated value. Try this - please put the path accordingly to reach paragraph node :
<xsl:for-each select="ns0:Mail/Content/section/paragraph">
<xsl:value-of select="." />
</xsl:for-each>
Similarly for line item.
Regards
Subhro
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Subhro,
Thanks a lot for the reply and the suggestion. I have changed the xslt mapping as suggested and it worked fine to iterate values. But when I run this end-to-end, I am getting an error for the mail adapter as
Please assist. Below is the complete XSLT mapping for reference:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://sap.com/xi/XI/Mail/30">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<Mail xmlns="http://sap.com/xi/XI/Mail/30">
<Subject>
<xsl:value-of select="ns0:Mail/Subject"/>
</Subject>
<From>
<xsl:value-of select="ns0:Mail/From"/>
</From>
<To>
<xsl:value-of select="ns0:Mail/To"/>
</To>
<Reply_To>
<xsl:value-of select="ns0:Mail/Reply_To"/>
</Reply_To>
<Content_Type>
<xsl:value-of select="ns0:Mail/Content_Type"/>
</Content_Type>
<Content>
<xsl:value-of select="ns0:Mail/Content/Header"/>
<xsl:for-each select="//Paragraph">
<xsl:value-of select="."/>
</xsl:for-each>
<xsl:for-each select="//LineItems">
<xsl:value-of select="."/>
</xsl:for-each>
<xsl:value-of select="ns0:Mail/Content/Footer"/>
</Content>
<!-- </xsl:template> -->
</Mail>
<!-- </body>
</html> -->
</xsl:template>
</xsl:stylesheet>
Hi Vishwanath,
Please check the output of your message mapping and the discussion below :
Note - Content Type should be text/plain and Content should come up once.
http://scn.sap.com/thread/3375281
Regards
Subhro
Hi Subhro,
I have tested the source XML in the Operation Mapping and I could see the Content came up only once as I have included all the source data into Content field in the XSLT mapping. I have also changed the Content Type to - text/plain. But still am getting the same mail adapter error :
15/10/2013 15:40:16.734 | Error | MP: exception caught with cause com.sap.aii.af.sdk.xi.srt.BubbleException: Failed to call the endpoint [null "null"]; nested exception caused by: com.sap.aii.af.sdk.xi.util.XMLScanException: expecting end tag: {http://sap.com/xi/XI/Mail/30}Mail, but found {http://sap.com/xi/XI/Mail/30}Subject at state 1 |
15/10/2013 15:40:16.734 | Error | Mail: Error occurred: com.sap.aii.af.lib.mp.module.ModuleException |
15/10/2013 15:40:16.734 | Error | Mail: Error occurred: com.sap.aii.af.sdk.xi.util.XMLScanException: expecting end tag: {http://sap.com/xi/XI/Mail/30}Mail, but found {http://sap.com/xi/XI/Mail/30}Subject at state 1 |
15/10/2013 15:40:16.739 | Error | Exception caught by adapter framework: Failed to call the endpoint |
15/10/2013 15:40:16.741 | Error | Transmitting the message to endpoint <local> using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.af.sdk.xi.srt.BubbleException: Failed to call the endpoint [null "null"]; nested exception caused by: com.sap.aii.af.sdk.xi.util.XMLScanException: expecting end tag: {http://sap.com/xi/XI/Mail/30}Mail, but found {http://sap.com/xi/XI/Mail/30}Subject at state 1 |
I have set the below parameters for the mail adapter:
Msg Protocol - XIPAYLOAD
Use Mail Package - selected
Content Encoding - base64
Use Adapter-Specific Message Atributes - selected
Varaible transport Binding - selected.
Please let me know where I am doing wrong.
Thanks a lot for all the assistance.
This is the output payload from the Operation Mapping -
<?xml version="1.0" encoding="UTF-8"?>
<Mail xmlns="http://sap.com/xi/XI/Mail/30" xmlns:ns0="http://sap.com/xi/XI/Mail/30">
<Subject>Orders have been processed (BACKORDER_BACKORDER_OK)</Subject>
<From>FromMail id</From>
<To>To Mail ID</To>
<Reply_To/>
<Content_Type>text/plain;charset="iso-8859-1"</Content_Type>
<Content>Test Content</Content>
</Mail>
Hi Vishwanath,
You may want to try the following :
1) Generating this in the format below changing the xslt Mail tags without the http://sap.com/xi/XI/Mail/30 tag i.e. as follows :
<ns0:Mail xmlns:ns0="http://sap.com/xi/XI/Mail/30">
</ns0:Mail>
2) Use Content_Type as text/plain to start with - for sure the charset can be send in Content Type - it is just to check if the quotes are causing any issue.
Regards
Subhro
Hi Subhro,
Thanks a lot for all the assistance wrt my mail adapter issue.
I still see the same error even after modifying the XSLT map as suggested above.
It gives exactly same error message:
15/10/2013 16:26:16.777 | Error | MP: exception caught with cause com.sap.aii.af.sdk.xi.srt.BubbleException: Failed to call the endpoint [null "null"]; nested exception caused by: com.sap.aii.af.sdk.xi.util.XMLScanException: expecting end tag: {http://sap.com/xi/XI/Mail/30}Mail, but found {http://sap.com/xi/XI/Mail/30}Subject at state 1 |
15/10/2013 16:26:16.777 | Error | Mail: Error occurred: com.sap.aii.af.lib.mp.module.ModuleException |
15/10/2013 16:26:16.777 | Error | Mail: Error occurred: com.sap.aii.af.sdk.xi.util.XMLScanException: expecting end tag: {http://sap.com/xi/XI/Mail/30}Mail, but found {http://sap.com/xi/XI/Mail/30}Subject at state 1 |
Not very sure where am making mistake.
Please let me know if any other options I can try of.
Hi Subhro,
Your suggestion worked finally.
I have removed the
http://sap.com/xi/XI/Mail/30 tag and it worked. Hurray...
Thanks a lot for your patient assistance all through my issue.
Hi Experts,
Can anyone help me fixing this Mail adapter issue. Am using the XSLT mapping to build the standard mail xsd and pass it through mail package. I have set the below parameters for the mail adapter:
Msg Protocol - XIPAYLOAD
Use Mail Package - selected
Content Encoding - base64
Use Adapter-Specific Message Atributes - selected
Varaible transport Binding - selected.
Please correct me if I have done anything wrong in the xslt mapping. I have pasted the XSLT map above.
Regards,
VD
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
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.