OdfFileDom contentDom = odgDoc1.getContentDom();
NodeList lst = contentDom.getElementsByTagNameNS(
DrawPageElement.ELEMENT_NAME.getUri(),
DrawPageElement.ELEMENT_NAME.getLocalName());
DrawPageElement page = (DrawPageElement) lst.item(lst.getLength() - 1);
//page.setOdfAttribute( OdfName.newName( OdfNamespace.newName(OdfDocumentNamespace.DRAW), "name" ), "page1" );
//page.setOdfAttribute( OdfName.newName( OdfNamespace.newName(OdfDocumentNamespace.DRAW), "style-name" ), "dp1" );
//page.setOdfAttribute( OdfName.newName( OdfNamespace.newName(OdfDocumentNamespace.DRAW), "master-page-name" ), "Default" );
page.setDrawNameAttribute("page1");
page.setDrawStyleNameAttribute("dp1");
page.setDrawMasterPageNameAttribute("Default");
DrawLineElement line = page.newDrawLineElement("6cm", "10cm", "15cm", "20cm");
//line.setOdfAttribute( OdfName.newName( OdfNamespace.newName(OdfDocumentNamespace.DRAW), "style-name" ), "gr1" );
//line.setOdfAttribute( OdfName.newName( OdfNamespace.newName(OdfDocumentNamespace.DRAW), "text-style-name" ), "P1" );
//line.setOdfAttribute( OdfName.newName( OdfNamespace.newName(OdfDocumentNamespace.DRAW), "layer" ), "layout" );
line.setDrawStyleNameAttribute("gr1");
line.setDrawTextStyleNameAttribute("P1");
line.setDrawLayerAttribute("layer");
XPath xpath = contentDom.getXPath();
DrawPageElement graphicTest = (DrawPageElement) xpath.evaluate("//draw:page[last()]", contentDom, XPathConstants.NODE);
Assert.assertNotNull(graphicTest.getChildNodes());
Assert.assertTrue(graphicTest.getChildNodes().item(0) instanceof DrawLineElement);
Assert.assertEquals(line, graphicTest.getChildNodes().item(0));
Assert.assertEquals(graphicTest.getChildNodes().item(0).getNodeName(), "draw:line");
Assert.assertEquals(((DrawLineElement) graphicTest.getChildNodes().item(0)).getSvgX1Attribute().toString(), "6cm");
Assert.assertEquals(((DrawLineElement) graphicTest.getChildNodes().item(0)).getSvgX2Attribute().toString(), "10cm");
Assert.assertEquals(((DrawLineElement) graphicTest.getChildNodes().item(0)).getSvgY1Attribute().toString(), "15cm");
Assert.assertEquals(((DrawLineElement) graphicTest.getChildNodes().item(0)).getSvgY2Attribute().toString(), "20cm");
contentDom.getDocument().save(ResourceUtilities.newTestOutputFile("CreatChildrenForGraphic.odg"));
} catch (Exception e) {
Logger.getLogger(CreateChildrenElementsTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);