Page 1 of 1

how do i create multiple slides with the same format?

PostPosted: Mon May 18, 2015 7:05 am
by Andre d docx4j
i'm a newbie to docx4j, i downloaded the http://www.docx4java.org/svn/docx4j/trunk/docx4j/src/pptx4j/java/org/pptx4j/samples/CreateHelloWorld.java and tried to change the content of the slide with another model of a presentation you can see here:http://s000.tinyupload.com/index.php?file_id=04002039625256543657.

I used the WebApp's package explorer to see what was inside the slide1 and just copy and pasted it in the SAMPLE_SHAPE String variable that holds the xml code in the java class CreateHelloWorld but it gives me this big exception when i compile:

Code: Select all
Exception in thread "main" javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 8; El prefijo "p" para el elemento "p:sld" no está enlazado.]
   at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:335)   at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:335)
   at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:512)
   at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:209)
   at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:175)
   at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157)
   at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:125)
   at org.docx4j.XmlUtils.unmarshalString(XmlUtils.java:433)
   at org.docx4j.samples.CreateHelloWorld.main(CreateHelloWorld.java:41)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 8; El prefijo "p" para el elemento "p:sld" no está enlazado.
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1239)
   at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
   at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:203)
   ... 5 more
Java Result: 1


What does it mean? do i need to write more parts of the packages? how can i create this whole slide in java?

Re: how do i create multiple slides with the same format?

PostPosted: Mon May 25, 2015 11:03 am
by jason
I'm guessing

El prefijo "p" para el elemento "p:sld" no está enlazado


in English is you haven't bound "p" to a namespace.

Notice:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
        private static String SAMPLE_SHAPE =                   
                "<p:sp   xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">"
 
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


binds "p" to "http://schemas.openxmlformats.org/presentationml/2006/main"

Re: how do i create multiple slides with the same format?

PostPosted: Tue May 26, 2015 1:01 am
by Andre d docx4j
so what should i do? how do i bind p to a namespace do i have to create another variable or just add it in my SAMPLE_SHAPE variable?

Re: how do i create multiple slides with the same format?

PostPosted: Tue May 26, 2015 9:15 am
by jason
Just add it.

Re: how do i create multiple slides with the same format?

PostPosted: Wed May 27, 2015 11:35 am
by Andre d docx4j
could you pòst the code i have to add? i'm pretty clueless on what to do

Re: how do i create multiple slides with the same format?

PostPosted: Wed May 27, 2015 6:30 pm
by jason
That's very basic Java.

String concat is just: String SAMPLE_SHAPE = "<p:sp xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">" + theRestOfYourXML;