[thelist] XML > XSL > HTML question

Jonathan Chard jonathan at familygenetix.com
Fri May 25 04:50:27 CDT 2001

Hi Kerin,

>A couple of parts of my XML file hold large chunks of text. When I view the
>XML file, I can see that the text (in CDATA[]) is nicely formatted with
>carriage returns. Obviously though, XSL strips out all extraneous
>whitespace, so I just end up with these *huge* blocks of text with no

>Now, I know how to get XSL to preserve whitespace, but thats no good - the
>text comes through still formatted, but obviously newline characters mean
>nothing to HTML - what I need to do is convert the newlines to <br>s, or
><p>s, or whatever.

>So, how can I do this with XSL? Convert newlines to <br> tags for the
>tree? This is driving me nuts!

Guess noone knows! TBH I find the CDATA sections pretty confusing and try to

You might want to check out http://www.dpawson.co.uk/xsl/cdata.html. This
seems to suggest that the CDATA section is not parsed at all, which means
it's not possible to do what you want. I think that you should only use a
section when you've got a lot of text that you don't want to escape, is this
true in
your case?

My only suggestion is that you parse your blocks of text *before* they get
stuck in your
database, so that when they're pulled out, they're already in the correct

You could also consider not using a CDATA section at all and using the
<xsl:copy-of> tag
to put the content directly in your web page.

But I'm just reiterating the points already made in the above link. Sorry I
can't be of more help,
I'm only a beginner too... I think it's just nice to know sometimes that
people are listening (hence
my response). Just wish I had a single suggestion to help the guy a while
ago that had a question
about if statements in an a stylesheet...

Jon Chard.

More information about the thelist mailing list