Solved

Very basic XML/DTD CDATA question

Posted on 2004-08-19
2
942 Views
Last Modified: 2013-11-19
I don't want the text in the testchild node to be parsed.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE test [
  <!ELEMENT test (testchild)>
  <!ELEMENT testchild (#CDATA)>
]>
<test>
<testchild>test once more.</testchild>
</test>

This throws an error when I try to view the file in IE 6.

The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Content model is invalid. Error processing resource 'file:///C:/Documents and Settings/e58012/My Documents/test.xml'. Line 4, Position 24
  <!ELEMENT testchild (#CDATA)>

According to this site, though, CDATA is legal for a DTD element type.  http://www.thescarms.com/XML/DTDTutorial.asp

Here's their example:

<?xml version="1.0"?>
<!DOCTYPE message [
  <!ELEMENT message (to,from,subject,text)>
  <!ELEMENT to         (#CDATA)>
  <!ELEMENT from      (#CDATA)>
  <!ELEMENT subject (#CDATA)>
  <!ELEMENT text     (#CDATA)>
]>
<message>
  <to>Dave</to>
  <from>Susan</from>
  <subject>Reminder</subject>
  <text>Don't forget to buy milk on the way home.</text>
</message>

Am I missing something?
0
Comment
Question by:slacksoft
2 Comments
 
LVL 22

Accepted Solution

by:
NovaDenizen earned 75 total points
ID: 11843384
That site is just wrong. :)

You can't have a '#CDATA' content type in an <!ELEMENT> tag.  '#PCDATA' is fine, though.

However, using '#PCDATA' won't stop you from using CDATA blocks in your data, like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE test [
  <!ELEMENT test (testchild)>
  <!ELEMENT testchild (#PCDATA)>
]>
<test>
<testchild><![CDATA[ test once more. <<< blah <hello> <goodbye> </hello> ]]></testchild>
</test>

0
 
LVL 2

Author Comment

by:slacksoft
ID: 11843639
Dang.  

Thanks anyway.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question