- Timestamp:
- 03/14/08 16:07:32 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java
r186 r192 248 248 * We want to use plain old Xalan J, not xsltc 249 249 * 250 * Following is not necessary provided Xalan is on the classpath. 251 * ================================== 250 * Following would not be necessary provided Xalan is on the classpath 252 251 * 253 252 System.setProperty("javax.xml.transform.TransformerFactory", "FQCN"); … … 255 254 examples of FQCN: 256 255 257 org.apache.xalan. transformer.TransformerImpl (this is the one we want)256 org.apache.xalan.processor.TransformerFactoryImpl (this is the one we want) 258 257 com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl 259 258 org.apache.xalan.xsltc.trax.TransformerFactoryImpl 259 net.sf.saxon.TransformerFactoryImpl 260 261 (unfortunately, there is no com.sun.org.apache.xalan.processor.TransformerFactoryImpl, 262 so we have to bundle xalan jar, which is 2.7 MB 263 264 But we can make it smaller: 265 266 org/apache/xalan/lib$ rm sql -rf 267 org/apache/xalan$ rm xsltc -rf 268 269 That gets us from 2.7 MB to 1.85 MB. 270 271 But Sun already has: 272 273 com.sun.org.apache.xpath; 274 com.sun.org.apache.xml.internal.dtm; 275 com.sun.org.apache.xalan.internal.extensions|lib|res|templates 276 277 So why not refactor Xalan and leave all that out as well? 278 279 280 HOWEVER, docx4all encounters http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6396599 281 282 java.util.prefs.FileSystemPreferences syncWorld 283 WARNING: Couldn't flush user prefs: java.util.prefs.BackingStoreException: java.lang.IllegalArgumentException: Not supported: indent-number 284 285 every 30 seconds 286 287 The workaround implemented is to remove META-INF/services from the xalan jar 288 to prevent xalan being picked up as the default provider for jaxp transform, 289 so we have to use it explicitly. 290 291 .. which means 292 293 System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl"); 260 294 261 295 */ 296 297 298 javax.xml.transform.TransformerFactory tfactory = javax.xml.transform.TransformerFactory.newInstance(); 299 String originalFactory = tfactory.getClass().getName(); 300 System.out.println("original TransformerFactory: " + originalFactory); 301 // com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl resolves the syncWorld problem 302 // net.sf.saxon.TransformerFactoryImpl is no good. 303 304 System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl"); 305 262 306 // Now transform this into XHTML 263 javax.xml.transform.TransformerFactorytfactory = javax.xml.transform.TransformerFactory.newInstance();307 tfactory = javax.xml.transform.TransformerFactory.newInstance(); 264 308 javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource(doc); 265 309 … … 274 318 // Use the template to create a transformer 275 319 javax.xml.transform.Transformer xformer = template.newTransformer(); 320 321 322 // Finished with the factory, so set it back again! 323 // The "Not supported: indent-number" problem will only occur if a user creates 324 // a new document during the time between these 2 calls to setProperty 325 // (and syncWorld is called?) 326 System.setProperty("javax.xml.transform.TransformerFactory", originalFactory); 276 327 277 328 if (!xformer.getClass().getName().equals("org.apache.xalan.transformer.TransformerImpl")) {
Note: See TracChangeset
for help on using the changeset viewer.
