diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2008-07-24 09:35:34 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2008-07-24 09:35:34 +0000 |
commit | 92df262a0778ee539c849454be2810621dac1b7e (patch) | |
tree | d5be9359cbacb91dffcab6f1a6ecfe61e9db2c6b /examples/embedding | |
parent | 30e2ce5bee38cbc32758e0b65fa7f98f3db76baa (diff) | |
download | xmlgraphics-fop-92df262a0778ee539c849454be2810621dac1b7e.tar.gz xmlgraphics-fop-92df262a0778ee539c849454be2810621dac1b7e.zip |
Fed up with all those trailing whitespaces. Let's remove them all (once... and for all?)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@679326 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'examples/embedding')
22 files changed, 268 insertions, 268 deletions
diff --git a/examples/embedding/java/embedding/ExampleAWTViewer.java b/examples/embedding/java/embedding/ExampleAWTViewer.java index 716ea1487..9822e47e5 100644 --- a/examples/embedding/java/embedding/ExampleAWTViewer.java +++ b/examples/embedding/java/embedding/ExampleAWTViewer.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; //Java diff --git a/examples/embedding/java/embedding/ExampleDOM2PDF.java b/examples/embedding/java/embedding/ExampleDOM2PDF.java index 9caa5b72a..6bf05827c 100644 --- a/examples/embedding/java/embedding/ExampleDOM2PDF.java +++ b/examples/embedding/java/embedding/ExampleDOM2PDF.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; // Java @@ -55,7 +55,7 @@ public class ExampleDOM2PDF { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + /** xsl-fo namespace URI */ protected static String foNS = "http://www.w3.org/1999/XSL/Format"; @@ -68,31 +68,31 @@ public class ExampleDOM2PDF { try { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired - + // Setup output OutputStream out = new java.io.FileOutputStream(pdf); out = new java.io.BufferedOutputStream(out); - + try { // Construct fop with desired output format and output stream Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); - + // Setup Identity Transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input for XSLT transformation Source src = new DOMSource(xslfoDoc); - + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); - + // Start XSLT transformation and FOP processing transformer.transform(src, res); } finally { out.close(); } - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); @@ -107,24 +107,24 @@ public class ExampleDOM2PDF { public static void main(String[] args) { try { System.out.println("FOP ExampleDOM2PDF\n"); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - + //Setup output file File pdffile = new File(outDir, "ResultDOM2PDF.pdf"); System.out.println("PDF Output File: " + pdffile); System.out.println(); - + Document foDoc = buildDOMDocument(); - + ExampleDOM2PDF app = new ExampleDOM2PDF(); app.convertDOM2PDF(foDoc, pdffile); - + System.out.println("Success!"); - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); @@ -140,15 +140,15 @@ public class ExampleDOM2PDF { // Create a sample XSL-FO DOM document Document foDoc = null; Element root = null, ele1 = null, ele2 = null, ele3 = null; - + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); foDoc = db.newDocument(); - + root = foDoc.createElementNS(foNS, "fo:root"); foDoc.appendChild(root); - + ele1 = foDoc.createElementNS(foNS, "fo:layout-master-set"); root.appendChild(ele1); ele2 = foDoc.createElementNS(foNS, "fo:simple-page-master"); @@ -178,7 +178,7 @@ public class ExampleDOM2PDF { * @param newNodeName name of the new node * @param textVal content of the element */ - protected static void addElement(Node parent, String newNodeName, + protected static void addElement(Node parent, String newNodeName, String textVal) { if (textVal == null) { return; diff --git a/examples/embedding/java/embedding/ExampleFO2JPSPrint.java b/examples/embedding/java/embedding/ExampleFO2JPSPrint.java index a67e2bdad..4f18b71ab 100644 --- a/examples/embedding/java/embedding/ExampleFO2JPSPrint.java +++ b/examples/embedding/java/embedding/ExampleFO2JPSPrint.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; // Java @@ -54,12 +54,12 @@ public class ExampleFO2JPSPrint { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + private DocPrintJob createDocPrintJob() { PrintService[] services = PrintServiceLookup.lookupPrintServices( DocFlavor.SERVICE_FORMATTED.PAGEABLE, null); PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); - PrintService printService = ServiceUI.printDialog(null, 50, 50, + PrintService printService = ServiceUI.printDialog(null, 50, 50, services, services[0], null, attributes); if (printService != null) { return printService.createPrintJob(); @@ -67,7 +67,7 @@ public class ExampleFO2JPSPrint { return null; } } - + /** * Prints an FO file using JPS. * @param fo the FO file @@ -78,7 +78,7 @@ public class ExampleFO2JPSPrint { */ public void printFO(File fo) throws IOException, FOPException, TransformerException, PrintException { - + //Set up DocPrintJob instance DocPrintJob printJob = createDocPrintJob(); @@ -88,20 +88,20 @@ public class ExampleFO2JPSPrint { PageableRenderer renderer = new PageableRenderer(); renderer.setUserAgent(userAgent); userAgent.setRendererOverride(renderer); - + // Construct FOP with desired output format Fop fop = fopFactory.newFop(userAgent); // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); - + // Start XSLT transformation and FOP processing transformer.transform(src, res); @@ -117,23 +117,23 @@ public class ExampleFO2JPSPrint { try { System.out.println("FOP ExampleFO2JPSPrint\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); System.out.println("Input: XSL-FO (" + fofile + ")"); System.out.println("Output: JPS (Java Printing System)"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2JPSPrint app = new ExampleFO2JPSPrint(); app.printFO(fofile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java b/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java index d9bc1d11d..885482dfb 100644 --- a/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java +++ b/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; // Java @@ -44,7 +44,7 @@ public class ExampleFO2OldStylePrint { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + /** * Prints an FO file using an old-style PrinterJob. * @param fo the FO file @@ -52,7 +52,7 @@ public class ExampleFO2OldStylePrint { * @throws FOPException In case of a FOP problem */ public void printFO(File fo) throws IOException, FOPException { - + //Set up PrinterJob instance PrinterJob printerJob = PrinterJob.getPrinterJob(); printerJob.setJobName("FOP Printing Example"); @@ -68,13 +68,13 @@ public class ExampleFO2OldStylePrint { // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); - + // Start XSLT transformation and FOP processing transformer.transform(src, res); @@ -93,23 +93,23 @@ public class ExampleFO2OldStylePrint { try { System.out.println("FOP ExampleFO2OldStylePrint\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); System.out.println("Input: XSL-FO (" + fofile + ")"); System.out.println("Output: old-style printing using PrinterJob"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2OldStylePrint app = new ExampleFO2OldStylePrint(); app.printFO(fofile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleFO2PDF.java b/examples/embedding/java/embedding/ExampleFO2PDF.java index 3b239f11b..6ae674908 100644 --- a/examples/embedding/java/embedding/ExampleFO2PDF.java +++ b/examples/embedding/java/embedding/ExampleFO2PDF.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; // Java @@ -60,13 +60,13 @@ public class ExampleFO2PDF { * @throws FOPException In case of a FOP problem */ public void convertFO2PDF(File fo, File pdf) throws IOException, FOPException { - + OutputStream out = null; - + try { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired - + // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). out = new FileOutputStream(pdf); @@ -78,24 +78,24 @@ public class ExampleFO2PDF { // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); - + // Start XSLT transformation and FOP processing transformer.transform(src, res); - + // Result processing FormattingResults foResults = fop.getResults(); java.util.List pageSequences = foResults.getPageSequences(); for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); - System.out.println("PageSequence " - + (String.valueOf(pageSequenceResults.getID()).length() > 0 - ? pageSequenceResults.getID() : "<no id>") + System.out.println("PageSequence " + + (String.valueOf(pageSequenceResults.getID()).length() > 0 + ? pageSequenceResults.getID() : "<no id>") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); @@ -117,13 +117,13 @@ public class ExampleFO2PDF { try { System.out.println("FOP ExampleFO2PDF\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); //File fofile = new File(baseDir, "../fo/pagination/franklin_2pageseqs.fo"); File pdffile = new File(outDir, "ResultFO2PDF.pdf"); @@ -132,10 +132,10 @@ public class ExampleFO2PDF { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2PDF app = new ExampleFO2PDF(); app.convertFO2PDF(fofile, pdffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java b/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java index c9422e1b9..e49eaed24 100644 --- a/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java +++ b/examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; // Java @@ -69,13 +69,13 @@ public class ExampleFO2PDFUsingSAXParser { // configure foUserAgent as desired OutputStream out = null; - + try { // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). out = new FileOutputStream(pdf); out = new BufferedOutputStream(out); - + // Construct fop and setup output format Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); @@ -85,7 +85,7 @@ public class ExampleFO2PDFUsingSAXParser { factory.setNamespaceAware(true); // throws ParserConfigurationException SAXParser parser = factory.newSAXParser(); - + // Obtain FOP's DefaultHandler // throws FOPException DefaultHandler dh = fop.getDefaultHandler(); @@ -108,13 +108,13 @@ public class ExampleFO2PDFUsingSAXParser { try { System.out.println("FOP ExampleFO2PDFUsingSAXParser\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); File pdffile = new File(outDir, "ResultFO2PDFUsingSAXParser.pdf"); @@ -122,10 +122,10 @@ public class ExampleFO2PDFUsingSAXParser { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2PDFUsingSAXParser app = new ExampleFO2PDFUsingSAXParser(); app.convertFO2PDF(fofile, pdffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleFO2RTF.java b/examples/embedding/java/embedding/ExampleFO2RTF.java index b33fb13b8..68d63304f 100644 --- a/examples/embedding/java/embedding/ExampleFO2RTF.java +++ b/examples/embedding/java/embedding/ExampleFO2RTF.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; // Java @@ -60,12 +60,12 @@ public class ExampleFO2RTF { * @throws FOPException In case of a FOP problem */ public void convertFO2RTF(File fo, File rtf) throws IOException, FOPException { - + FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired OutputStream out = null; - + try { // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). @@ -74,25 +74,25 @@ public class ExampleFO2RTF { // Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, foUserAgent, out); - + // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); - + // Start XSLT transformation and FOP processing transformer.transform(src, res); - + // Please note: getResults() won't work for RTF and other flow formats (like MIF) // as the layout engine is not involved in the conversion. The page-breaking // is done by the application opening the generated file (like MS Word). //FormattingResults foResults = fop.getResults(); - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); @@ -110,13 +110,13 @@ public class ExampleFO2RTF { try { System.out.println("FOP ExampleFO2RTF\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File fofile = new File(baseDir, "xml/fo/helloworld.fo"); File rtffile = new File(outDir, "ResultFO2RTF.rtf"); @@ -124,10 +124,10 @@ public class ExampleFO2RTF { System.out.println("Output: PDF (" + rtffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleFO2RTF app = new ExampleFO2RTF(); app.convertFO2RTF(fofile, rtffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleObj2PDF.java b/examples/embedding/java/embedding/ExampleObj2PDF.java index c3dcbc5d6..666b7e433 100644 --- a/examples/embedding/java/embedding/ExampleObj2PDF.java +++ b/examples/embedding/java/embedding/ExampleObj2PDF.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; // Java @@ -43,7 +43,7 @@ import org.apache.fop.apps.MimeConstants; import embedding.model.ProjectTeam; /** - * This class demonstrates the conversion of an arbitrary object file to a + * This class demonstrates the conversion of an arbitrary object file to a * PDF using JAXP (XSLT) and FOP (XSL:FO). */ public class ExampleObj2PDF { @@ -60,9 +60,9 @@ public class ExampleObj2PDF { * @throws FOPException In case of a FOP problem * @throws TransformerException In case of a XSL transformation problem */ - public void convertProjectTeam2PDF(ProjectTeam team, File xslt, File pdf) + public void convertProjectTeam2PDF(ProjectTeam team, File xslt, File pdf) throws IOException, FOPException, TransformerException { - + FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired @@ -76,10 +76,10 @@ public class ExampleObj2PDF { // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xslt)); - + // Setup input for XSLT transformation Source src = team.getSourceForProjectTeam(); - + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); @@ -99,7 +99,7 @@ public class ExampleObj2PDF { try { System.out.println("FOP ExampleObj2PDF\n"); System.out.println("Preparing..."); - + // Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); @@ -117,7 +117,7 @@ public class ExampleObj2PDF { ExampleObj2PDF app = new ExampleObj2PDF(); app.convertProjectTeam2PDF(ExampleObj2XML.createSampleProjectTeam(), xsltfile, pdffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleObj2XML.java b/examples/embedding/java/embedding/ExampleObj2XML.java index 90f9ba5b0..71a027192 100644 --- a/examples/embedding/java/embedding/ExampleObj2XML.java +++ b/examples/embedding/java/embedding/ExampleObj2XML.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; //Hava @@ -36,7 +36,7 @@ import embedding.model.ProjectTeam; /** - * This class demonstrates the conversion of an arbitrary object file to an + * This class demonstrates the conversion of an arbitrary object file to an * XML file. */ public class ExampleObj2XML { @@ -48,20 +48,20 @@ public class ExampleObj2XML { * @throws IOException In case of an I/O problem * @throws TransformerException In case of a XSL transformation problem */ - public void convertProjectTeam2XML(ProjectTeam team, File xml) + public void convertProjectTeam2XML(ProjectTeam team, File xml) throws IOException, TransformerException { - + //Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); /* Note: We use the identity transformer, no XSL transformation is done. - The transformer is basically just used to serialize the + The transformer is basically just used to serialize the generated document to XML. */ - + //Setup input Source src = team.getSourceForProjectTeam(); - + //Setup output Result res = new StreamResult(xml); @@ -97,7 +97,7 @@ public class ExampleObj2XML { try { System.out.println("FOP ExampleObj2XML\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); @@ -113,7 +113,7 @@ public class ExampleObj2XML { ExampleObj2XML app = new ExampleObj2XML(); app.convertProjectTeam2XML(createSampleProjectTeam(), xmlfile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleSVG2PDF.java b/examples/embedding/java/embedding/ExampleSVG2PDF.java index ca0f46146..d152db7ae 100644 --- a/examples/embedding/java/embedding/ExampleSVG2PDF.java +++ b/examples/embedding/java/embedding/ExampleSVG2PDF.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; //Java @@ -47,22 +47,22 @@ public class ExampleSVG2PDF { * @throws TranscoderException In case of a transcoding problem */ public void convertSVG2PDF(File svg, File pdf) throws IOException, TranscoderException { - + //Create transcoder Transcoder transcoder = new PDFTranscoder(); //Transcoder transcoder = new org.apache.fop.render.ps.PSTranscoder(); - + //Setup input InputStream in = new java.io.FileInputStream(svg); try { TranscoderInput input = new TranscoderInput(in); - + //Setup output OutputStream out = new java.io.FileOutputStream(pdf); out = new java.io.BufferedOutputStream(out); try { TranscoderOutput output = new TranscoderOutput(out); - + //Do the transformation transcoder.transcode(input, output); } finally { @@ -82,13 +82,13 @@ public class ExampleSVG2PDF { try { System.out.println("FOP ExampleSVG2PDF\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File svgfile = new File(baseDir, "xml/svg/helloworld.svg"); File pdffile = new File(outDir, "ResultSVG2PDF.pdf"); @@ -96,10 +96,10 @@ public class ExampleSVG2PDF { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleSVG2PDF app = new ExampleSVG2PDF(); app.convertSVG2PDF(svgfile, pdffile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleXML2FO.java b/examples/embedding/java/embedding/ExampleXML2FO.java index 07b946435..c5638c45b 100644 --- a/examples/embedding/java/embedding/ExampleXML2FO.java +++ b/examples/embedding/java/embedding/ExampleXML2FO.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; //Java @@ -47,19 +47,19 @@ public class ExampleXML2FO { * @throws IOException In case of an I/O problem * @throws TransformerException In case of a XSL transformation problem */ - public void convertXML2FO(File xml, File xslt, File fo) + public void convertXML2FO(File xml, File xslt, File fo) throws IOException, TransformerException { - + //Setup output OutputStream out = new java.io.FileOutputStream(fo); try { //Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xslt)); - + //Setup input for XSLT transformation Source src = new StreamSource(xml); - + //Resulting SAX events (the generated FO) must be piped through to FOP Result res = new StreamResult(out); @@ -85,7 +85,7 @@ public class ExampleXML2FO { File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + //Setup input and output files File xmlfile = new File(baseDir, "xml/xml/projectteam.xml"); File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl"); File fofile = new File(outDir, "ResultXML2FO.fo"); @@ -95,10 +95,10 @@ public class ExampleXML2FO { System.out.println("Output: XSL-FO (" + fofile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleXML2FO app = new ExampleXML2FO(); app.convertXML2FO(xmlfile, xsltfile, fofile); - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/ExampleXML2PDF.java b/examples/embedding/java/embedding/ExampleXML2PDF.java index 2769b032a..a7c8e2a41 100644 --- a/examples/embedding/java/embedding/ExampleXML2PDF.java +++ b/examples/embedding/java/embedding/ExampleXML2PDF.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; //Java @@ -38,7 +38,7 @@ import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.MimeConstants; /** - * This class demonstrates the conversion of an XML file to PDF using + * This class demonstrates the conversion of an XML file to PDF using * JAXP (XSLT) and FOP (XSL-FO). */ public class ExampleXML2PDF { @@ -57,7 +57,7 @@ public class ExampleXML2PDF { File outDir = new File(baseDir, "out"); outDir.mkdirs(); - // Setup input and output files + // Setup input and output files File xmlfile = new File(baseDir, "xml/xml/projectteam.xml"); File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl"); File pdffile = new File(outDir, "ResultXML2PDF.pdf"); @@ -67,7 +67,7 @@ public class ExampleXML2PDF { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + // configure fopFactory as desired FopFactory fopFactory = FopFactory.newInstance(); @@ -77,30 +77,30 @@ public class ExampleXML2PDF { // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); out = new java.io.BufferedOutputStream(out); - + try { // Construct fop with desired output format Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); - + // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xsltfile)); - + // Set the value of a <param> in the stylesheet transformer.setParameter("versionParam", "2.0"); - + // Setup input for XSLT transformation Source src = new StreamSource(xmlfile); - + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); - + // Start XSLT transformation and FOP processing transformer.transform(src, res); } finally { out.close(); } - + System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(System.err); diff --git a/examples/embedding/java/embedding/MultipleFO2PDF.java b/examples/embedding/java/embedding/MultipleFO2PDF.java index 7a30f0905..a9ace7cf0 100644 --- a/examples/embedding/java/embedding/MultipleFO2PDF.java +++ b/examples/embedding/java/embedding/MultipleFO2PDF.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding; // Java @@ -59,26 +59,26 @@ public class MultipleFO2PDF { // JAXP TransformerFactory can be reused, too private TransformerFactory factory = TransformerFactory.newInstance(); - + /** * Converts an FO file to a PDF file using FOP * @param fo the FO file * @param pdf the target PDF file - * @throws TransformerException in case of a transformation problem + * @throws TransformerException in case of a transformation problem * @throws IOException in case of an I/O problem * @throws FOPException in case of a FOP problem * @return the formatting results of the run */ - public FormattingResults convertFO2PDF(File fo, File pdf) + public FormattingResults convertFO2PDF(File fo, File pdf) throws TransformerException, IOException, FOPException { - + OutputStream out = null; Fop fop; - + try { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired - + // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). out = new FileOutputStream(pdf); @@ -89,13 +89,13 @@ public class MultipleFO2PDF { // Setup JAXP using identity transformer Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); - + // Start XSLT transformation and FOP processing transformer.transform(src, res); } finally { @@ -105,7 +105,7 @@ public class MultipleFO2PDF { return fop.getResults(); } - /** + /** * Listens on standard in for names of fo files to be transformed to pdf. * 'quit' or the null string (for piped input) cause the listener to stop listening. */ @@ -116,10 +116,10 @@ public class MultipleFO2PDF { File outDir = new File(baseDir, "out"); outDir.mkdirs(); BufferedReader in = new BufferedReader(new java.io.InputStreamReader(System.in)); - + while (true) { try { - // Listen for the input file name + // Listen for the input file name System.out.print("Input XSL-FO file ('quit' to stop): "); String foname = in.readLine(); if (foname == null) { @@ -146,9 +146,9 @@ public class MultipleFO2PDF { java.util.List pageSequences = foResults.getPageSequences(); for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();) { PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next(); - System.out.println("PageSequence " - + (String.valueOf(pageSequenceResults.getID()).length() > 0 - ? pageSequenceResults.getID() : "<no id>") + System.out.println("PageSequence " + + (String.valueOf(pageSequenceResults.getID()).length() > 0 + ? pageSequenceResults.getID() : "<no id>") + " generated " + pageSequenceResults.getPageCount() + " pages."); } System.out.println("Generated " + foResults.getPageCount() + " pages in total."); @@ -161,7 +161,7 @@ public class MultipleFO2PDF { } } } - + /** * Main method. Set up the listener. * @param args command-line arguments diff --git a/examples/embedding/java/embedding/events/ExampleEvents.java b/examples/embedding/java/embedding/events/ExampleEvents.java index 9c52e4ba1..4f0b5c0c2 100644 --- a/examples/embedding/java/embedding/events/ExampleEvents.java +++ b/examples/embedding/java/embedding/events/ExampleEvents.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.events; import java.io.BufferedOutputStream; @@ -68,21 +68,21 @@ public class ExampleEvents { */ public void convertFO2PDF(URL fo, File pdf) throws IOException, FOPException, TransformerException { - + OutputStream out = null; - + try { //Create the user agent for this processing run FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - + //Adding a simple logging listener that writes to stdout and stderr foUserAgent.getEventBroadcaster().addEventListener(new SysOutEventListener()); - + // Add your own event listener foUserAgent.getEventBroadcaster().addEventListener(new MyEventListener()); - + // configure foUserAgent further as desired - + // Setup output stream. Note: Using BufferedOutputStream // for performance reasons (helpful with FileOutputStreams). out = new FileOutputStream(pdf); @@ -94,13 +94,13 @@ public class ExampleEvents { // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer - + // Setup input stream Source src = new StreamSource(fo.toExternalForm()); // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); - + // Start XSLT transformation and FOP processing transformer.transform(src, res); @@ -114,7 +114,7 @@ public class ExampleEvents { public void processEvent(Event event) { if ("org.apache.fop.events.ResourceEventProducer.imageNotFound" .equals(event.getEventID())) { - + //Get the FileNotFoundException that's part of the event's parameters FileNotFoundException fnfe = (FileNotFoundException)event.getParam("fnfe"); @@ -122,16 +122,16 @@ public class ExampleEvents { + "!!! ===---"); //Stop processing when an image could not be found. Otherwise, FOP would just //continue without the image! - + System.out.println("Throwing a RuntimeException..."); throw new RuntimeException(EventFormatter.format(event), fnfe); } else { //ignore all other events } } - + } - + /** A simple event listener that writes the events to stdout and sterr. */ private static class SysOutEventListener implements EventListener { @@ -152,7 +152,7 @@ public class ExampleEvents { } } } - + /** * This method extracts the original exception from some exception. The exception @@ -185,7 +185,7 @@ public class ExampleEvents { try { System.out.println("FOP ExampleEvents\n"); System.out.println("Preparing..."); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); @@ -199,9 +199,9 @@ public class ExampleEvents { System.out.println("Output: PDF (" + pdffile + ")"); System.out.println(); System.out.println("Transforming..."); - + ExampleEvents app = new ExampleEvents(); - + try { app.convertFO2PDF(fo, pdffile); } catch (TransformerException te) { @@ -215,7 +215,7 @@ public class ExampleEvents { System.out.println("Aborted!"); System.exit(-1); } - + System.out.println("Success!"); } catch (Exception e) { //Some other error (shouldn't happen in this example) diff --git a/examples/embedding/java/embedding/intermediate/ExampleConcat.java b/examples/embedding/java/embedding/intermediate/ExampleConcat.java index 07790309d..6967ebc8a 100644 --- a/examples/embedding/java/embedding/intermediate/ExampleConcat.java +++ b/examples/embedding/java/embedding/intermediate/ExampleConcat.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.intermediate; import java.io.File; @@ -81,26 +81,26 @@ public class ExampleConcat { * @throws FOPException In case of a FOP problem * @throws TransformerException In case of a XSL transformation problem */ - public void convertToIntermediate(Source src, Source xslt, File intermediate) + public void convertToIntermediate(Source src, Source xslt, File intermediate) throws IOException, FOPException, TransformerException { - + //Create a user agent FOUserAgent userAgent = fopFactory.newFOUserAgent(); - + //Create an instance of the target renderer so the XMLRenderer can use its font setup Renderer targetRenderer = userAgent.getRendererFactory().createRenderer( - userAgent, MimeConstants.MIME_PDF); - + userAgent, MimeConstants.MIME_PDF); + //Create the XMLRenderer to create the intermediate format (area tree XML) XMLRenderer xmlRenderer = new XMLRenderer(); xmlRenderer.setUserAgent(userAgent); - + //Tell the XMLRenderer to mimic the target renderer xmlRenderer.mimicRenderer(targetRenderer); - + //Make sure the prepared XMLRenderer is used userAgent.setRendererOverride(xmlRenderer); - + // Setup output OutputStream out = new java.io.FileOutputStream(intermediate); out = new java.io.BufferedOutputStream(out); @@ -117,7 +117,7 @@ public class ExampleConcat { } else { transformer = factory.newTransformer(); } - + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); @@ -136,7 +136,7 @@ public class ExampleConcat { * @throws TransformerException In case of a XSL transformation problem * @throws SAXException In case of an XML-related problem */ - public void concatToPDF(File[] files, File pdffile) + public void concatToPDF(File[] files, File pdffile) throws IOException, TransformerException, SAXException { // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); @@ -147,23 +147,23 @@ public class ExampleConcat { FOUserAgent userAgent = fopFactory.newFOUserAgent(); //Construct the AreaTreeModel that will received the individual pages - AreaTreeModel treeModel = new RenderPagesModel(userAgent, + AreaTreeModel treeModel = new RenderPagesModel(userAgent, MimeConstants.MIME_PDF, fontInfo, out); - + //Iterate over all intermediate files AreaTreeParser parser = new AreaTreeParser(); for (int i = 0; i < files.length; i++) { Source src = new StreamSource(files[i]); parser.parse(src, treeModel, userAgent); } - + //Signal the end of the processing. The renderer can finalize the target document. treeModel.endDocument(); } finally { out.close(); } } - + /** * Main method. * @param args command-line arguments @@ -171,12 +171,12 @@ public class ExampleConcat { public static void main(String[] args) { try { System.out.println("FOP ExampleConcat\n"); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - + //Setup output file File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl"); File[] files = new File[] { @@ -184,31 +184,31 @@ public class ExampleConcat { new File(outDir, "team2.at.xml")}; File pdffile = new File(outDir, "ResultConcat.pdf"); for (int i = 0; i < files.length; i++) { - System.out.println("Intermediate file " + (i + 1) + ": " + System.out.println("Intermediate file " + (i + 1) + ": " + files[i].getCanonicalPath()); } System.out.println("PDF Output File: " + pdffile.getCanonicalPath()); System.out.println(); - + ProjectTeam team1 = ExampleObj2XML.createSampleProjectTeam(); ProjectTeam team2 = createAnotherProjectTeam(); - + ExampleConcat app = new ExampleConcat(); - + //Create intermediate files app.convertToIntermediate( - team1.getSourceForProjectTeam(), + team1.getSourceForProjectTeam(), new StreamSource(xsltfile), files[0]); app.convertToIntermediate( - team2.getSourceForProjectTeam(), + team2.getSourceForProjectTeam(), new StreamSource(xsltfile), files[1]); - + //Concatenate the individual intermediate files to one document app.concatToPDF(files, pdffile); - + System.out.println("Success!"); - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); diff --git a/examples/embedding/java/embedding/intermediate/ExampleStamp.java b/examples/embedding/java/embedding/intermediate/ExampleStamp.java index b1b0b77e7..c6123b718 100644 --- a/examples/embedding/java/embedding/intermediate/ExampleStamp.java +++ b/examples/embedding/java/embedding/intermediate/ExampleStamp.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.intermediate; import java.io.File; @@ -50,7 +50,7 @@ public class ExampleStamp { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + /** * Stamps an intermediate file and renders it to a PDF file. * @param atfile the intermediate file (area tree XML) @@ -60,7 +60,7 @@ public class ExampleStamp { * @throws TransformerException In case of a XSL transformation problem * @throws SAXException In case of an XML-related problem */ - public void stampToPDF(File atfile, File stampSheet, File pdffile) + public void stampToPDF(File atfile, File stampSheet, File pdffile) throws IOException, TransformerException, SAXException { // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); @@ -71,31 +71,31 @@ public class ExampleStamp { FOUserAgent userAgent = fopFactory.newFOUserAgent(); //Construct the AreaTreeModel that will received the individual pages - AreaTreeModel treeModel = new RenderPagesModel(userAgent, + AreaTreeModel treeModel = new RenderPagesModel(userAgent, MimeConstants.MIME_PDF, fontInfo, out); - + //Iterate over all intermediate files AreaTreeParser parser = new AreaTreeParser(); Source src = new StreamSource(atfile); Source xslt = new StreamSource(stampSheet); - + //Setup Transformer for XSLT processing TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(xslt); - + //Send XSLT result to AreaTreeParser SAXResult res = new SAXResult(parser.getContentHandler(treeModel, userAgent)); - + //Start XSLT transformation and area tree parsing transformer.transform(src, res); - + //Signal the end of the processing. The renderer can finalize the target document. treeModel.endDocument(); } finally { out.close(); } } - + /** * Main method. * @param args command-line arguments @@ -103,12 +103,12 @@ public class ExampleStamp { public static void main(String[] args) { try { System.out.println("FOP ExampleConcat\n"); - + //Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - + //Setup output file File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl"); File atfile = new File(outDir, "team.at.xml"); @@ -120,19 +120,19 @@ public class ExampleStamp { System.out.println(); ProjectTeam team1 = ExampleObj2XML.createSampleProjectTeam(); - + //Create intermediate file ExampleConcat concatapp = new ExampleConcat(); concatapp.convertToIntermediate( - team1.getSourceForProjectTeam(), + team1.getSourceForProjectTeam(), new StreamSource(xsltfile), atfile); - + //Stamp document and produce a PDF from the intermediate format ExampleStamp app = new ExampleStamp(); app.stampToPDF(atfile, stampxsltfile, pdffile); - + System.out.println("Success!"); - + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); diff --git a/examples/embedding/java/embedding/model/ProjectMember.java b/examples/embedding/java/embedding/model/ProjectMember.java index 0efc6d514..4b602b87f 100644 --- a/examples/embedding/java/embedding/model/ProjectMember.java +++ b/examples/embedding/java/embedding/model/ProjectMember.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.model; /** @@ -34,8 +34,8 @@ public class ProjectMember { */ public ProjectMember() { } - - + + /** * Convenience constructor. * @param name name of the project member diff --git a/examples/embedding/java/embedding/model/ProjectTeam.java b/examples/embedding/java/embedding/model/ProjectTeam.java index 3dfceb3db..47ae2b569 100644 --- a/examples/embedding/java/embedding/model/ProjectTeam.java +++ b/examples/embedding/java/embedding/model/ProjectTeam.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.model; import java.util.List; diff --git a/examples/embedding/java/embedding/model/ProjectTeamInputSource.java b/examples/embedding/java/embedding/model/ProjectTeamInputSource.java index 2953f41d7..dd9d31236 100644 --- a/examples/embedding/java/embedding/model/ProjectTeamInputSource.java +++ b/examples/embedding/java/embedding/model/ProjectTeamInputSource.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.model; import org.xml.sax.InputSource; diff --git a/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java b/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java index c86f94f9a..b08351a86 100644 --- a/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java +++ b/examples/embedding/java/embedding/model/ProjectTeamXMLReader.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.model; //Java @@ -60,18 +60,18 @@ public class ProjectTeamXMLReader extends AbstractObjectReader { if (handler == null) { throw new IllegalStateException("ContentHandler not set"); } - + //Start the document handler.startDocument(); - + //Generate SAX events for the ProjectTeam generateFor(projectTeam); - + //End the document - handler.endDocument(); + handler.endDocument(); } - + /** * Generates SAX events for a ProjectTeam object. * @param projectTeam ProjectTeam object to use @@ -84,7 +84,7 @@ public class ProjectTeamXMLReader extends AbstractObjectReader { if (handler == null) { throw new IllegalStateException("ContentHandler not set"); } - + handler.startElement("projectteam"); handler.element("projectname", projectTeam.getProjectName()); Iterator i = projectTeam.getMembers().iterator(); @@ -107,7 +107,7 @@ public class ProjectTeamXMLReader extends AbstractObjectReader { if (handler == null) { throw new IllegalStateException("ContentHandler not set"); } - + handler.startElement("member"); handler.element("name", projectMember.getName()); handler.element("function", projectMember.getFunction()); diff --git a/examples/embedding/java/embedding/tools/AbstractObjectReader.java b/examples/embedding/java/embedding/tools/AbstractObjectReader.java index 8ec4836bb..641a90ca3 100644 --- a/examples/embedding/java/embedding/tools/AbstractObjectReader.java +++ b/examples/embedding/java/embedding/tools/AbstractObjectReader.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.tools; //Java @@ -33,7 +33,7 @@ import org.xml.sax.ErrorHandler; import org.xml.sax.EntityResolver; /** - * This class can be used as base class for XMLReaders that generate SAX + * This class can be used as base class for XMLReaders that generate SAX * events from Java objects. */ @@ -43,10 +43,10 @@ public abstract class AbstractObjectReader implements XMLReader { "http://xml.org/sax/features/namespaces"; private static final String NS_PREFIXES = "http://xml.org/sax/features/namespace-prefixes"; - + private Map features = new java.util.HashMap(); private ContentHandler orgHandler; - + /** Proxy for easy SAX event generation */ protected EasyGenerationContentHandlerProxy handler; /** Error handler */ @@ -60,7 +60,7 @@ public abstract class AbstractObjectReader implements XMLReader { setFeature(NAMESPACES, false); setFeature(NS_PREFIXES, false); } - + /* ============ XMLReader interface ============ */ /** diff --git a/examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java b/examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java index fe35ad426..c9780a1c1 100644 --- a/examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java +++ b/examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package embedding.tools; //SAX @@ -28,10 +28,10 @@ import org.xml.sax.helpers.AttributesImpl; /** * This class is an implementation of ContentHandler which acts as a proxy to - * another ContentHandler and has the purpose to provide a few handy methods + * another ContentHandler and has the purpose to provide a few handy methods * that make life easier when generating SAX events. * <br> - * Note: This class is only useful for simple cases with no namespaces. + * Note: This class is only useful for simple cases with no namespaces. */ public class EasyGenerationContentHandlerProxy implements ContentHandler { @@ -64,8 +64,8 @@ public class EasyGenerationContentHandlerProxy implements ContentHandler { /** * Sends the notification of the beginning of an element. * @param name Name for the element. - * @param atts The attributes attached to the element. If there are no - * attributes, it shall be an empty Attributes object. + * @param atts The attributes attached to the element. If there are no + * attributes, it shall be an empty Attributes object. * @throws SAXException Any SAX exception, possibly wrapping another exception. */ public void startElement(String name, Attributes atts) throws SAXException { @@ -108,8 +108,8 @@ public class EasyGenerationContentHandlerProxy implements ContentHandler { * Sends notifications for a whole element with some String content. * @param name Name for the element. * @param value Content of the element. - * @param atts The attributes attached to the element. If there are no - * attributes, it shall be an empty Attributes object. + * @param atts The attributes attached to the element. If there are no + * attributes, it shall be an empty Attributes object. * @throws SAXException Any SAX exception, possibly wrapping another exception. */ public void element(String name, String value, Attributes atts) throws SAXException { @@ -165,7 +165,7 @@ public class EasyGenerationContentHandlerProxy implements ContentHandler { /** * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes) */ - public void startElement(String namespaceURI, String localName, + public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { target.startElement(namespaceURI, localName, qName, atts); } @@ -174,7 +174,7 @@ public class EasyGenerationContentHandlerProxy implements ContentHandler { /** * @see org.xml.sax.ContentHandler#endElement(String, String, String) */ - public void endElement(String namespaceURI, String localName, String qName) + public void endElement(String namespaceURI, String localName, String qName) throws SAXException { target.endElement(namespaceURI, localName, qName); } |