CDATASection (org.w3c.dom.Document document, Format format, CDATA cdata) { final List<CDATA> list = Collections.singletonList(cdata); final FormatStack formatStack = new FormatStack(format); final Walker walker = buildWalker(formatStack, list, false); if (walker.hasNext()) { final Content c = walker.next(); if (c == null) { return printCDATA(document, new CDATA(walker.text())); } if (c.getCType() == CType.CDATA) { return printCDATA(document, (CDATA)c); } } // return an empty string if nothing happened. return null; }