Re: Preserving output formatting after XSL transformation

Subject: Re: Preserving output formatting after XSL transformation
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 8 Nov 2000 16:05:20 -0700 (MST)
Jesse Ehrenzweig wrote:
> I'm wondering how to preserve the formatting of my transformed HTML output
> text.... instead of text appearing like so:
> 	<table>
> 	<tr>
> 	<td>
> 	....
> I would like it to appear like this instead:
> 	<table>
> 		<tr>
> 			<td>
> 				...

I think you're asking for whitespace-only text nodes in your stylesheet
tree (more specifically, the whitespace appearing between the tags for
literal result elements) to be preserved. XSLT does not consider such
space significant and will discard it; you have no control over it. So you
have two options:

1. Rely on indent="yes" in the xsl:output element. Processor dependent.
2. Rely on indent="no" and explicitly create text nodes with the
whitespace you want:

<xsl:text>    </xsl:text><table>
<xsl:text>         </xsl:text><tr>
<xsl:text>              <xsl:text><td>


I'd choose (1). :)

   - Mike
Mike J. Brown, software engineer at         My XML/XSL resources: in Denver, Colorado, USA 

 XSL-List info and archive:

Current Thread