| 1 | Xalan notes |
|---|
| 2 | ----------- |
|---|
| 3 | |
|---|
| 4 | // com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl won't |
|---|
| 5 | // work with our extension functions. |
|---|
| 6 | |
|---|
| 7 | (Same problem with Xalan 2.7.1 and org.apache.xalan.xsltc.trax.TransformerImpl) |
|---|
| 8 | |
|---|
| 9 | javax.xml.transform.TransformerException: Cannot convert argument/return type in call to method |
|---|
| 10 | for many extension functions |
|---|
| 11 | |
|---|
| 12 | Problem is returning a DocumentFragment? |
|---|
| 13 | Return a NodeSet instead. |
|---|
| 14 | But there is org.apache.xpath.NodeSet, |
|---|
| 15 | and com.sun.org.apache.xpath.NodeSet. |
|---|
| 16 | |
|---|
| 17 | Returning one of these is not enough .. problems with args as well? |
|---|
| 18 | Would need to build Xalan from source to debug |
|---|
| 19 | |
|---|
| 20 | Real Xalan 2.7.1 works in docx4j. |
|---|
| 21 | |
|---|
| 22 | JDK/JRE doesn't include an equivalent. |
|---|
| 23 | |
|---|
| 24 | Saxon doesn't work with our extension functions. |
|---|
| 25 | |
|---|
| 26 | So the only option today is real Xalan with processor, not xsltc |
|---|
| 27 | |
|---|
| 28 | docx4all now specifies xalan-patched. |
|---|
| 29 | |
|---|
| 30 | // Whenever we flush Preferences in a Swing application on Linux, |
|---|
| 31 | // < Java 6u10 RC (as of b23) |
|---|
| 32 | // we'll get java.util.prefs.BackingStoreException: java.lang.IllegalArgumentException: Not supported: indent-number |
|---|
| 33 | // if we are using our Xalan jar. |
|---|
| 34 | // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6396599 |
|---|
| 35 | // So Swing applications will need to use the original |
|---|
| 36 | // setting, which we record for their convenience here. |
|---|
| 37 | // eg com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl |
|---|
| 38 | // It would be nice to reset to the original whenever we finish |
|---|
| 39 | // using, but that goal seems to be elusive! |
|---|
| 40 | |
|---|
| 41 | HOWEVER, docx4all encounters http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6396599 |
|---|
| 42 | |
|---|
| 43 | java.util.prefs.FileSystemPreferences syncWorld |
|---|
| 44 | WARNING: Couldn't flush user prefs: java.util.prefs.BackingStoreException: java.lang.IllegalArgumentException: Not supported: indent-number |
|---|
| 45 | |
|---|
| 46 | every 30 seconds (on Linux, with JDK < Java 6u10 RC (as of b23) |
|---|
| 47 | |
|---|
| 48 | The workaround implemented (xalan-patched) is to remove META-INF/services from the xalan jar |
|---|
| 49 | to prevent xalan being picked up as the default provider for jaxp transform, |
|---|
| 50 | so we have to use it explicitly. |
|---|
| 51 | |
|---|
| 52 | .. which means |
|---|
| 53 | |
|---|
| 54 | System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl"); |
|---|
| 55 | |
|---|
| 56 | (unfortunately, there is no com.sun.org.apache.xalan.processor.TransformerFactoryImpl, |
|---|
| 57 | so we have to bundle xalan jar, which is 2.7 MB |
|---|
| 58 | |
|---|
| 59 | But we can make it smaller: |
|---|
| 60 | |
|---|
| 61 | org/apache/xalan/lib$ rm sql -rf |
|---|
| 62 | org/apache/xalan$ rm xsltc -rf |
|---|
| 63 | |
|---|
| 64 | That gets us from 2.7 MB to 1.85 MB. |
|---|
| 65 | |
|---|
| 66 | Sun already has: |
|---|
| 67 | |
|---|
| 68 | com.sun.org.apache.xpath; |
|---|
| 69 | com.sun.org.apache.xml.internal.dtm; |
|---|
| 70 | com.sun.org.apache.xalan.internal.extensions|lib|res |
|---|
| 71 | |
|---|
| 72 | so you might think we can refactor Xalan to point to those, and them out of our jar. |
|---|
| 73 | |
|---|
| 74 | well, it turns out that its too messy leaving out org.apache.xpath or xalan.extensions |
|---|
| 75 | |
|---|
| 76 | so you have to keep xalan.extensions, processor, serialize, trace, transformer |
|---|
| 77 | |
|---|
| 78 | leaving out just org.apache.xalan.resources and org.apache.xpath.resources |
|---|
| 79 | only gets us down to 1.5 MB. (and that's with just jar cvf xalan-minimal.jar org/apache/xalan org/apache/xpath |
|---|
| 80 | - we'd still need to include org/apache/xml) |
|---|
| 81 | |
|---|
| 82 | ie once you include the whole of org.apache.xpath, you may as well just go with the 1.85 MB :( |
|---|
| 83 | |
|---|
| 84 | |
|---|