I tried to get the SlidePart the following way:
- Code: Select all
PresentationMLPackage template =
(PresentationMLPackage)PresentationMLPackage.load(new java.io.File("S1.pptx"));
Parts parts = template.getParts();
Map partsMap = parts.getParts();
Set partsMapKeys = partsMap.keySet();
for (Iterator it = partsMapKeys.iterator(); it.hasNext();) {
Object o = it.next();
System.out.println();
System.out.println("The Key Name is "+o.toString());
System.out.println("Value is "+partsMap.get(o));
System.out.println();
if("/ppt/slides/slide1.xml".equalsIgnoreCase(o.toString())){
SlidePart sldPart = (SlidePart)partsMap.get(o);
List texts = sldPart.getJAXBNodesViaXPath(XPATH_TO_SELECT_TEXT_NODES, true);
System.out.println("Size of list "+texts.size());
for (Object obj : texts) {
Text text = (Text) ((JAXBElement) obj).getValue();
String textValue = text.getValue();
System.out.println("TEXTVALUE");
System.out.println(" "+textValue);
System.out.println("TEXTVALUE");
}
}
}
HEre I was trying to get the text value that my PPTX contains. My Slide1.xml that i extracted using zip/unzip is attached.
The output I get from this is that the List if empty and the warnings:
The Key Name is /ppt/slides/slide1.xml
Value is org.docx4j.openpackaging.parts.PresentationML.SlidePart@1db0c7e
6235 [main] WARN org.docx4j.XmlUtils - no object association for xpath result!
6235 [main] WARN org.docx4j.XmlUtils - no object association for xpath result!
Size of list 0
Can you help me resolve this issue?