Problem with preserving the format of xml element during xslt

L

longinus

Hello,

I have following element in XML:

<Elem><![CDATA[dsdfhdfh<BR/>dfshdfhdfh
dddd
dddd<BR/>dsfhfdh<BR/>]]></Elem>

which is preformatted and i would like to have the format on the
webpage(html) as well.

In XSL-file there is a following instructions:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
....>
<PRE>
<xsl:value-of select="Elem> diable-output-escaping="yes"/>
</PRE>

after XSLT preformatted text should preserve format on the webpage.

What i get is:

dsdfhdfh
dfshdfhdfh
dddd dddd
dsfhfdh

Where is the problem?

Thanks,
longinus
 
A

Anton Spaans

longinus said:
Hello,

I have following element in XML:

<Elem><![CDATA[dsdfhdfh<BR/>dfshdfhdfh
dddd
dddd<BR/>dsfhfdh<BR/>]]></Elem>

which is preformatted and i would like to have the format on the
webpage(html) as well.

In XSL-file there is a following instructions:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
...>
<PRE>
<xsl:value-of select="Elem> diable-output-escaping="yes"/>
</PRE>

after XSLT preformatted text should preserve format on the webpage.

What i get is:

dsdfhdfh
dfshdfhdfh
dddd dddd
dsfhfdh

Where is the problem?

Thanks,
longinus

(i assume that there are some typo's in your original post)

What do you want to see?
If you do 'view source' on the html you probably will see this:
========================
dsdfhdfh<BR/>dfshdfhdfh
dddd
dddd<BR/>dsfhfdh<BR/>
========================

But in html, inside the browser, this will be shown as
========================
dsdfhdfh
dfshdfhdfh
dddd dddd
dsfhfdh
========================

If you want to have this shown inside the browser:
========================
dsdfhdfh<BR/>dfshdfhdfh
dddd
dddd<BR/>dsfhfdh<BR/>

========================
then don't use <PRE>, but use an enclosing <XMP> element instead in your XSL
(or <TEXTAREA>)

-- Anton.
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top