Re: [xsl] CDATA or escape in the result tree problems

Subject: Re: [xsl] CDATA or escape in the result tree problems
From: Abel Braaksma <>
Date: Mon, 30 Oct 2006 09:49:58 +0100
Kjetil Kjernsmo wrote:
Hi all!

select="./ct:value/*/*"/> put into a CDATA section, or perhaps escaped.

Can it be that the textarea nodes are also in the "ct" prefixed namespace? Or do you have another namespace attached to the textarea elements? This namespace must be used in the cdata-section-elements as well.

Any ideas why this is so? Is it because I import this stylesheet? Is it
a weakness with libxslt? Or have I misunderstood

Now, I assume that a CDATA section is The Right Way To Do It, but I
don't know if TinyMCE thinks likewise. I have seen it simply escape <
and > to &lt; and &gt;, and still submit it back as proper HTML.
So, I figured, maybe I should be more pragmatic about it (I'm normally
such a purist), and just escape them too...

If you are a purist, you don't need to worry about the way it is encoded in XML, as from the XML point of view, this does not matter.

The problem is that I allow users to insert pretty much any HTML in
there. My application does some validation and a bit of cleanup, so it
should be valid, but that makes is slightly harder to write the
template that it should match on if I were to just escape the HTML. If
the cdata thing above seems hard to do, I would be happy for advices on
how to do this as well.

For XML (and so: XML applications) the following three are equal:

<textarea>&lt;sometag /></textarea>
<textarea><![CDATA[<sometag />]]></textarea>

Which means, to some extend, that using CDATA-sections on the output is not needed. Unless of course you don't use XML tools to parse this result-xml, but you use literal string comparison. I recommend sticking to XML tools, so that you do not have to worry about he way it is encoded.

Of course, this does not give you a resolution for getting the CDATA sections in there. I don't use them often, but I believe that the way you tried it is the right way. Which makes me think it to be a problem with LibXSLT.

-- Abel Braaksma

Current Thread