cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan Sundin" <>
Subject RE: <![CDATA[]]>
Date Tue, 21 Mar 2000 07:13:12 GMT
> On Mon, Mar 20, 2000 at 05:04:22PM +0100, Jan Sundin wrote:
> > I'm using a <![CDATA[]]> element that holds HTLM-tags, i do not want the
> > content of the element to be escaped or modified in any way.
> > But when using Cocoon 1.7.1-dev, xalan_0_20_0, xerces_1_0_3. A
> > <![CDATA[<DIV>]]> gets output as "&lt;DIV&gt;". I had expected
> to get <DIV>.
> >
> > Have i missunderstood something?
> Yes, I believe you have. CDATA is needed if you need characters such
> as "<", ">", and "&" preserved. I find it most useful in xsp pages (as
> described in the xsp intro documentation):
>   <xsp:logic><![CDATA[
>     int i;
>     for (i=0; i < 10; i++) { } // the "<" would generate an error
> w/o CDATA
>   ]]></xsp:logic>
> rather than:
>   <xsp:logic>
>     int i;
>     for (i=0; i &lt; 10; i++) { }  // Note the use of "&lt;"
>   </xsp:logic>
> I don't know what you're trying to accomplish, but I suspect that
> what you really need to do is use "<DIV/>" (to turn it into a
> valid, empty xml tag). You'll likely find that cocoon strips
> out the extra "/" before it reaches the browser.

I realize i could have explained this better the first time.
I have a Cocoon-producer creating some XML-stuff that then gets transformd
into HTML. For some reasons i want to embed HTML-tags in the XML file (i
know this isnt the "right thing" to do, but some of the data i want to
display is already in HTML-form). To preserve characters such as < > & i
embed this HTML-fragmet in CDATA, just like you do in your example above.

Example, the following XML-file:

	<?xml version="1.0"?>
	<?xml-stylesheet href="jan.xsl" type="text/xsl"?>
	<?cocoon-process type="xslt"?>
	<samples><![CDATA[<DIV id="collapse"></DIV>]]>

and the stylesheet:

	<?xml version="1.0"?>
	<xsl:stylesheet version="1.0"
	<xsl:template match="samples">

generates the output:

	<html>&lt;DIV id=&quot;collapse&quot;&gt;&lt;/DIV&gt;
Is this really correct?

I expected to get :
	<html><DIV id="collapse"></DIV>;

Jan Sundin

View raw message