controlling whitespace with output method=html

A

Andy Fish

Hi,

I was wondering if there is any way to control the whitespace (specifically
line breaks) that are generated using Xalan XSLT processor with output
method=html.

I find it sometimes generates a line feed character before a <br>, even
where I have no whitespace between the <br /> and the next HTML tag in my
xsl. This wouldn't normally be a problem but it seems that sometimes this
upsets IE and causes it to put an extra blank line in the HTML page.

Andy
 
P

Patrick TJ McPhee

% I was wondering if there is any way to control the whitespace (specifically
% line breaks) that are generated using Xalan XSLT processor with output
% method=html.

In general, if you put all literal text in xsl:text elements, the processor
will spit out only what you tell it to. If you emit literal text which is
not wrapped up in xsl:text, the processor will typically emit all the text
nodes in the same template, including the new-lines. This may be the
problem you're having.
 
A

Andy Fish

Patrick TJ McPhee said:
% I was wondering if there is any way to control the whitespace (specifically
% line breaks) that are generated using Xalan XSLT processor with output
% method=html.

In general, if you put all literal text in xsl:text elements, the processor
will spit out only what you tell it to. If you emit literal text which is
not wrapped up in xsl:text, the processor will typically emit all the text
nodes in the same template, including the new-lines. This may be the
problem you're having.

the problem I'm having is that even when I jam up the HTML fragment in the
xsl file with no whitespace at all, it still comes out with line breaks in.
Normally this wouldn't matter with HTML but in this specific case it is
making a difference to the way IE renders the page.

however, the <xsl:text> did provide a workaround. I replaced <br> with

<xsl:text>&lt;br&gt;</xsl:text>

and now the extra whitespace is gone. It seems like an ultra-bodge but there
are only a couple of places I need to use it so I'll have to be pragmatic
about it.

Thanks

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top