• 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 type

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:
An attribute of CDATA type can contain any character if it conforms to well formedness constraints.. I am not clear about "well formedness constraints". What Kind of "well formedness constraints" should it to conform to?
Could someone help me out?
Thanks,
Nancy
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Nancy,
According to XML1.0, "The string type may take any literal string as a value". The following is the production for attribute values:
[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"
Assuming this DTD:
<!ELEMENT a EMPTY>
<!ATTLIST a
b CDATA #REQUIRED>
the following documents are VALID:
<a b="x>y"/>
<a b="x'y"/>
<a b='x"y'/>
But the following documents are NOT VALID:
<a b="x<y"/>
<a b="x&y"/>
The question often asked is: what is the difference between CDATA and NMTOKEN? Let's assume you want to create an attribute href for URLs. A URL contains a // which is not a name token. So you cannot use the NMTOKEN type for href. You will have to use:
<!ELEMENT a EMPTY>
<!ATTLIST a
href CDATA #REQUIRED>
Now the value of href can contain a //.
Another example: an attribute of CDATA type can contain a white space. An attribute of type NMTOKEN cannot contain a white space.
The best way to learn all this is to experiment with small documents and a validating parser.
Good Luck!
----
Joel Amoussou
IBM XML Certification Practice Test
http://www.xmlmentor.net/xmlexamsim.htm
reply
    Bookmark Topic Watch Topic
  • New Topic