This discussion is archived
3 Replies Latest reply: Aug 15, 2013 10:32 AM by odie_63 RSS

CDATA section gets lost when storing data as binary xml

j.sieben Newbie
Currently Being Moderated

Hi,

has anybody found any documentation that once you store XML as binary xml, it won't save CDATA-tags? Is this the expected behavior or a bug?

 

as an example, you have a xml instance like this:

 

<foo><![CDATA[This is CDATA-content]]></foo>

 

but once you save it in a table that stores this XMLType instance as binary xml, this is what is returned:

 

<foo>This is CDATA-content</foo>

 

Can anybody shed some light on this?

 

Best regards,

Jürgen

  • 1. Re: CDATA section gets lost when storing data as binary xml
    odie_63 Guru
    Currently Being Moderated

    What's your database version?

     

    I don't reproduce on 11.2.0.2 or 11.2.0.3 :

    SQL> create table tmp_xml of xmltype

      2  xmltype store as securefile binary xml;

     

    Table created.

     

    SQL> insert into tmp_xml values (

      2    xmlparse(document '<foo><![CDATA[This is CDATA-content]]></foo>')

      3  );

     

    1 row created.

     

    SQL> select object_value from tmp_xml;

     

    OBJECT_VALUE

    --------------------------------------------------------------------------------

    <foo><![CDATA[This is CDATA-content]]></foo>

     

  • 2. Re: CDATA section gets lost when storing data as binary xml
    j.sieben Newbie
    Currently Being Moderated

    Hi odie_63

    thanks for your reply and my apologies for answering so late.

    I'm using Oracle 11g R2 and SQL-Developer 3.2.2

    Yes, you're right, if you run your script from within SQL*Plus.

    If you run it within SQL-Developer, it will give you the following output:

     

    drop table test_xml;

     

    create table test_xml(

      xml_instance xmltype)

      xmltype columen xml_instance store as binary xml;

     

    insert into test_xml values(xmltype('<Foo><![CDATA[Das ist CDATA]]></Foo>'));

     

    select *

      from test_xml;

     

    XML_INSTANCE

    ---------------------------------------------

    <Foo>Das is CDATA</Foo>

     

    So I'm at the wrong forum here, it needs to be posted to the SQL-Developer Forum.

     

    Thanks anyway!

     

    Jürgen

     

    Message was edited by: j.sieben Followup: No, SQL-Developer does not really delete any CDATA-section, but it hides the CDATA-Tag from being shown on page. Very confusing, as I assumed an error in this field, didn't see that the CDATA-Tag was stored and only found the behaviour after inserting data via SQL-Developer and retreiving them via SQL*Plus ...

  • 3. Re: CDATA section gets lost when storing data as binary xml
    odie_63 Guru
    Currently Being Moderated

    Followup: No, SQL-Developer does not really delete any CDATA-section, but it hides the CDATA-Tag from being shown on page. Very confusing, as I assumed an error in this field, didn't see that the CDATA-Tag was stored and only found the behaviour after inserting data via SQL-Developer and retreiving them via SQL*Plus ...

    Yes, each tool has its own way of handling XMLType for display.

    For example, PL/SQL Developer (which I use a lot) executes a small PL/SQL block that basically calls getClobVal() method each time an XMLType is fetched to the client.

     

    To be sure of the actual content, always check it after serializing to CLOB, e.g. :

    SELECT XMLSerialize(document xml_instance as CLOB indent)

    FROM test_xml ;

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points