title: Converting XML to Word Document
body: <p>I have a word-generated xml file (2007) with the right structure</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;?mso-application progid="Word.Document"?&gt;
      &lt;pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"&gt;
          &lt;!-- content... --&gt;
      &lt;/pkg:package&gt;
  </code></pre>
  
  <p>Using Apache Poi, I want to generate the corresponding <code>XWPFDocument</code></p>
  
  <pre><code>            try {
                  //strXML is the xml content
                  File xmlGenFile = new File("./sampleFile.xml");
                  FileWriter fw = new FileWriter(xmlGenFile);
                  fw.write(strXML);
                  fw.close();
                  OPCPackage oPack = OPCPackage.open(xmlGenFile);
                  XWPFDocument doc = new XWPFDocument(oPack);
  
              } catch (ContentIOException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (InvalidFormatException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  </code></pre>
  
  <p>I tried to use the <code>OPCPackage.open</code> method but i am getting <code>org.apache.poi.openxml4j.exceptions.InvalidOperationException</code></p>
  
  <pre><code>org.apache.poi.openxml4j.exceptions.InvalidOperationException: Can't open the specified file: '.\sampleFile.xml'
      at org.apache.poi.openxml4j.opc.ZipPackage.&lt;init&gt;(ZipPackage.java:131)
      at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:246)
      at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:200)
      at tn.com.st2i.service.impl.TemplatingServiceImpl.generateWordDocument(TemplatingServiceImpl.java:105)
      at tn.com.st2i.webscript.RetrieveGeneratedDocumentPost.execute(RetrieveGeneratedDocumentPost.java:79)
      at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:429)
      at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:452)
      at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:491)
      at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:529)
      at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:341)
      at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)
      at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
      at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.util.zip.ZipException: error in opening zip file
      at java.util.zip.ZipFile.open(Native Method)
      at java.util.zip.ZipFile.&lt;init&gt;(ZipFile.java:215)
      at java.util.zip.ZipFile.&lt;init&gt;(ZipFile.java:145)
      at java.util.zip.ZipFile.&lt;init&gt;(ZipFile.java:159)
      at org.apache.poi.openxml4j.opc.internal.ZipHelper.openZipFile(ZipHelper.java:157)
      at org.apache.poi.openxml4j.opc.ZipPackage.&lt;init&gt;(ZipPackage.java:129)
      ... 32 more
  </code></pre>
  
  <p>Obviously, the file exists</p>