[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: CDATA or escape in the result tree problems

Subject: Re: CDATA or escape in the result tree problems
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 30 Oct 2006 09:49:58 +0100
escape equal xml
Kjetil Kjernsmo wrote:
Hi all!

<xsl:copy-of
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
cdata-section-elements?

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>
<textarea>&#x3c;&#x73;&#x6F;&#x6D;&#x65;&#x74;&#x61;&#x67;&#x20;&#x2F;&#x3e;></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.

Cheers,
-- Abel Braaksma
  http://www.nuntia.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.