cancel
Showing results for 
Search instead for 
Did you mean: 

Mail Adapter :: eMail Reporting

Former Member
0 Kudos

Hi

I am creating one scenario using following weblog :

/people/community.user/blog/2006/09/08/email-report-as-attachment-excelword

But in my mail I am getting the Headings but not the values which I am providing through my XML file.

I even deleted all the fomatting elements but still the same thing.

My XSLT file is like this now ...

***********************************************

?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

<xsl:template match="/">

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

<Subject>Deliveries from XI</Subject>

<From><i>MY EMAIL ID</i></From>

<To><i>My EMAIL ID</i></To>

<Content_Type>text/html</Content_Type>

<Content>

<xsl:text xsl:space="preserve">Catalog of CDs available:</xsl:text>

<xsl:text xsl:space="preserve">Title</xsl:text>

<xsl:text xsl:space="preserve">Artist</xsl:text>

<xsl:text xsl:space="preserve">Country</xsl:text>

<xsl:text xsl:space="preserve">Company</xsl:text>

<xsl:text xsl:space="preserve">Price</xsl:text>

<xsl:text xsl:space="preserve">Year</xsl:text>

<xsl:for-each select="Catalog_MT/cd">

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

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

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

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

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

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

</xsl:for-each>

</Content>

</ns1:Mail>

</xsl:template>

</xsl:stylesheet>

*************************************************

My XML file is this

<?xml version="1.0" encoding="ISO-8859-1" ?>

- <ns0:Catalog_MT xmlns:ns0="urn:Reporting">

- <cd>

<title>Empire Burlesque</title>

<artist>Bob Dylan</artist>

<country>USA</country>

<company>Columbia</company>

<price>10.90</price>

<year>1985</year>

</cd>

- <cd>

<title>Hide your heart</title>

<artist>Bonnie Tyler</artist>

<country>UK</country>

<company>CBS Records</company>

<price>9.90</price>

<year>1988</year>

</cd>

</ns0:Catalog_MT>

***************************************

I am getting the output like this in my Mail Body -->

<i><b>Catalog of CDs available:TitleArtistCountryCompanyPriceYear</b></i>

I am not so good in XSLT. Can you pls. suggest what am I missing.

Regards

- Lalit -

Accepted Solutions (1)

Accepted Solutions (1)

former_member206604
Active Contributor
0 Kudos

Hi,

You did not consider namespace in your XSLT

try this

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <b>xmlns:ns2="urn:Reporting"</b>>

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

<xsl:template match="/">

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

<Subject>Deliveries from XI</Subject>

<From>MY EMAIL ID</From>

<To>My EMAIL ID</To>

<Content_Type>text/html</Content_Type>

<Content>

<xsl:text xsl:space="preserve">Catalog of CDs available:</xsl:text>

<xsl:text xsl:space="preserve">Title</xsl:text>

<xsl:text xsl:space="preserve">Artist</xsl:text>

<xsl:text xsl:space="preserve">Country</xsl:text>

<xsl:text xsl:space="preserve">Company</xsl:text>

<xsl:text xsl:space="preserve">Price</xsl:text>

<xsl:text xsl:space="preserve">Year</xsl:text>

<xsl:for-each select<b>="ns2:Catalog_MT/cd"</b>>

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

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

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

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

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

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

</xsl:for-each>

</Content>

</ns1:Mail>

</xsl:template>

</xsl:stylesheet>

Regards,

Prakash

Answers (1)

Answers (1)

former_member187339
Active Contributor
0 Kudos

Hi,

Your XSLT should be:

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

<xsl:template match="/">

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

<b><ns0:Catalog_MT xmlns:ns0="urn:Reporting"></b>

<Subject>Deliveries from XI</Subject>

<From>MY EMAIL ID</From>

<To>My EMAIL ID</To>

<Content_Type>text/html</Content_Type>

<Content>

<xsl:text xsl:space="preserve">Catalog of CDs available:</xsl:text>

<xsl:text xsl:space="preserve">Title</xsl:text>

<xsl:text xsl:space="preserve">Artist</xsl:text>

<xsl:text xsl:space="preserve">Country</xsl:text>

<xsl:text xsl:space="preserve">Company</xsl:text>

<xsl:text xsl:space="preserve">Price</xsl:text>

<xsl:text xsl:space="preserve">Year</xsl:text>

<b><xsl:for-each select="ns0:Catalog_MT/cd"></b>

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

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

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

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

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

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

</xsl:for-each>

</Content>

<b></ns0:Catalog_MT></b>

</ns1:Mail>

</xsl:template>

</xsl:stylesheet>

Regards

Suraj

Former Member
0 Kudos

Thanks Prakash & Suraj.

This solved me problem.

Pls. confirm if I will use multiple XML source files & will use single XSLT than i have to declare the namespaces of all of them.

Also in case I want " <b>To</b> " field to be dynamic, do I need to do this in XML file & XSLT file

<?xml version="1.0" encoding="ISO-8859-1" ?>

- <ns0:Catalog_MT xmlns:ns0="urn:Reporting">

<i><sender>abc@company.com</sender></i>

- <cd>

<title>Empire Burlesque</title>

<artist>Bob Dylan</artist>

<country>USA</country>

<company>Columbia</company>

<price>10.90</price>

<year>1985</year>

</cd>

</ns0:Catalog_MT>

**************************************

<XSLT File >

......

....

<b><To><xsl:value-of select="ns2:Catalog_MT/sender"/></To></b>

......

......

Thanks

- Lalit -

former_member206604
Active Contributor
0 Kudos

Hi,

1.You can go to the Message Type and remove the Target Namespace then you will have that ns0: in your Message Type. So you can use the same XSLT for all the cases but the strucutre should be the same.

You can also use this XSLT for removing namespaces. In the interface mapping you need to add one more mapping of type XSL and add the following XSLT as the first one and then you can add your actual XSLT. In this case you need not handle namespace.

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

<xsl:stylesheet version="1.0"

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

<xsl:output method="xml" indent="no"/>

<xsl:template match="/|comment()|processing-instruction()">

<xsl:copy>

<xsl:apply-templates/>

</xsl:copy>

</xsl:template>

<xsl:template match="*">

<xsl:element name="{local-name()}">

<xsl:apply-templates select="@*|node()"/>

</xsl:element>

</xsl:template>

<xsl:template match="@*">

<xsl:attribute name="{local-name()}">

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

</xsl:attribute>

</xsl:template>

</xsl:stylesheet>

Regards,

Prakash

bhavesh_kantilal
Active Contributor
0 Kudos

Lalit,

<i><To><xsl:value-of select="ns2:Catalog_MT/sender"/></To></i>

Looks good / correct to me. Maybe the XSL expert ( Prakash ) can cofirm .

Regards,

Bhavesh

former_member206604
Active Contributor
0 Kudos

Hi Lalit,

Bhavesh is right <To><xsl:value-of select="ns2:Catalog_MT/sender"/></To> this is fine.

<i>

>>>Looks good / correct to me. Maybe the XSL expert ( Prakash ) can cofirm .</i>

@Bhavesh

Yes sir you are right, but XSL expert is too muh for me

Regards,

Prakash

Former Member
0 Kudos

Thanks Bhaveh & Prakash

That worked for me & now I am able to use Dynamic IDs.

Prakash you are an expert in XSL as the program which u suggest me above, i need to learn XSL first in order to understand that.

- Lalit -

{ Problem resolved }