RE: [xsl] Formatting issue with HTML and TEXT output method

Subject: RE: [xsl] Formatting issue with HTML and TEXT output method
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 17 Jul 2008 09:14:53 +0100
I'm having trouble understanding the question, but I suspect that what you
are looking for is that newlines in the XML should render as newlines when
the HTML is displayed in the browser. that is, if your input is

<p>
THREE
BLIND
MICE
</p>

then you want to generate HTML is such a way that the user sees three lines
of text on the browser screen.

As I expect you know, HTML treats a newline as equivalent to a space, so the
normal way to do this is to replace newlines by <br/> elements. That's easy
in XSLT 2.0 using <xsl:analyze-string>, it's a bit harder in 1.0 (google for
"XSLT 1.0 replace newline by <br>" which gives you 39,000 hits).

Another approach is to generate the <pre> tag in HTML, which causes newlines
to be rendered as newlines.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Senthilkumaravelan K [mailto:skumaravelan@xxxxxxxxxxxxxx] 
> Sent: 17 July 2008 00:39
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Formatting issue with HTML and TEXT output method
> 
> Hi All,
> We have xml
> <note>
> <cond>
> <html>
> <body>
> <p align="center">
> TESTTESTTESTTESTTESTTESTTESTTESTTEST
> TESTTESTTESTTESTTESTTESTTESTTESTTEST
> TESTTESTTESTTESTTESTTESTTESTTESTTEST
> </p>
> <p align="center">
> TESTTESTTESTTESTTESTTESTTESTTESTTEST
> TESTTESTTESTTESTTESTTESTTESTTESTTEST
> TESTTESTTESTTESTTESTTESTTESTTESTTEST
> </p>
> </body>
> </html>
> </cond>
> <note>
> 
> When we write xslt one with "html" as output method and text 
> as output method.
> 
> for html out method am using
> <xsl:value-of select="//cond">
> 
> text output method
> <xsl:copy-of select="//cond">
> 
> 
> How to make the text xslt output like formatted text output 
> pretty with alignment.
> 
> Any idea would of great help.
> 
> Thanks
> Senthil

Current Thread