xsl-list
[Top] [All Lists]

RE: Preserve Whitespace with Mixed Content (Text and Tags)

2005-05-12 15:20:35
Are you using Microsoft's XSLT processor? If so, the best advice is don't:
it removes the whitespace before you get any chance in your stylesheet to
preserve it.

The other question is, do you want white space in the HTML "source", or
white space on the browser screen? They aren't the same thing: the browser
collapses multiple spaces and newlines into a single space. To convert
multiple spaces in the XML into multiple spaces on the screen, you may need
to change them into non-breaking spaces (But you're using <pre> tags, so I
guess you know that).

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: James(_dot_)Whitehead-1(_at_)ksc(_dot_)nasa(_dot_)gov 
[mailto:James(_dot_)Whitehead-1(_at_)ksc(_dot_)nasa(_dot_)gov] 
Sent: 12 May 2005 22:56
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Preserve Whitespace with Mixed Content (Text and Tags)

Hello,
Message-Id: 
<iss(_dot_)609c(_dot_)4283d0df(_dot_)801be(_dot_)1(_at_)kmail(_dot_)ksc(_dot_)nasa(_dot_)gov>

I am generating html from an xml document, and would like to 
preserve white space inside tags that contain both text and 
other tags, such within these THD tags:
<THD>               <HL1>Load</HL1>            <HL1>Height</HL1></THD>

Ideally, I would like to end up with:
<pre>               Load                 Height</pre>
or, better:
<pre>               <b>Load</b>                 <b>Height</b></pre>

I have tried many xsl variations using using 
<xsl:preserve-space... and <pre> tags, but am unable to come 
up with a way to preserve the spaces (and line feeds) with 
this mixed content.  I always seem to end up with something 
like either:
<pre>Load Height</pre>
or:
<pre>LoadHeight</pre>

I have no trouble preserving white space if the inner tags 
are removed, such as here:
<THD>               Load                 Height</THD>
The <HL1> tags are not the only tags that might appear inside 
the <THD> tags -- a large number of other nested tags might 
show up as well. I do not have any control over the original 
source xml document. 

Can anyone please point me in the right direction?  I have 
searched Dave Pawson's FAQ, the XSL-List archives, and other 
some oft-cited web references, and if the answer is in one of 
these, I haven't seen it.  

Thank you for any information you can provide.

Regards,

Jim

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--