How can I preserve HTML using XSL?

How can I preserve HTML using XSL?

Post by Frank Sallia » Fri, 21 Sep 2001 18:01:18



Hi,

I'm having the following problem:

I'm using XSL to transform XML into HTML.
One of the XML fields I use contains (well-formed) HTML.

The XML is as follows:

- <NEWSITEM>
- <ID>1</ID>
- <TITLE>Some Title</TITLE>
- <BODY>
-
CDATA[
<p>This contains HTML</p>
<p><a href="somelink.asp">More.</a></p>
  ]]>
  </BODY>
  </NEWSITEM>

When using the following XSL,

...
<xsl:value-of select="BODY"/>
...

I get the following output

&lt;p&gt;This contains...
etc...

How can I avoid this?
I've already tried to use the attribute disable-output-escaping, but it makes no difference...

Can anyone help me out on this?

Thx,

 
 
 

How can I preserve HTML using XSL?

Post by wh » Fri, 21 Sep 2001 18:08:58


Why are you putting the HTML part of your XML document in a CDATA section?
Try removing it from the CDATA section, you should find that the literal
tags (i.e. the <p> <a> tags) get copied across automatically.

Wayne.


Quote:> Hi,

> I'm having the following problem:

> I'm using XSL to transform XML into HTML.
> One of the XML fields I use contains (well-formed) HTML.

> The XML is as follows:

> - <NEWSITEM>
> - <ID>1</ID>
> - <TITLE>Some Title</TITLE>
> - <BODY>
> -
> CDATA[
> <p>This contains HTML</p>
> <p><a href="somelink.asp">More.</a></p>
>   ]]>
>   </BODY>
>   </NEWSITEM>

> When using the following XSL,

> ...
> <xsl:value-of select="BODY"/>
> ...

> I get the following output

> &lt;p&gt;This contains...
> etc...

> How can I avoid this?
> I've already tried to use the attribute disable-output-escaping, but it

makes no difference...

- Show quoted text -

> Can anyone help me out on this?

> Thx,



 
 
 

How can I preserve HTML using XSL?

Post by Julian F. Reschk » Fri, 21 Sep 2001 18:13:11


If it's well-formed, there's no reason to escape it.

So remote the CDATA stuff, then later use xsl:copy-of instead of
xsl:value-of.



Quote:> Hi,

> I'm having the following problem:

> I'm using XSL to transform XML into HTML.
> One of the XML fields I use contains (well-formed) HTML.

> The XML is as follows:

> - <NEWSITEM>
> - <ID>1</ID>
> - <TITLE>Some Title</TITLE>
> - <BODY>
> -
> CDATA[
> <p>This contains HTML</p>
> <p><a href="somelink.asp">More.</a></p>
>   ]]>
>   </BODY>
>   </NEWSITEM>

> When using the following XSL,

> ...
> <xsl:value-of select="BODY"/>
> ...

> I get the following output

> &lt;p&gt;This contains...
> etc...

> How can I avoid this?
> I've already tried to use the attribute disable-output-escaping, but it

makes no difference...

- Show quoted text -

> Can anyone help me out on this?

> Thx,


 
 
 

1. xml to html using xsl: How to preserve xml encoding ?

How to make xsl stylesheet preserve encoding of source xml
document in generated html document ?

<xsl:output method="html" encoding="..."/>

I would like to use us-asci as default encoding but
some pages require iso-8859-1 or iso-8859-2.

--

366A 5DD7 7707 379C 9251  32AE C948 0BD2 7D99 688A  expires: 2003-01-25
I may disagree with the following *random epigram* :
The road to hell is paved with NAND gates.
                -- J. Gooding

2. GVP 33mhz 040/SCSI for 2000

3. XSL problem: preserve HTML tags?

4. LDAP

5. preserve entities (after XSL->HTML transformation)

6. High-res mono on a TV

7. Keyword xsl:preserve-space may not be used here.

8. selecting records where max value

9. HTML to HTML using XSL! (urgent)

10. preserving line breaks and HTML tags in XSLT

11. Preserving space around inline HTML tags?

12. preserving line breaks and HTML tags in text

13. Preserving < or > in output html