Ignore:
Timestamp:
01/09/10 18:15:02 (2 years ago)
Author:
jharrop
Message:

Remove dom4j stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromZipFile.java

    r1003 r1004  
    5151import org.docx4j.openpackaging.parts.relationships.RelationshipsPart; 
    5252import org.docx4j.relationships.Relationship; 
    53 import org.dom4j.Document; 
    54 import org.dom4j.DocumentException; 
    55 import org.dom4j.io.SAXReader; 
    5653 
    5754 
     
    130127                //              but only the WordML package exists at present 
    131128                 
    132                 Document ctmDocument = null; 
    133129                try { 
    134                         ctmDocument = deprecatedGetDocumentFromZippedPart(zf, "[Content_Types].xml"); 
    135                 } catch (Exception e) { 
    136                         // Shouldn't happen 
    137                         throw new Docx4JException("Couldn't get [Content_Types].xml", e); 
    138                 } 
    139                 debugPrint(ctmDocument); 
    140                 ctm.parseContentTypesFile(ctmDocument);          
     130                        InputStream is = getInputStreamFromZippedPart( zf,  "[Content_Types].xml"); 
     131                        ctm.parseContentTypesFile(is); 
     132                } catch (IOException e) { 
     133                        throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e); 
     134                } 
     135                 
    141136                Package p = ctm.createPackage(); 
    142137                 
     
    236231 
    237232        private static InputStream getInputStreamFromZippedPart(ZipFile zf, String partName)  
    238                 throws DocumentException, IOException { 
     233                throws IOException { 
    239234                 
    240235                InputStream in = null; 
     
    244239         
    245240         
    246         private static Document deprecatedGetDocumentFromZippedPart(ZipFile zf, String partName)  
    247                 throws DocumentException, IOException { 
    248                  
    249                 InputStream in = null; 
    250                 in = zf.getInputStream( zf.getEntry(partName ) ); 
    251                 SAXReader xmlReader = new SAXReader(); 
    252                 Document contents = null; 
    253                 try { 
    254                         contents = xmlReader.read(in); 
    255                 } catch (DocumentException e) { 
    256                         // Will land here for binary files eg gif file 
    257                         // These do get handled .. 
    258                         log.error("DocumentException on " + partName + " . Check this is binary content.");  
    259                         //e.printStackTrace() ; 
    260                         throw e; 
    261                 } finally { 
    262                         if (in != null) { 
    263                                 try { 
    264                                         in.close(); 
    265                                 } catch (IOException exc) { 
    266                                         exc.printStackTrace(); 
    267                                 } 
    268                         } 
    269                 } 
    270                 return contents;                 
    271         } 
    272241         
    273242        /* recursively  
     
    579548        }        
    580549         
    581         private void dumpZipFileContents(ZipFile zf) { 
    582                 Enumeration entries = zf.entries(); 
    583                 // Enumerate through the Zip entries until we find the one named 
    584                 // '[Content_Types].xml'. 
    585                 while (entries.hasMoreElements()) { 
    586                         ZipEntry entry = (ZipEntry) entries.nextElement(); 
    587                         log.info( "\n\n" + entry.getName() + "\n" ); 
    588                         InputStream in = null; 
    589                         try {                    
    590                                 in = zf.getInputStream(entry); 
    591                         } catch (IOException e) { 
    592                                 e.printStackTrace() ; 
    593                         }                                
    594                         SAXReader xmlReader = new SAXReader(); 
    595                         Document xmlDoc = null; 
    596                         try { 
    597                                 xmlDoc = xmlReader.read(in); 
    598                         } catch (DocumentException e) { 
    599                                 // Will land here for binary files eg gif file 
    600                                 e.printStackTrace() ; 
    601                         } finally { 
    602                                 if (in != null) { 
    603                                         try { 
    604                                                 in.close(); 
    605                                         } catch (IOException exc) { 
    606                                                 exc.printStackTrace(); 
    607                                         } 
    608                                 } 
    609                         } 
    610                         debugPrint(xmlDoc); 
    611                          
    612                 } 
    613                  
    614         } 
    615  
    616          
    617          
    618          
    619          
    620550         
    621551} 
Note: See TracChangeset for help on using the changeset viewer.