try {
OdfTextDocument odtRootDoc = OdfTextDocument.newTextDocument();
odtRootDoc.insertDocument(OdfTextDocument.newTextDocument(), "DOCA/");
OdfDocument docA = odtRootDoc.loadSubDocument("DOCA");
docA.newImage(ResourceUtilities.getURI(TEST_PIC));
docA.insertDocument(OdfSpreadsheetDocument.newSpreadsheetDocument(), "../DOCB/");
OdfFileDom contentA = docA.getContentDom();
XPath xpath = contentA.getXPath();
TextPElement lastPara = (TextPElement) xpath.evaluate("//text:p[last()]", contentA, XPathConstants.NODE);
addFrameForEmbeddedDoc(contentA, lastPara, "DOCB");
OdfDocument docB = odtRootDoc.loadSubDocument("DOCB/");