Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Retain whitespace between tags within mixed-content tags

2843402Jan 21 2015 — edited Jan 21 2015

We are using XML DB in Oracle Database 12c. We have a problem retaining whitespaces between tags. Note that we have already registered our schema in the database that defines which tags are mixed-content type. I think we have done this properly since inserting XMLs not conforming to the schema will raise an exception.

For example:

with input as ( select xmltype( '<content> <inline>hello</inline> <inline>world</inline> </content>') as xml_doc from dual) select xmlserialize(document xml_doc no indent) from input

Note that the above is an example only, we properly set xmlns and other root attributes properly to refer to registered schemas.

Will output:

'<content><inline>hello</inline><inline>world</inline></content>'

Whereas we expected the output to be:

'<content> <inline>hello</inline> <inline>world</inline> </content>'

Is this an Oracle bug or are we doing something wrong? Oracle should not remove the whitespaces between <inline> since their parent <content> is of mixed content-type.

Note:

  • "no indent" in xmlserialize is used so that no additional whitespace is introduced in the XML. And besides, any XML operation (XQuery) results to removal of whitespaces between tags.
  • xml:space="preserve" is not an option since XML may be indented. Indentation whitespaces should not be preserved.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 18 2015
Added on Jan 21 2015
2 comments
776 views