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/LoadFromZipNG.java

    r1003 r1004  
    5959import org.docx4j.relationships.Relationship; 
    6060 
    61 import org.dom4j.Document; 
    62 import org.dom4j.DocumentException; 
    63 import org.dom4j.io.SAXReader; 
    6461 
    6562 
     
    187184                //              Eventually, you'll also be able to create an Excel package etc 
    188185                //              but only the WordML package exists at present 
    189                  
    190                 Document ctmDocument = null; 
     186 
    191187                try { 
    192                         ctmDocument = deprecatedGetDocumentFromZippedPart(partByteArrays, "[Content_Types].xml"); 
    193                 } catch (Exception e) { 
    194                         // Shouldn't happen 
    195                         throw new Docx4JException("Couldn't get [Content_Types].xml", e); 
    196                 } 
    197                 debugPrint(ctmDocument); 
    198                 ctm.parseContentTypesFile(ctmDocument);          
     188                        InputStream is = getInputStreamFromZippedPart( partByteArrays,  "[Content_Types].xml");          
     189                        ctm.parseContentTypesFile(is); 
     190                } catch (IOException e) { 
     191                        throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e); 
     192                } 
     193                                 
    199194                Package p = ctm.createPackage(); 
    200195                 
     
    290285                        String partName)  
    291286        //private static InputStream getInputStreamFromZippedPart(ZipFile zf, String partName)  
    292                 throws DocumentException, IOException { 
     287                throws IOException { 
    293288                 
    294289                InputStream in = null; 
     
    298293        } 
    299294         
    300          
    301         private static Document deprecatedGetDocumentFromZippedPart(HashMap<String, ByteArray> partByteArrays,  
    302                         String partName) 
    303         //private static Document deprecatedGetDocumentFromZippedPart(ZipFile zf, String partName)  
    304                 throws DocumentException, IOException { 
    305                  
    306                 InputStream in = null; 
    307 //              in = zf.getInputStream( zf.getEntry(partName ) ); 
    308                 in = partByteArrays.get(partName).getInputStream(); 
    309                 SAXReader xmlReader = new SAXReader(); 
    310                 Document contents = null; 
    311                 try { 
    312                         contents = xmlReader.read(in); 
    313                 } catch (DocumentException e) { 
    314                         // Will land here for binary files eg gif file 
    315                         // These do get handled .. 
    316                         log.error("DocumentException on " + partName + " . Check this is binary content.");  
    317                         //e.printStackTrace() ; 
    318                         throw e; 
    319                 } finally { 
    320                         if (in != null) { 
    321                                 try { 
    322                                         in.close(); 
    323                                 } catch (IOException exc) { 
    324                                         exc.printStackTrace(); 
    325                                 } 
    326                         } 
    327                 } 
    328                 return contents;                 
    329         } 
    330          
     295                 
    331296        /* recursively  
    332297        (i) create new Parts for each thing listed 
     
    632597                return part; 
    633598        }        
    634          
    635         private void dumpZipFileContents(ZipFile zf) { 
    636                 Enumeration entries = zf.entries(); 
    637                 // Enumerate through the Zip entries until we find the one named 
    638                 // '[Content_Types].xml'. 
    639                 while (entries.hasMoreElements()) { 
    640                         ZipEntry entry = (ZipEntry) entries.nextElement(); 
    641                         log.info( "\n\n" + entry.getName() + "\n" ); 
    642                         InputStream in = null; 
    643                         try {                    
    644                                 in = zf.getInputStream(entry); 
    645                         } catch (IOException e) { 
    646                                 e.printStackTrace() ; 
    647                         }                                
    648                         SAXReader xmlReader = new SAXReader(); 
    649                         Document xmlDoc = null; 
    650                         try { 
    651                                 xmlDoc = xmlReader.read(in); 
    652                         } catch (DocumentException e) { 
    653                                 // Will land here for binary files eg gif file 
    654                                 e.printStackTrace() ; 
    655                         } finally { 
    656                                 if (in != null) { 
    657                                         try { 
    658                                                 in.close(); 
    659                                         } catch (IOException exc) { 
    660                                                 exc.printStackTrace(); 
    661                                         } 
    662                                 } 
    663                         } 
    664                         debugPrint(xmlDoc); 
    665                          
    666                 } 
    667                  
    668         } 
    669          
     599                 
    670600        class ByteArray { 
    671601                 
Note: See TracChangeset for help on using the changeset viewer.