You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dominique Devienne <DD...@lgc.com> on 2002/08/12 23:56:51 UTC

[OFF-TOPIC] XML Question

Can someone explain me the difference between the two lines of XML below:

<sometag><![CDATA[some textual content]]></sometag>
<sometag>[CDATA[some textual content]]</sometag>

I use the second form in one of my document, and everything seem to work
fine, but by looking at the online doc from <cvschangelog>, I see the output
using the first form...

What the difference? Does it matter for the DTD?
I use <!ELEMENT sometag (#PCDATA)> for that element.

Thanks for any help. --DD

PS: The XML spec is a little obtuse to me... And I did look at it!

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [OFF-TOPIC] XML Question

Posted by Gordon Tyler <go...@sitraka.com>.
From: "Dominique Devienne" <DD...@lgc.com>

> Can someone explain me the difference between the two lines of XML below:
>
> <sometag><![CDATA[some textual content]]></sometag>
> <sometag>[CDATA[some textual content]]</sometag>

See http://www.w3.org/TR/2000/REC-xml-20001006#sec-cdata-sect.

The first line describes an element "sometag" which has a CDATA section
child containing "some textual content". The second line describes an
element "sometag" which has a text child containing "[CDATA[some textual
content]]". In other words, the first line is the correct way to use a CDATA
section.

CDATA sections allow you to escape text that would otherwise be interpreted
as markup (e.g. <foo>).

> What the difference? Does it matter for the DTD?
> I use <!ELEMENT sometag (#PCDATA)> for that element.

Normal text and CDATA sections both qualify as PCDATA. However, you may need
to treat CDATA sections specially depending on the parser and API you use.

> PS: The XML spec is a little obtuse to me... And I did look at it!

It is rather. I have to read very slowly and carefully ;)

Ciao,
Gordon



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>