!CDATA

Discussion in 'XML' started by Bill, Dec 11, 2007.

  1. Bill

    Bill Guest

    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
    Bill, Dec 11, 2007
    #1
    1. Advertising

  2. 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
    Joseph Kesselman, Dec 11, 2007
    #2
    1. Advertising

  3. Bill

    Guest

    On Dec 12, 11:56 am, "Bill" <> 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">
    , Dec 11, 2007
    #3
  4. 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
    Joseph Kesselman, Dec 11, 2007
    #4
  5. Bill

    Bill Guest

    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:
    ...
    > On Dec 12, 11:56 am, "Bill" <> 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">
    Bill, Dec 12, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Schmidt

    CDATA in XMLout

    Stefan Schmidt, Dec 28, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,272
    Andy R
    Dec 31, 2003
  2. chrisn
    Replies:
    1
    Views:
    3,584
    Bruce Barker
    Sep 13, 2005
  3. Forest
    Replies:
    0
    Views:
    313
    Forest
    Oct 20, 2003
  4. John Davison
    Replies:
    1
    Views:
    571
    Hal Rosser
    Jul 7, 2004
  5. Replies:
    3
    Views:
    738
    Joe Kesselman
    Mar 6, 2006
Loading...

Share This Page