From 8ac435580866f05c9c9c1fbe2e30e030b0587c0a Mon Sep 17 00:00:00 2001 From: Rainer Klute Date: Mon, 16 May 2005 21:39:22 +0000 Subject: [PATCH] - Improved the build process' with respect to its dependencies on JUnit, JDepend and an XSLT processor. - Included DDF in the generated javadoc API documentation. - Excluded the obsolete HDF from the generated javadoc API documentation. - Included the CLASSPATH environment variable in the javadoc classpath so that references to third-party packages can be resolved. - Removed all explicit references to Xalan and changed the HSSF record generator to use any XSLT processor. However, that stuff seems to be very much out of date: The XSL stylesheet won't compile even after an obvious fix. Thus my modifications are untested but that stuff won't work anyway. I doubt it is important. - Did some beautifications on the build.xml file. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353683 13f79535-47bb-0310-9956-ffa450edef68 --- ant.dtd | 54 +- build.xml | 524 ++++++++++-------- .../org/apache/poi/dev/RecordGenerator.java | 66 ++- src/records/styles/record.xsl | 12 +- .../apache/poi/generator/FieldIterator.java | 6 - 5 files changed, 364 insertions(+), 298 deletions(-) diff --git a/ant.dtd b/ant.dtd index 9f3ad3cf8f..fc2ddcd637 100644 --- a/ant.dtd +++ b/ant.dtd @@ -1,6 +1,6 @@ - + @@ -3556,38 +3556,6 @@ file CDATA #IMPLIED description CDATA #IMPLIED> - - - - - - - - - - - - + + + - + - @@ -573,9 +591,9 @@ FORREST_HOME environment variable! @@ -591,7 +609,8 @@ FORREST_HOME environment variable! - @@ -610,21 +629,18 @@ FORREST_HOME environment variable! - - + + @@ -633,11 +649,12 @@ FORREST_HOME environment variable! - + + POI API Documentation]]> @@ -645,13 +662,30 @@ FORREST_HOME environment variable! Copyright ${tstamp.year} The Apache Software Foundation or its licensors, as applicable.]]> - - - - - - - + + DDF - Dreadful Drawing Format + + + + HPSF - Horrible Property Set Format + + + + HSSF - Horrible Spreadsheet Format + + + + HWPF - Horrible Word Processor Format + + + + POIFS - POI File System + + + + Utilities + + Examples @@ -660,53 +694,48 @@ FORREST_HOME environment variable! - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + @@ -758,60 +787,62 @@ FORREST_HOME environment variable! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Distribution located in build/dist - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Distribution located in build/dist + - + - + - + - + @@ -819,17 +850,16 @@ FORREST_HOME environment variable! - - + - + - + JUnit is not available. You must download JUnit from <http://www.junit.org/> and include the JAR file in your @@ -838,17 +868,34 @@ FORREST_HOME environment variable! + + + + + + + + + + + WARNING: Since JUnit is not available you might encounter failures + subsequently. In order to avoid this you should download JUnit from + <http://www.junit.org/> and include the JAR file in your + classpath. + + + - + - + - + JDepend is not available. You must download JDepend from <http://www.clarkware.com/software/JDepend.html> and include the @@ -859,34 +906,51 @@ FORREST_HOME environment variable! - - + + - - - - + - + - + - The Xalan XSLT processor is not available. You must download Xalan from + An XSLT processor is missing. You must download e.g. Xalan from <http://xml.apache.org/xalan-j/> and include the JAR file in your classpath. - + + + + + + + + + + + + WARNING: Since an XSLT processor is not available you might encounter + failures subsequently. In order to avoid this you should download + e.g. Xalan from <http://xml.apache.org/xalan-j/> and include the + JAR file in your classpath. + + + + + + + + - diff --git a/src/java/org/apache/poi/dev/RecordGenerator.java b/src/java/org/apache/poi/dev/RecordGenerator.java index 345f609e57..870183a7a7 100644 --- a/src/java/org/apache/poi/dev/RecordGenerator.java +++ b/src/java/org/apache/poi/dev/RecordGenerator.java @@ -17,12 +17,24 @@ package org.apache.poi.dev; -import org.w3c.dom.Document; -import org.w3c.dom.Element; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.Reader; +import java.util.Properties; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Result; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; /** * Description of the Class @@ -79,11 +91,7 @@ public class RecordGenerator { File destinationPathFile = new File(destinationPath); destinationPathFile.mkdirs(); String destinationFilepath = destinationPath + "/" + recordName + suffix + ".java"; - String args[] = new String[]{"-in", file.getAbsolutePath(), "-xsl", recordStyleDir + "/" + extendstg.toLowerCase() + ".xsl", - "-out", destinationFilepath, - "-TEXT"}; - - org.apache.xalan.xslt.Process.main(args); + transform(file, new File(destinationFilepath), new File(recordStyleDir + "/" + extendstg.toLowerCase() + ".xsl")); System.out.println("Generated " + suffix + ": " + destinationFilepath); // Generate test (if not already generated) @@ -93,11 +101,7 @@ public class RecordGenerator { destinationFilepath = destinationPath + "/Test" + recordName + suffix + ".java"; if (new File(destinationFilepath).exists() == false) { String temp = (recordStyleDir + "/" + extendstg.toLowerCase() + "_test.xsl"); - args = new String[]{"-in", file.getAbsolutePath(), "-xsl", - temp, - "-out", destinationFilepath, - "-TEXT"}; - org.apache.xalan.xslt.Process.main(args); + transform(file, new File(destinationFilepath), new File(temp)); System.out.println("Generated test: " + destinationFilepath); } else { System.out.println("Skipped test generation: " + destinationFilepath); @@ -105,4 +109,40 @@ public class RecordGenerator { } } } + + + + /** + *

Executes an XSL transformation. This process transforms an XML input + * file into a text output file controlled by an XSLT specification.

+ * + * @param in the XML input file + * @param out the text output file + * @param xslt the XSLT specification, i.e. an XSL style sheet + * @throws FileNotFoundException + * @throws TransformerException + */ + private static void transform(final File in, final File out, final File xslt) + throws FileNotFoundException, TransformerException + { + final Reader r = new FileReader(xslt); + final StreamSource ss = new StreamSource(r); + final TransformerFactory tf = TransformerFactory.newInstance(); + final Transformer t; + try + { + t = tf.newTransformer(ss); + } + catch (TransformerException ex) + { + System.err.println("Error compiling XSL style sheet " + xslt); + throw ex; + } + final Properties p = new Properties(); + p.setProperty(OutputKeys.METHOD, "text"); + t.setOutputProperties(p); + final Result result = new StreamResult(out); + t.transform(new StreamSource(in), result); + } + } diff --git a/src/records/styles/record.xsl b/src/records/styles/record.xsl index da9f851f35..e9615d7fda 100644 --- a/src/records/styles/record.xsl +++ b/src/records/styles/record.xsl @@ -115,9 +115,9 @@ public class Record int pos = 0; - + - ; + ; } @@ -137,9 +137,9 @@ public class Record LittleEndian.putShort(data, 0 + offset, sid); LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); - + - + return getRecordSize(); @@ -150,10 +150,10 @@ public class Record */ public int getRecordSize() { - + return 4 - + ; } diff --git a/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java b/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java index 927e8d4772..a7a97b59ca 100644 --- a/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java +++ b/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java @@ -32,12 +32,6 @@ public class FieldIterator { } - public void init(org.apache.xalan.extensions.XSLProcessorContext context, - org.apache.xalan.templates.ElemExtensionCall extElem) - { - offset = 0; - } - /** * This utility function returns a fill method entry for a given field * -- 2.39.5