Use XMLTEXT with XMLAGG to construct mixed content. Suppose that the content of table T is as follows:
seqno plaintext emphtext
------ ------------------------------------------- -----------------------------
1 This query shows how to construct mixed content
2 using XMLAGG and XMLTEXT. Without XMLTEXT
3 XMLAGG will not have text nodes to group with other nodes, mixed content therefore, cannot generate
SELECT
XMLELEMENT(
NAME "para", XMLAGG(
XMLCONCAT(
XMLTEXT(
PLAINTEXT
),
XMLELEMENT(
NAME "emphasis", EMPHTEXT
)
)
ORDER BY SEQNO
), '.'
) AS "result"
FROM T
This query produces the following result:
result
-------------------------------------------------------------------------------
<para>This query shows how to construct <emphasis>mixed content</emphasis>
using XMLAGG and XMLTEXT. Without <emphasis>XMLTEXT</emphasis>
, XMLAGG
will not have text nodes to group with other nodes, therefore, cannot
generate
<emphasis>mixed content</emphasis>.</para>