Solved

Very basic XML/DTD CDATA question

Posted on 2004-08-19
2
941 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
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…
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.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

914 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now