aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/tools
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2002-01-08 09:52:18 +0000
committerKeiron Liddle <keiron@apache.org>2002-01-08 09:52:18 +0000
commitaca1e4f9afd5d27a9ad6cea9871c4ae4632653e7 (patch)
tree36f89e946c70432b09f8f26a3f75de9146965f7c /src/org/apache/fop/tools
parent0f24e0a799e3f4a2540f51d64e21f76639179b72 (diff)
downloadxmlgraphics-fop-aca1e4f9afd5d27a9ad6cea9871c4ae4632653e7.tar.gz
xmlgraphics-fop-aca1e4f9afd5d27a9ad6cea9871c4ae4632653e7.zip
does some basic text into pdf and svg output just for a start
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194617 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/tools')
-rw-r--r--src/org/apache/fop/tools/TestConverter.java4
-rw-r--r--src/org/apache/fop/tools/anttasks/CompileXMLFiles.java233
-rw-r--r--src/org/apache/fop/tools/anttasks/RunTest.java14
3 files changed, 9 insertions, 242 deletions
diff --git a/src/org/apache/fop/tools/TestConverter.java b/src/org/apache/fop/tools/TestConverter.java
index 2f06daffc..846c5773c 100644
--- a/src/org/apache/fop/tools/TestConverter.java
+++ b/src/org/apache/fop/tools/TestConverter.java
@@ -45,7 +45,7 @@ public class TestConverter {
File destdir;
File compare = null;
String baseDir = "./";
- Hashtable differ = new Hashtable();
+ HashMap differ = new HashMap();
private Logger log;
/**
@@ -117,7 +117,7 @@ public class TestConverter {
* This runs the tests specified in the xml file fname.
* The document is read as a dom and each testcase is covered.
*/
- public Hashtable runTests(String fname, String dest, String compDir) {
+ public HashMap runTests(String fname, String dest, String compDir) {
log.debug("running tests in file:" + fname);
try {
if (compDir != null) {
diff --git a/src/org/apache/fop/tools/anttasks/CompileXMLFiles.java b/src/org/apache/fop/tools/anttasks/CompileXMLFiles.java
deleted file mode 100644
index 7342c2883..000000000
--- a/src/org/apache/fop/tools/anttasks/CompileXMLFiles.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.tools.anttasks;
-
-/**
- * This class is an extension of Ant, a script utility from
- * jakarta.apache.org.
- * It takes a couple of xml files conforming to the xml-site dtd and
- * writes them all into one xml file, deleting any reference to
- * the proprietary protocol sbk. The configFile determines what files
- * are read in what sequence.
- */
-// Ant
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-
-
-// SAX
-import org.xml.sax.Parser;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.Locator;
-import org.xml.sax.AttributeList;
-
-// Java
-import java.io.*;
-import java.util.*;
-import java.net.URL;
-
-public class CompileXMLFiles extends Task
- implements org.xml.sax.EntityResolver, org.xml.sax.DTDHandler,
- org.xml.sax.DocumentHandler, org.xml.sax.ErrorHandler {
- private String configFile, outFile;
- private String[] filenameList;
- private String filenames;
- private ArrayList files = new ArrayList();
-
- // sets name of configuration file, which must
- // be an xml file conforming to the book.dtd used by xml-site
- public void setConfigFile(String configFile) {
- this.configFile = configFile;
- }
-
- public void setOutFile(String outFile) {
- this.outFile = outFile;
- }
-
-
- // main method of this task
- public void execute() throws BuildException {
- boolean errors = false;
-
- if (!(new File(configFile).exists())) {
- errors = true;
- System.err.println("Task CompileXMLFiles - ERROR: config file "
- + configFile + " is missing.");
- }
-
- Parser parser = createParser();
-
- if (parser == null) {
- System.err.println("Task CompileXMLFiles - ERROR: Unable to create SAX parser");
- errors = true;
- }
- parser.setDocumentHandler(this);
- try {
- parser.parse(CompileXMLFiles.fileInputSource(configFile));
- } catch (SAXException e) {
- System.out.println(e);
- } catch (IOException ioe) {
- System.out.println(ioe);
- }
- } // end: execute()
-
-
- /* the following methods belong to the sax parser and implement the Document Handler */
- public InputSource resolveEntity(String publicId,
- String systemId) throws SAXException {
- return null;
- }
-
- public void notationDecl(String name, String publicId, String systemId) {
- // no op
- }
-
- public void unparsedEntityDecl(String name, String publicId,
- String systemId, String notationName) {
- // no op
- }
-
- public void setDocumentLocator(Locator locator) {
- // no op
- }
-
- public void startDocument() throws SAXException {
- // no op
- }
-
- /*
- * After the cnfiguration file has been parsed all files which
- * have been collected in the ArrayList files are concatinated
- * and written to a new (temporary) file
- */
- public void endDocument() throws SAXException {
- String line, filename;
- BufferedReader in;
- try {
- BufferedWriter out =
- new BufferedWriter(new FileWriter("compileXMLFiles-tmp.xml"));
- out.write("<?xml version=\"1.0\"?>\n"
- + "<!DOCTYPE documentation [\n"
- + "<!ENTITY nbsp \" \">\n" + "]>\n<documentation>");
- for(int count = 0; count < files.size(); count++) {
- filename = (String)files.get(count);
- in = new BufferedReader(new FileReader(filename));
- while ((line = in.readLine()) != null) {
- // kill the lines pointing to the sbk protocol and the xml declaration
- if (line.indexOf("<!DOCTYPE ") != -1
- || line.indexOf("<?xml ") != -1) {
- line = "";
- }
- out.write(line + "\n");
- }
- out.flush();
- }
- out.write("\n</documentation>");
- out.close();
- } catch (Exception e) {
- System.out.println(e);
- }
-
- }
-
- public void startElement(String name,
- AttributeList atts) throws SAXException {
- String id, label, source;
- if (name.equals("document") || name.equals("entry")) {
- source = atts.getValue("source");
- files.add(source);
- }
- }
-
- public void endElement(String name) throws SAXException {
- // no op
- }
-
- public void characters(char ch[], int start,
- int length) throws SAXException {
- // no op
- }
-
- public void ignorableWhitespace(char ch[], int start,
- int length) throws SAXException {
- // no op
- }
-
- public void processingInstruction(String target,
- String data) throws SAXException {
- // no op
- }
-
- public void warning(SAXParseException e) throws SAXException {
- // no op
- }
-
- public void error(SAXParseException e) throws SAXException {
- // no op
- }
-
- public void fatalError(SAXParseException e) throws SAXException {
- throw e;
- }
-
- /* ------------------------ */
-
- /**
- * creates a SAX parser, using the value of org.xml.sax.parser
- * defaulting to org.apache.xerces.parsers.SAXParser
- *
- * @return the created SAX parser
- */
- static Parser createParser() {
- String parserClassName = System.getProperty("org.xml.sax.parser");
- if (parserClassName == null) {
- parserClassName = "org.apache.xerces.parsers.SAXParser";
- }
- System.err.println("using SAX parser " + parserClassName);
-
- try {
- return (Parser)Class.forName(parserClassName).newInstance();
- } catch (ClassNotFoundException e) {
- System.err.println("Could not find " + parserClassName);
- } catch (InstantiationException e) {
- System.err.println("Could not instantiate " + parserClassName);
- } catch (IllegalAccessException e) {
- System.err.println("Could not access " + parserClassName);
- } catch (ClassCastException e) {
- System.err.println(parserClassName + " is not a SAX driver");
- }
- return null;
- }
-
- /**
- * create an InputSource from a file name
- *
- * @param filename the name of the file
- * @return the InputSource created
- */
- protected static InputSource fileInputSource(String filename) {
-
- /* this code adapted from James Clark's in XT */
- File file = new File(filename);
- String path = file.getAbsolutePath();
- String fSep = System.getProperty("file.separator");
- if (fSep != null && fSep.length() == 1)
- path = path.replace(fSep.charAt(0), '/');
- if (path.length() > 0 && path.charAt(0) != '/')
- path = '/' + path;
- try {
- return new InputSource(new URL("file", null, path).toString());
- } catch (java.net.MalformedURLException e) {
- throw new Error("unexpected MalformedURLException");
- }
- }
-
-}
-
diff --git a/src/org/apache/fop/tools/anttasks/RunTest.java b/src/org/apache/fop/tools/anttasks/RunTest.java
index 53e58f89b..78d19ca07 100644
--- a/src/org/apache/fop/tools/anttasks/RunTest.java
+++ b/src/org/apache/fop/tools/anttasks/RunTest.java
@@ -76,15 +76,15 @@ public class RunTest extends Task {
ClassLoader loader = new URLClassLoader(new URL[] {
new URL("file:build/fop.jar")
});
- Hashtable diff = runConverter(loader, "areatree",
+ HashMap diff = runConverter(loader, "areatree",
"reference/output/");
if (diff != null &&!diff.isEmpty()) {
System.out.println("====================================");
System.out.println("The following files differ:");
boolean broke = false;
- for (Enumeration keys = diff.keys();
- keys.hasMoreElements(); ) {
- Object fname = keys.nextElement();
+ for (Iterator keys = diff.keySet().iterator();
+ keys.hasNext(); ) {
+ Object fname = keys.next();
Boolean pass = (Boolean)diff.get(fname);
System.out.println("file: " + fname
+ " - reference success: " + pass);
@@ -165,11 +165,11 @@ public class RunTest extends Task {
* file in the base directory.
* @param loader the class loader to use to run the tests with
*/
- protected Hashtable runConverter(ClassLoader loader, String dest,
+ protected HashMap runConverter(ClassLoader loader, String dest,
String compDir) {
String converter = "org.apache.fop.tools.TestConverter";
- Hashtable diff = null;
+ HashMap diff = null;
try {
Class cla = Class.forName(converter, true, loader);
Object tc = cla.newInstance();
@@ -185,7 +185,7 @@ public class RunTest extends Task {
meth = cla.getMethod("runTests", new Class[] {
String.class, String.class, String.class
});
- diff = (Hashtable)meth.invoke(tc, new Object[] {
+ diff = (HashMap)meth.invoke(tc, new Object[] {
testsuite, dest, compDir
});
} catch (Exception e) {