aboutsummaryrefslogtreecommitdiffstats
path: root/src/codegen/java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-07-16 20:16:51 +0000
committerJeremias Maerki <jeremias@apache.org>2008-07-16 20:16:51 +0000
commit1ec5f0c34786a0589aa34cf06a523c05bb42ec61 (patch)
tree9df493edbabf5fd214289988cc6b1035ed6e8e9d /src/codegen/java
parent93d283b53b864778a2c87af1d7072c1a520b35f8 (diff)
downloadxmlgraphics-fop-1ec5f0c34786a0589aa34cf06a523c05bb42ec61.tar.gz
xmlgraphics-fop-1ec5f0c34786a0589aa34cf06a523c05bb42ec61.zip
Worked around a bug in Xalan 2.4.0 (bundled with Sun Java 1.4.2_xx) where file URLs like file:/C:/.... got converted to file:\C:\.... on Windows causing a FileNotFoundException.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@677404 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/codegen/java')
-rw-r--r--src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
index ed92a55e0..e00b05b55 100644
--- a/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
+++ b/src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java
@@ -22,6 +22,7 @@ package org.apache.fop.tools;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.Iterator;
import java.util.List;
@@ -38,6 +39,7 @@ import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Node;
+import org.apache.commons.io.IOUtils;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
@@ -121,29 +123,38 @@ public class EventProducerCollectorTask extends Task {
//Generate translation file (with potentially new translations)
src = new DOMSource(sourceDocument);
- Result res = new StreamResult(getTranslationFile().toURI().toURL().toExternalForm());
- StreamSource xslt2 = new StreamSource(
- getClass().getResourceAsStream(MERGETRANSLATION));
- if (xslt2.getInputStream() == null) {
- throw new FileNotFoundException(MERGETRANSLATION + " not found");
- }
- transformer = tFactory.newTransformer(xslt2);
- transformer.setURIResolver(new URIResolver() {
- public Source resolve(String href, String base) throws TransformerException {
- if ("my:dom".equals(href)) {
- return new DOMSource(generated);
+
+ //The following triggers a bug in older Xalan versions
+ //Result res = new StreamResult(getTranslationFile());
+ OutputStream out = new java.io.FileOutputStream(getTranslationFile());
+ out = new java.io.BufferedOutputStream(out);
+ Result res = new StreamResult(out);
+ try {
+ StreamSource xslt2 = new StreamSource(
+ getClass().getResourceAsStream(MERGETRANSLATION));
+ if (xslt2.getInputStream() == null) {
+ throw new FileNotFoundException(MERGETRANSLATION + " not found");
+ }
+ transformer = tFactory.newTransformer(xslt2);
+ transformer.setURIResolver(new URIResolver() {
+ public Source resolve(String href, String base) throws TransformerException {
+ if ("my:dom".equals(href)) {
+ return new DOMSource(generated);
+ }
+ return null;
}
- return null;
+ });
+ if (resultExists) {
+ transformer.setParameter("generated-url", "my:dom");
}
- });
- if (resultExists) {
- transformer.setParameter("generated-url", "my:dom");
- }
- transformer.transform(src, res);
- if (resultExists) {
- log("Translation file updated: " + getTranslationFile());
- } else {
- log("Translation file generated: " + getTranslationFile());
+ transformer.transform(src, res);
+ if (resultExists) {
+ log("Translation file updated: " + getTranslationFile());
+ } else {
+ log("Translation file generated: " + getTranslationFile());
+ }
+ } finally {
+ IOUtils.closeQuietly(out);
}
} catch (TransformerException te) {
throw new IOException(te.getMessage());