aspose file tools
The moose likes Product and Other Certifications and the fly likes CDATA and #PCDATA Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Product and Other Certifications
Reply Bookmark "CDATA and #PCDATA" Watch "CDATA and #PCDATA" New topic
Author

CDATA and #PCDATA

Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 645
Can anyone let me know what is the exact difference b/w #PCDATA and #CDATA and why #CDATA is not allowed as the content for an element?
As far as i understand, #PCDATA will be parsed by the parser and hence cannot contain any mark-up text like --- < > ' ". I also understand that the parser resolves any of the entity references contained within the #PCDATA that it parses.
What about #CDATA?
Anyone please correct me for any mistakes and clarify
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1126
The keywords #PCDATA and CDATA are pretty much equivalent. One is used for elements and one for attributes. Why are they named differently? Good question.
The only characters which are not allowed in #PCDATA are < and & (unless it represents an entity reference).
The same applies to CDATA. In addition, it can't have " or ', depending on the character that delimits the attribute.
One difference between the two is the fact that #PCDATA is a content model, the only one that specifies what the character stream looks like. CDATA, on the other hand, is one of several ways to restrict the attribute's content.
Cheers,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Copied from w3schools
PCDATA
PCDATA means parsed character data.
Think of character data as the text found between the start tag and the end tag of an XML element.
PCDATA is text that will be parsed by a parser. Tags inside the text will be treated as markup and entities will be expanded.

CDATA
CDATA also means character data.
CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded.
Samba Siva Rao Potla
Greenhorn

Joined: May 14, 2002
Posts: 14
Hi Zhang,
You have given below text.
"CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded. "
But..
The internal entity references as an attribute (which is of type CDATA) value will be expanded.
Please let me know if am wrong.
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 645
Yeah! Not only the internal entity references, but also the external parsable entity references will be parsed and the value substituted by the parser when entities are used for CDATA of the attributes;
"Only text inside a CDATA SECTION is ignored by the parser." - from w3schools
I guess the CDATA section is the catch here and not the CDATA type used for the attributes;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CDATA and #PCDATA
 
Similar Threads
CDATA and PCDATA
Sample DTD Question #1
difference between CDATA and PCDATA in XML
Clarification about CDATA
difference between #PCDATA and CDATA?