Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7020637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:20:38+00:00 2026-05-27T23:20:38+00:00

I have an XSL template that is a small section of an HTML email.

  • 0

I have an XSL template that is a small section of an HTML email. The XSL section changes based on data, but the surrounding HTML does not. I would like to include this HTML in the XSL template. I tried the following approach, but get an exception because the tags in the EmailHeader.html are not closed. I tried using CDATA tags, but with no success.

My exception: Unexpected end of file has occurred. The following elements are not closed: td, tr, table, td, tr, table, body, html.

How can I include the html sections in the XSL template?

(Code samples have been simplified)

My XSL File:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" />

     <xsl:template match="/Email">    

     <xsl:copy-of select="document('EmailHeader.html')"></xsl:copy-of>

    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td style="width:25px">&#160;</td>
        <td style="width:550px; text-align:left; font-family:Arial; font-size:10pt; color:#444444">
          <br /><br />
          To <xsl:value-of select="FirstName"/>&#160;<xsl:value-of select="LastName"/>:
          <br /><br />
          Welcome, and thank you for enrolling...
         </td>
        <td style="width:25px">&#160;</td>
      </tr>
    </table>

    <xsl:copy-of select="document('EmailFooter.html')"></xsl:copy-of>

   </xsl:template>

</xsl:transform>

EmailHeader.html:

<html xmlns="http://www.w3.org/1999/xhtml" style="background-color:#96A084">
<head>
    <title></title>
</head>
<body style="background-color:#96A084; margin:0px; padding:0px">
<table border="0" cellpadding="0" cellspacing="0" width="630px" style="background-color:#96A084">
  <tr>
    <td>

EmailFooter.html:

    <td style="width:15px">&#160;</td>
  </tr>
</table>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:20:39+00:00Added an answer on May 27, 2026 at 11:20 pm

    What you could do, is create your complete Email template in a separate file, and then pass the body of the email to it as a parameter. For example, save the following XSLT in a file called EmailTemplate.xslt

    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       <xsl:output method="html"/>
    
       <xsl:template name="Email">
          <xsl:param name="body"/>
          <html xmlns="http://www.w3.org/1999/xhtml" style="background-color:#96A084">
             <head>
                <title/>
             </head>
             <body style="background-color:#96A084; margin:0px; padding:0px">
                <table border="0" cellpadding="0" cellspacing="0" width="630px" style="background-color:#96A084">
                   <tr>
                      <td>
                         <xsl:copy-of select="$body"/>
                      </td>
                      <td style="width:15px"> </td>
                   </tr>
                </table>
             </body>
          </html>
       </xsl:template>
    </xsl:transform>
    

    Next, amend your original XSLT to import this file, and then call the named Email template with the HTML for the email body as a parameter

    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       <xsl:include href="EmailTemplate.xslt"/>
    
       <xsl:output method="html"/>
    
       <xsl:template match="/Email">
          <xsl:variable name="body">
             <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                   <td style="width:25px"> </td>
                   <td style="width:550px; text-align:left; font-family:Arial; font-size:10pt; color:#444444">
                      <br/>
                      <br/> To 
                      <xsl:value-of select="FirstName"/> 
                      <xsl:value-of select="LastName"/>: 
                      <br/>
                      <br/>Welcome, and thank you for enrolling... 
                   </td>
                   <td style="width:25px"> </td>
                </tr>
             </table>
          </xsl:variable>
          <xsl:call-template name="Email">
             <xsl:with-param name="body" select="$body"/>
          </xsl:call-template>
       </xsl:template>
    
    </xsl:transform>
    

    So, when you apply this XSLT to the following XML

    <Email>
    <FirstName>John</FirstName>
    <LastName>Smith</LastName>
    </Email>
    

    The following should be output

    <html style="background-color:#96A084" xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    </head>
    <body style="background-color:#96A084; margin:0px; padding:0px">
    <table border="0" cellpadding="0" cellspacing="0" width="630px" style="background-color:#96A084">
    <tr>
    <td>
    <table border="0" cellpadding="0" cellspacing="0" xmlns=""><tr><td style="width:25px"> </td><td style="width:550px; text-align:left; font-family:Arial; font-size:10pt; color:#444444"><br><br> To 
                      John 
                      Smith: 
                      <br><br>Welcome, and thank you for enrolling... 
                   </td><td style="width:25px"> </td></tr></table>
    </td>
    <td style="width:15px"> </td>
    </tr>
    </table>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a small template that looks like: <xsl:template name=templt> <xsl:param name=filter />
I have a xml that looks like below <xsl:template match=//xml> <xsl:for-each select=//z:row> <ul class
I have an XSL template that is selected for execution (below). What I would
I have an xml column ExportTemplate in a table that holds an xsl template
I have made a small xslt file to create an html output called weather.xsl
I have an xsl template that I want to call to put into an
I am writing a template that extends templates, but it has some issues. <xsl:template
I have developed an XSL file that transforms xml files into a html table.
I have the following xsl template that I'm using to group my xsl. The
I have the following XSL template (I omitted the template for Organization, let me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.