aspose file tools*
The moose likes XML and Related Technologies and the fly likes whitespace... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "whitespace..." Watch "whitespace..." New topic
Author

whitespace...

Sarran Vidyakumar
Greenhorn

Joined: Mar 26, 2003
Posts: 28
hey guyz:
on transformation the whitespace is lost..I need the output in the table to show the spaces after name..I tried the <xsl reserve-space elements="name" /> but it still strips off the spaces..any suggestions..Thanks....


sample XML File:

<?xml version="1.0" encoding="UTF-8"?>
<devguru_staff>
<programmer>
<name>Bugs Bunny </name>
<dob>03/21/1970</dob>
<phone>865-111-1111</phone>
</programmer>
<programmer>
<name>Daisy Duck </name>
<dob>08/09/1949</dob>
<phone>865-222-2222</phone>
</programmer>
</devguru_staff>

Sample XSL File:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl reserve-space elements="name" />
<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:for-each select="devguru_staff/programmer">
<tr>
<td>
<xsl:value-of select="name" />
</td>
<td>
<xsl:value-of select="dob" />
</td>
<td>
<xsl:value-of select="phone" />
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Sarran Vidyakumar
Greenhorn

Joined: Mar 26, 2003
Posts: 28
<xsl:value-of select='translate(.," "," ")'/>

solves the prob..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: whitespace...