xsl-list
[Top] [All Lists]

RE: output of cdata within xsl:value-of select

2002-12-02 10:30:25

You are most likely viewing the output as HTML and not as the text
itself - HTML will collapse the spaces down to a single space.

To show if this is the case, wrap the data with <pre> and try it again:

Your Message is: <br/>
<pre>
  <xsl:value-of select="TGMSG"/>
</pre>

cheers
andrew

-----Original Message-----
From: Natarajan, Chokkalingam 
[mailto:chokkalingam(_dot_)natarajan(_at_)eds(_dot_)com]
Sent: 02 December 2002 16:54
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] output of cdata within xsl:value-of select


Folks,  I have a question with regards to output of CDATA 
value within a
xsl:value-of select in a XSL file. I have an XML data coming 
to an XSL file
as a data stream and the XSL contains the format in which the 
XSL should be
displayed.

The fragment of code in my XML file is:

<TGMSG><![CDATA[This is a test message, hopefully this will go through
      line2
      line3
      line4
      line5
      line6 end.]]>
</TGMSG>

There are line breaks (carriage returns) within the CDATA 
section. This will
pass through without any hassle while XML parsing.

The fragment of code in my XSL file is: 

Your Message is: <br/>
<xsl:value-of select="TGMSG"/><br/>

But when I pass the above XML data input to the XSL file, the 
output comes
in without the line breaks. Like this:

This is a test message, hopefully this will go through line2 
line3 line4
line5 line6 end.

But I want the output to come out like this (in other words, I want to
preserve the carriage returns / line breaks that I get within 
the CDATA, and
print them out using my XSL file):

This is a test message, hopefully this will go through 
line2 
line3 
line4 
line5 
line6 end.

What should I do to achieve this? I need to perform this only 
by modifying
the XSL file. If anyone has encountered this before or know 
the solution,
please let me know. Thanks in advance.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>