OdfTextParagraph p0 = (OdfTextParagraph) lst.item(lst.getLength() - 1);
OfficeDocumentContentElement content = contentDom.newOdfElement(OfficeDocumentContentElement.class);
OfficeBodyElement body = contentDom.newOdfElement(OfficeBodyElement.class);
content.appendChild(body);
ChartChartElement chart = contentDom.newOdfElement(ChartChartElement.class);
//create children element
ChartPlotAreaElement plotArea = chart.newChartPlotAreaElement();
body.appendChild(chart);
p0.getParentNode().insertBefore(content, p0);
XPath xpath = contentDom.getXPath();
ChartChartElement chartTest = (ChartChartElement) xpath.evaluate("//chart:chart[last()]", contentDom, XPathConstants.NODE);
Assert.assertNotNull(chartTest.getChildNodes());
Assert.assertTrue(chartTest.getChildNodes().item(0) instanceof ChartPlotAreaElement);
Assert.assertEquals(plotArea, chartTest.getChildNodes().item(0));
Assert.assertEquals(chartTest.getChildNodes().item(0).getNodeName(), "chart:plot-area");
contentDom.getDocument().save(ResourceUtilities.newTestOutputFile("CreatChildrenForChartTest.odt"));
} catch (Exception e) {
Logger.getLogger(CreateChildrenElementsTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);