RE: [xsl] How to put space between two characters?

Subject: RE: [xsl] How to put space between two characters?
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Tue, 6 Apr 2004 10:15:58 -0500
Hi puja,

I just realized that your original question was to put space between words,
while the answers (including mine) were focused on images...

Anyway, although you can, there is no real need to use DOCTYPE, you simply
use &#160; (which is output to the non-braking-space &nbsp; equivalent) in
your XSL Stylesheet to separate whatever HTML elements, like this:

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

<xsl:output method="html" encoding="UTF-8" indent="yes" />

<xsl:template match="/run">
	<html>
	<head>
	<title>Title</title>
	</head>
	<body>
	<img src="C:\Documents and
Settings\psiegers\Desktop\pietsiegs.jpg"></img>
	&#160;&#160;
	<img src="C:\Documents and
Settings\psiegers\Desktop\pietsiegs.jpg"></img>
	</body>
	</html>
</xsl:template>

</xsl:stylesheet>

Alternativley, you can use a HTML table, set the border to '0', and play
with the clellspacing attribute of the <td> elements, like this:

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

<xsl:output method="html" encoding="UTF-8" indent="yes" />

<xsl:template match="/run">
	<html>
	<head>
	<title>Title</title>
	</head>
	<body>
	<table border="0" cellspacing="10">
	<tr>
	<td>
		<img src="C:\Documents and
Settings\psiegers\Desktop\pietsiegs.jpg"></img>
	</td>
	<td>
		<img src="C:\Documents and
Settings\psiegers\Desktop\pietsiegs.jpg"></img>
	</td>
	</tr>
	</table>
	</body>
	</html>
</xsl:template>

</xsl:stylesheet>

But note that this approach gives you 10 pixels AROUND the whole image, an
effect you may not wish to use.

A final approach (IMO, the best) that makes use of both techniques is to use
a <table> element and add another <td> element between the two <img>
elements, and fill it with the amount of non-breaking spaces like this:

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

<xsl:output method="html" encoding="UTF-8" indent="yes" />

<xsl:template match="/run">
	<html>
	<head>
	<title>Title</title>
	</head>
	<body>
	<table border="0">
	<tr>
	<td>
		<img src="C:\Documents and
Settings\psiegers\Desktop\pietsiegs.jpg"></img>
	</td>
	<td>&#160;&#160;&#160;&#160;</td>
	<td>
		<img src="C:\Documents and
Settings\psiegers\Desktop\pietsiegs.jpg"></img>
	</td>
	</tr>
	</table>
	</body>
	</html>
</xsl:template>

</xsl:stylesheet>

Please let us know if this answers your questions.

Cheers, Pieter  


<prs/>
http://www.pietsieg.com
http://www.pietsieg.com/dotnetnuke
Contributor on www.ASPToday.com
Co-author on "Professional ASP.NET XML with C#", July 2002 by Wrox Press

Current Thread