How to output element containing HTML?

Subject: How to output element containing HTML?
From: "Peter Bryant" <pbryant@xxxxxxxxxxx>
Date: Wed, 25 Aug 1999 09:25:18 +1200
I have a database field that contains input entered by users.  This input
can have html in it.  Possibly poorly formed HTML!

I want to have the field as an xml element in my document.  When it is
processed through XSL I want the html to be inserted.

e.g.
XML:
<MESSAGE_BODY><![CDATA[ <A
HREF="http://domain.com";>http://domain.com</A> ]]></MESSAGE_BODY>

I'm pretty sure I need the CDATA since the data may not have the right
closing tags.

XSL wise I've tried:
<xsl:value-of select="MESSAGE_BODY" />
as well as copy-of, <xsl:text> and different output name spaces.

They all seem to result in the disapointing:
&lt;A HREF=&#34;http://domain.com&#34; &gt;http://domain.com&lt;/A&gt;

Is this a fundamental problem with XSL?  I have an element that may or may
not be well formed XML (user entered HTML).  I want to insert it directly
without any special quoting into a stylesheet output.  Now, I can get the
element to contain (possibly) poorly formed XML by wrapping it in CDATA, but
there seems no standard (STRIPDATA seems specific to LotusXSL) way of doing
this.

There are xsl elements that can almost do this.  xsl:comment would be
perfect except that it wraps the data in <!-- and -->.

The work around I found was to hack the my XSL processor's source.  I
created a new element
<infopop:html select="MESSAGE_BODY"> combining the code of the xsl:value-of
element and the xsl:comment elements.  I did this with the SAXON xsl
processor, not sure how to do this with LotusXSL.

Does anyone else agree that there should be an xsl directive that says:

"insert what I tell you directly into the output stream with no mucking
about with it please."

If so how does one lobby the xsl working group?

Peter Bryant



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


Current Thread