Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > !CDATA

Reply
Thread Tools

!CDATA

 
 
Bill
Guest
Posts: n/a
 
      12-11-2007
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


 
Reply With Quote
 
 
 
 
Joseph Kesselman
Guest
Posts: n/a
 
      12-11-2007
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.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
 
joshua.davies@travelocity.com
Guest
Posts: n/a
 
      12-11-2007
On Dec 12, 11:56 am, "Bill" <billla...@hotmail.com> wrote:
> <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:

<p> This is the synopsis for the <![CDATA[ <!DOCTYPE root_name DTD_URI
> 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">
 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      12-11-2007
wrote:
> 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...


--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
Bill
Guest
Posts: n/a
 
      12-12-2007
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

<> a écrit dans le message de news:
66637ff0-7d6f-4012-a3ea-a8cbc203bc57...oglegroups.com...
> On Dec 12, 11:56 am, "Bill" <billla...@hotmail.com> wrote:
>> <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:
>
> <p> This is the synopsis for the <![CDATA[ <!DOCTYPE root_name DTD_URI
>> 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">



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57