xsl-list
[Top] [All Lists]

Re: Translating the contents of a XML field as HTML...

2003-01-10 04:50:32

This is a FAQ.

Basically you have an input that looks like

<xxx><![CDTDA[<b>example text</b>]]></xxx>

or, equivalently


<xxx>&lt;b>example text&lt;/b></xxx>


XSLT is not really designed to cope well with such input.
The usual advice, if you can control your input format, is do not start
from there, it's much better if you can have input that looks like

<xxx><b>example text</b></xxx>

In which case you simply need
<xsl:copy-of select="xxx/node()"/>



If you can't change your input form you have three choices,

* try to use the string handling features of XSLT to recognise
the markup and create the necessary elements, doable in simple cases,
but not much fun.

* See if your XSLT system has an extension function that would allow you
to pass the string to an XML parser (or an html parser that returns sax
events)

* or use

<xsl:value-of disable-output-encoding="yes" select="xxx/node()"/>

which will sort of seem to work if your XSLT processor supports d-o-e.
Using d-o-e is evil (search the archives of this list for 1001 reasons
why:-) but in cases where the input language is badly (or unhelpfully)
designed, it sometimes comes to the rescue.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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