• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

#CDATA and #PCDATA

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

some of the xml articles say that Element's value or Attribute's value type could #CDATA or #PCDATA. i do the follwoings:
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#CDATA)>
<!ELEMENT from (#CDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
</note>
when validated it with XML spy, gives me error saying the file is now well-formed. but when data type is defined as being #PCDATA type, it's FINE.
NOW, WHAT'S WRONG with #CDATA? what's the difference between #CDATA and #PCDATA in terms of their use? could anyone please explain?
thanks.
himal
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Himal,
An Element can contain other elements or text.
#PCDATA stands for Parsed Character Data and an Elements data (Elements and Text) must be parsed so therefore it must be #PCDATA if the elements contents is text:
<!ELEMENT name (#PCDATA)>
#CDATA stands for Character Data and is NOT parsed. Attributes are not parsed by the parser so they must be referred to as Character Data.
<!ATTLIST name first CDATA >
I hope this helps and maybe someone can add to this!
[ September 20, 2002: Message edited by: Aaron O'Brien ]
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Himal:
#PCDATA (parsed character data)is for elements, CDATA (note: no # sign!)is for attributes. See below:
<!ELEMENT sample (#PCDATA) >
<!ATTLIST sample version CDATA "1.0" >
HTH
 
Aaron O'Brien
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jim!
 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys. appreciate your clarification.
himal
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic