Using 9.4.2 and 943-20200826.181852 I get the same result:

let $test as element(root) :=
<root>
  <content>
    <div>words</div>
  </content>
</root>

return file:write('/home/graydon/test2.xml',
$test,
map { "method": "xml", "cdata-section-elements": "content"})

does not work, in the sense that no CDATA block is created.

let $test as element(root) :=
<root>
  <content>
    <div>words</div>
  </content>
</root>

return file:write('/home/graydon/test2.xml',
$test,
map { "method": "xml", "cdata-section-elements": "div"})

does work, in the sense that the text contents of div gets wrapped in CDATA.

If I try
let $test as element(root) :=
<root>
  <content>
    <div>words <b>bold</b> words</div>
  </content>
</root>

return file:write('/home/graydon/test2.xml',
$test,
map { "method": "xml", "cdata-section-elements": "div"})

I get

<root>
  <content>
    <div><![CDATA[words ]]><b>bold</b><![CDATA[ words]]></div>
  </content>
</root>

which makes me think that only text node children of the element get wrapped in a CDATA block.

I would expect (from the way XSLT processors usually behave) that the content of an element with element children would be serialized into a CDATA block.  Am I confused?  Is this a bug? is there a  more appropriate way to declare the contents of the content element a CDATA block?

Thanks!
Graydon