Click here to Skip to main content
12,696,920 members (28,765 online)
Click here to Skip to main content
Articles » Languages » XML » XML/XSLT » Downloads


29 bookmarked

Template Messages Using XSL Transformations and XML Serialization

, 23 Aug 2007 CPOL
This article shows how you can implement templated messages, such as email templates
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
	<xsl:template match="/">
				<xsl:variable name="orderId" select="mailData/@orderId"/>
				<xsl:variable name="totalSum" select="sum(mailData/orderedProducts/orderedProduct/price)"/>
					Dear <xsl:value-of select="mailData/name"/>,
					On <xsl:value-of select="mailData/orderDate"/> you ordered some product from 
					<a href="">our website</a>.
					<xsl:for-each select="mailData/orderedProducts/orderedProduct">
							Order <xsl:value-of select="$orderId"/>:
								<xsl:attribute name="href">
									<xsl:value-of select="@id"/>
								<xsl:value-of select="name"/>
							</a> - $<xsl:value-of select="format-number(price, '#.00')"/>
				Total price: $<xsl:value-of select="format-number($totalSum, '#.00')"/>
				<xsl:if test="count(mailData/orderedProducts/orderedProduct) &gt; 2">
						You ordered more than 2 products and you will receive a <b>free hat</b>.
				<xsl:if test="$totalSum &gt; 20">
						You ordered products for more than $<xsl:value-of select="format-number(20, '#.00')"/>
						and the delivery of the products will be <b>free</b>.
					To confirm your order please follow 
						<xsl:attribute name="href">
							<xsl:value-of select="$orderId"/>
							<xsl:value-of select="mailData/name"/>
						this link

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Cvetomir Todorov
Software Developer
Bulgaria Bulgaria
Cvetomir Todorov is a student in the Sofia University. His interests include Object Oriented Programming and Design, Design Patterns, Producing High-Quality Code, Refactoring, Unit Testing, Test Driven Development etc. The technology he's using is .NET with C# language.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 23 Aug 2007
Article Copyright 2007 by Cvetomir Todorov
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid