new line

D

David Schwartz

I'm generating text files containing html to be re-used elsewhere.
Naturally, the xsl code sits on different lines in the .xsl file.
However, sometimes the new lines are reflected in the resulting html
and sometimes it's not so the results of one line of xsl just
continues from the results of the previous xsl line on the same output
file line.

How can I control this more precisely?

TIA,
David
 
J

Joseph Kesselman

David said:
How can I control this more precisely?

XSLT has to assume that whitespace may be meaningful in your output
document, so in general it doesn't generate any unless you tell it to
either by copying the newline from your source document or by explicitly
writing one out with <xsl:text>
</xsl:text>. (Or <xsl:text>
</xsl:text> or
<xsl:text>
</xsl:text>, which use character references to express
the line break and may be a bit easier for other folks to read.)

If you are absolutely certain that spurious whitespace won't harm your
documents, you can also try turning on indentation in xsl:eek:utput. In
some processors you will also have to use a nonstandard feature to tell
the system how much indentation you want per level. (Xylem assumes 0
unless you tell it otherwise).

If you're getting whitespace where you didn't want it, that's a
different set of problems; normalize-space() and xsl:strip-space may be
helpful knobs to tweak in that case.
 
D

David Schwartz

If you are absolutely certain that spurious whitespace won't harm your
documents, you can also try turning on indentation in xsl:eek:utput.

Thanks Joe. I had indent turned on which is one of the reasons I was
surprised by what I was seeing. It seemed to be somewhat random so not
sure what was going on. However, <xsl:text>
</xsl:text> is working
with Xalan just fine.

Thanks again.
 
J

Joseph Kesselman

David said:
Thanks Joe. I had indent turned on which is one of the reasons I was
surprised by what I was seeing. It seemed to be somewhat random

Probably not random at all. Remember that indentation will only be added
when there is no adjacent text value it could get confused with, just as
XSLT will ignore whitespace in the stylesheet except when there's
adjacent text it might be part of. If you've explicitly output any text
content, indent won't break the line at that point.

You might want to figure out whether that's what was making the
difference, just as a learning exercise. But...
> <xsl:text>
</xsl:text> is working with Xalan just fine.

Glad to help.
 

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,999
Messages
2,570,247
Members
46,844
Latest member
JudyGvh32

Latest Threads

Top