Document doc1 = embDocs.get(0);
Assert.assertNotNull(doc1);
OdfContentDom contentDom = doc1.getContentDom();
XPath xpath = contentDom.getXPath();
TextPElement para = (TextPElement) xpath.evaluate("//text:p[1]", contentDom, XPathConstants.NODE);
OdfTextSpan spanElem = new OdfTextSpan(contentDom);
spanElem.setTextContent(TEST_SPAN_TEXT);
para.appendChild(spanElem);
// save the embed document to a stand alone document
doc1.save(TEST_FILE_SAVE_EMBEDDED_OUT);
// Load test
Document loadedDoc = Document.loadDocument(TEST_FILE_SAVE_EMBEDDED_OUT);
OdfContentDom contentDom2 = loadedDoc.getContentDom();
OdfTextSpan span = (OdfTextSpan) xpath.evaluate("//text:span[last()]", contentDom2, XPathConstants.NODE);
Assert.assertEquals(span.getTextContent(), TEST_SPAN_TEXT);
List<Document> embDocs3 = docWithEmbeddedObjects.getEmbeddedDocuments(Document.OdfMediaType.TEXT);
// Writer Doc
Document doc3 = embDocs3.get(0);
Assert.assertNotNull(doc3);
OdfContentDom contentDom3 = doc3.getContentDom();
TextPElement para2 = (TextPElement) xpath.evaluate("//text:p[1]", contentDom3, XPathConstants.NODE);
addImageToDocument(contentDom3, para2);
TextPElement para3 = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom3, XPathConstants.NODE);
addFrameForEmbeddedDoc(contentDom3, para3, "NewEmbedded");
doc3.insertDocument(TextDocument.newTextDocument(), "/NewEmbedded/");
Document doc4 = doc3.getEmbeddedDocument("NewEmbedded");
Assert.assertNotNull(doc4);
OdfContentDom contentDom4 = doc4.getContentDom();