• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CDATA and PCDATA

 
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I went through this thread.
I have this example from w3school

If I change anyone of these element as CDATA, IE5 gives error :
"Content model is invalid. "
What is the practical use of CDATA ?
Has anyone ever used CDATA for element ??
Can we use it for element at all ??
Any help will be a appreciated.
Thanks in advance.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In DTD, there is no CDATA, only PCDATA. It's in the XML document instance where you can markup certain parts of text content with either PCDATA or CDATA blocks.
(PS. I didn't have time to check that so please correct me if I'm wrong)
 
R K Singh
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are right.
Elements can be only PCDATA. [ or in other words CDATA cant be used in dtd file.]
CDATA, I think, is suppose to be used in the xml file only for the data which you want not to be parsed. [exa: http://www.w3schools.com/xml/xml_cdata.asp]
I tried this and its working fine.

May I conclude it as following points:
1) Only "PCDATA" is used in dtd for element.
2) CDATA is used in xml file for the data which is not suppose to be parsed.
Thanks Lasse
 
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
CDATA is used very rarely in XML documents. Its generally used when you have a lot of textual content like ">","<", "'", "&", """.
The use of CDATA is very rare as it rarely supports teh purpose for which xml was created!!!. (user defined tags). Data inside teh CDATA section is not parsed by teh parser.
So CDATA is generally used when you need to include non-xml data or a lot of pre-defined entities mentioned above.
Elemnts cannot have CDATA as their model. BUT Elemnts can have CDATA sections to store data as shown in the above example by lasse!!!

I guess thats y we also include our code segments in the segment in javaranch so that the entire character set we type (along with white space) is preserved :-). It is not parsed by teh processor used to represent our documents. I guess CDATA is something similar to that !!!
hope this helps
hari
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic