cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Whitespace in HTML Output from XSL

dirk.waldenmaie
1-Newbie

Controlling Whitespace in HTML Output from XSL

Hi,

we have problems with HTML files we got out of E3 because the complete file
is in one line and the folling programs cannot handle that file.

Has anybody an idea how you can influence the whitespace in a HTML file that
is output of a XSL Stylesheet. (E3)
I don't mean the whitespace inside the elements, I mean that one between the
elements.

Or has E3 something like the "Limit Output record length" function in Epic
for the xml files?

Regards,
Dirk


10 REPLIES 10

In your XSLT script, you could try creating a template like
<xsl:template name="new-line">
<xsl:text>
</xsl:text>
</xsl:template>
and then placing a <xsl:call-template name="new-line"/"> at various templates
for nodes where you want line breaks.

You could also try using the indent attribute of <xsl:output>, which will make your output "pretty", with newlines, indented elements, etc. Use something like this:

<xsl:output method="html" indent="yes"/">

(Include other output attributes as necessary.)

--Clay

I already use the indent attribute. But it seems that E3/Xalan doesn't care
about this.

Dirk

That's strange. I don't use E3, but I use Xalan both as a standalone processor and as Epic's XSLT engine, and while the indent attribute doesn't actually indent nested elements from the left margin, it does insert line breaks where you would expect them.

Does Ed's suggestion for manually inserting line breaks work for you?

No, I get everything in one line.

Dirk

In that case, I guess the problem must be somewhere downstream from the XSL processing. I don't know how E3 works at all, but I suspect the line breaks are there in the XSL output, but something further down the processing pipeline is stripping them out.

You could test this theory by applying your XSLT stylesheet to your content outside of E3 to see what you get. Xalan has a command line interface to perform simple transformations like this. See http://xml.apache.org/xalan-j/commandline.html for details. Transform the document and then look at the output to see if the linebreaks are there. If they are, then it's definitely something E3 is doing to the content after the XSLT transformation that's removing them.

I don't know anything about E3 either, but are you sure you can't use set
outputrecordlength=XX in a pubrc file in your doctype directory and get the
lines to end at the XX value in your output?

Good suggestion. But could not see any influence of this setting towards the
XSL Output.

Dirk

Hmmm. Just shooting in the dark here.
Does your XSLT stylesheet contain an <xsl:strip-space> element at some high
level or something? When you tried my original suggestion of
<xsl:template name="new-line">
<xsl:text>
</xsl:text>
</xsl:template>

You did put a carriage return as the contents of <xsl:text></xsl:text>,
right?

If that still didn't work, then some other application must be stripping
your whitespace.

> Hmmm. Just shooting in the dark here.
> Does your XSLT stylesheet contain an
> <xsl:strip-space> element at some high
> level or something? When you tried my
> original suggestion of
> <xsl:template name="new-line">
> <xsl:text>
> </xsl:text>
> </xsl:template>

No.

> You did put a carriage return as the contents of
> <xsl:text></xsl:text>, right?

Right.

> If that still didn't work, then some other application
> must be stripping your whitespace.

I think we found another E3 feature.

Dirk
Announcements