Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

CDATA and PCDATA

 
Ranch Hand
Posts: 5397
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: 5397
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic