Page 1 of 1

How to add JaxbElements to slides?

PostPosted: Mon May 27, 2013 6:20 pm
by pupul07
Hi everyone.
I'm new to both Java programming as well as pptx4j.
So please forgive me if this question is a trivial one.

I used the code generator to generate a table I made in the form of a JAXBElement object.
Now, how do I add this object to my slide?

This is what I was trying to do:
Code: Select all
PresentationMLPackage presentationMLPackage = PresentationMLPackage.createPackage();
MainPresentationPart pp = (MainPresentationPart)presentationMLPackage.getParts().getParts().get(new PartName("/ppt/presentation.xml"));
SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(new PartName("/ppt/slideLayouts/slideLayout1.xml"));
SlidePart slidePart = presentationMLPackage.createSlidePart(pp, layoutPart, new PartName("/ppt/slides/slide1.xml"));
slidePart.getJaxbElement().getCSld().getSpTree().getSpOrGrpSpOrGraphicFrame().add(createIt());


But I get the following error:
[com.sun.istack.internal.SAXException2: Instance of "javax.xml.bind.JAXBElement" is substituting "java.lang.Object", but "javax.xml.bind.JAXBElement" is bound to an anonymous type.]

Re: How to add JaxbElements to slides?

PostPosted: Mon May 27, 2013 10:16 pm
by jason
If you could please post your complete sample .java file (ie including imports and the createIt() method), it'll be easier to replicate your issue.

Re: How to add JaxbElements to slides?

PostPosted: Tue May 28, 2013 4:25 pm
by pupul07
Hi Jason.

I figured out the problem, I was trying to marshal a graphic without creating a graphic frame first.

Sorry for the silly question.