The xsl:preserve-space element is used to keep white-space only nodes in the output. Note that the default is to leave white-space only nodes. Therefore, it is only necessary to use the xsl:preserve-space element when you use the xsl:strip-space element and wish to insure that certain white-space nodes are not removed. By white-space, we refer to carriage returns, line feeds, spaces and tabs. No text or numbers appear in the node.
The related xsl:strip-space element is used to remove white-space only nodes so that they do not appear in the output. This is a self-closing element and it cannot contain any child elements or any content.
The mandatory elements attribute is a white-space delimited list of the names of the elements in which all of the white-space nodes must not be removed. You can also use generic names with wild cards.
We use the eBIZ_com_Staff XML file for our example with the following header: <?xml-stylesheet type=”text/xsl” href=”xslt_example_preservespace.xsl”?> and we name it: eBIZ_com_Staff.xml
Code for xslt_example_preservespace1.xsl:
<?xml version="1.0" encoding="iso-8859-1"?>

<!-- DWXMLSource="sample23.xml" --><!DOCTYPE xsl:stylesheet  [

	<!ENTITY nbsp   " ">

	<!ENTITY copy   "©"

	<!ENTITY reg    "®"

	<!ENTITY trade  "™">

	<!ENTITY mdash  "—"

	<!ENTITY ldquo  "“">

	<!ENTITY rdquo  "”">

<!ENTITY pound  "£">

	<!ENTITY yen    "¥">

	<!ENTITY euro   "€">


<xsl:stylesheet version="1.0" 


<xsl:preserve-space elements="fname" />

<xsl:output method="html" encoding="iso-8859-1"

 doctype-public="-//W3C//DTD XHTML 1.0 

Transitional//EN" doctype-system=


<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">



var i=0;

function mm() {





<meta http-equiv="Content-Type" 

content="text/html; charset=iso-8859-1"/>

<title>Sample XSL Document</title>

<style type="text/css">


.style3 {font-family: Geneva, Arial,

 Helvetica, sans-serif; color: #0033FF; }





<table width="59%" border="1" cellspacing="0" cellpadding="1" id="data">


    <td width="9%" nowrap="nowrap"

 bgcolor="#6699FF"><strong>Sr no </strong></td>

    <td width="22%" bgcolor="#6699FF">

<strong>Employee ID </strong></td>

	<td width="30%" bgcolor="#6699FF">



    <td width="20%" bgcolor="#6699FF">



    <td width="19%" bgcolor="#6699FF">


	<td width="19%" nowrap="nowrap" b

gcolor="#6699FF"><strong>Phone No </strong></td>

	<td width="19%" nowrap="nowrap
bgcolor="#6699FF"><strong>Address </strong></td>


<xsl:for-each select="ebiz/employee_details">


    <td><span class="style3">.



<td nowrap="nowrap"><span class="style3">

<xsl:value-of select="emp_id" /></span></td>

	 <td nowrap="nowrap"><span class="style3"

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

<xsl:value-of select="lname"></xsl:value-of></span></td>


    <td nowrap="nowrap"><xsl:value-of select="department" /></td>


    <td nowrap="nowrap"><xsl:value-of select="designation" /></td>

	<td nowrap="nowrap"><xsl:value-of select="phone" /></td>

	<td nowrap="nowrap"><xsl:value-of select="address"/></td