LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives


XML-L Archives

XML-L Archives


View:

Next Message | Previous Message
Next in Topic | Previous in Topic
Next by Same Author | Previous by Same Author
Chronologically | Most Recent First
Proportional Font | Monospaced Font

Options:

Join or Leave XML-L
Reply | Post New Message
Search Archives


Subject: Re: PCDATA and CDATA
From: "Simon St.Laurent" <[log in to unmask]>
Reply-To:General discussion of Extensible Markup Language <[log in to unmask]>
Date:Tue, 19 Oct 1999 12:27:10 -0400
Content-Type:text/plain
Parts/Attachments:
Parts/Attachments

text/plain (44 lines)


At 07:30 PM 10/19/99 +0530, Anand Raman wrote:
>
> The difference between CDATA and PCDATA is really confusing me.The book i am
> referring to uses PCDATA to define the data type of element contents and
> CDATA to define the attribute values of elements.. I am sure this is not the
> true logic behind this.


The distinction is sort of arbitrary - CDATA is 'character data' while PCDATA
is 'parsed character data' - but it's one of those rules you have to follow.
XML 1.0 requires you to use PCDATA (actually, #PCDATA) in element type
declarations and CDATA in attribute declarations or the parser won't
understand
what you're doing.

>
> When i tried to define the element content to be of the type CDATA the xml
> parser complained.
>
> ../xml/cdata.xml: 8, 12: Element "<contents>" is not valid because it does
> not follow the rule, "(CDATA)".
>
> Excerpts of the simple XML page i wrote
>
>                  <!ELEMENT head (contents)>
>
>
>                  <!ELEMENT contents (CDATA)>]>



The parser is looking for a CDATA element in your document, and since there
isn't one, it's complaining.  Declare:

<!ELEMENT contents (#PCDATA)>

instead, and you'll have much better luck.

Simon St.Laurent
XML: A Primer, 2nd Ed.
Building XML Applications
Inside XML DTDs: Scientific and Technical
Sharing Bandwidth / Cookies
http://www.simonstl.com

Back to: Top of Message | Previous Page | Main XML-L Page

Permalink



LISTSERV.HEANET.IE

CataList Email List Search Powered by the LISTSERV Email List Manager