on 10-18-2006 8:42 AM
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 -
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 -
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
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.