!CDATA

B

Bill

Hi

I'm learning XML by myself and as you'll see I'm at the very beginning so be
patient with me please.

Assertion: <![ CDATA[ ... ]]> can be used to escape controls in a xml
document.

So if I write the following code :
<mycode>

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>
it'a a try
</title>
</head>
<body>


<p> This is the synopsis for the <![CDATA [ <!DOCTYPE root_name DTD_URI
subsets ...> ]]> where blah blah blah </p>

</body>
</html>

</mycode>

If I display that in FF I obtain:

This is the synopsis for the ]]> where blah blah blah


I don't understand. I unmistakably made a mistake but where ?


Thanks
 
J

Joseph Kesselman

Which parser are you using? It sounds like either it's broken, or what
you think you've written isn't what you've actually written.

General statement of principle principle: <!CDATA[]]> should be avoided
except as a kluge to help humans copy-and-paste stuff into a hand-edited
XML file without having to manually escape the &lt;, &gt;, and &amp;
characters. That's all it does for you, really. No XML tool should ever
generate <!CDATA[]]> sections; no tool should ever insist upon them.
 
J

joshua.davies

<mycode>

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<p> This is the synopsis for the <![CDATA [ <!DOCTYPE root_name DTD_URI
subsets ...> ]]> where blah blah blah </p>

Remove the space between the CDATA and the "[" character:

subsets ...> ]]> where blah blah blah </p>

I'm surprised it didn't complain before that, though - the XML
declaration and DOCTYPE should go before the root element:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<mycode>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
J

Joseph Kesselman

Remove the space between the CDATA and the "[" character:

Good point; I should have caught that but I assumed it was a typo in the
post rather than in the user's file. More fool me...
 
B

Bill

Hi Joshua

I've been searching for that root element you mention and found that I
introduced a bad code snippet in my question.

That is, I used a common practice in forums which is to start the snippet
with a delimiter as <my snippet> and </mysnippet>. I realized that using
that practice in a XML forum is a very bad idea !

That's why the "root element" you stated fooled you and me. My snippet
starts with <mycode> and ends with </mycode> which are actually not markers
(in XML they are but... you understand me I know) . I should have used <!--
mycode --> instead. My big mistake, sorry. Anyways, your observation was
correct, I removed the space you told me and it works.

I have another "big" question.

Let's say you have a huge mysql database and you want to filter it some way.
Will you filter it using mysql language and produce a xml database to be
further processed or will you use the whole mysql db ?

I feel that it's not productive to translate the whole thing only to process
it in xml. Then, what is the real use of xml databases if not only to store
some transactions results to be published ?


Thanks

<mycode>

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<p> This is the synopsis for the <![CDATA [ <!DOCTYPE root_name DTD_URI
subsets ...> ]]> where blah blah blah </p>

Remove the space between the CDATA and the "[" character:

subsets ...> ]]> where blah blah blah </p>

I'm surprised it didn't complain before that, though - the XML
declaration and DOCTYPE should go before the root element:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<mycode>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top