Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Very basic XML/DTD CDATA question

Posted on 2004-08-19
2
Medium Priority
?
947 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 300 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

971 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