[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Fwd: Over/under trimming of whitespace

Subject: [xsl] Fwd: Over/under trimming of whitespace
From: "David Morris" <David.Morris@xxxxxxxxxxxxx>
Date: Thu, 25 Apr 2002 15:12:31 -0600


I have a stylesheet to convert from XHTML to FOP. I haven't been 
able to come up with a good way to distinguish between an element 
like <td></td>, <td/>, and <td>-some whitespace-</td>. 

I want an element with whitespace to do nothing and to generate an:
<fo:inline white-space-collapse="false"> </fo:inline>

I am using the following:

  <xsl:when test="normalize-space()=' ' and .!=''">
    <fo:inline white-space-collapse="false"> </fo:inline>

I have a couple of problems here, I thought that normalize-space() 
should return a single character if any whitespace exists. It appears 
to return an empty string, at least with SAXON. I am not sure if it
internally with FOP because I don't get to see the intermediate fo

The bigger problem is that specifying the following 
on a template rule that matches an element with whitespace
<fo:inline white-space-collapse="false"> </fo:inline>


<fo:inline white-space-collapse="false"/>

rendering this solution completely useless.

I tried adding:

<xsl:preserve-space elements="fo:inline" />

It doesn't appear to help.

My current workaround is to pass through the whitespace in the 
source document. This works fine if the whitespace doesn't 
contain a CR/LF. Since others are generating this content, I am 
setting myself up for problems. I would like to replace any 
whitespace with a retained single character of whitespace. Can 
anyone help with this, offer an alternative, or point me to an 


David Morris

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread