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.