controlling whitespace with output method=html

Andy Fish

Usenet Archive
Joined
Dec 30, 2002
Messages
605
Reaction score
0
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
 

Patrick TJ McPhee

Usenet Archive
Joined
Apr 2, 2000
Messages
269
Reaction score
0
% 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.
 

Andy Fish

Usenet Archive
Joined
Dec 30, 2002
Messages
605
Reaction score
0
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
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top