?
Solved

Very basic XML/DTD CDATA question

Posted on 2004-08-19
2
Medium Priority
?
946 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

718 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