jeremias 2004/01/09 00:56:43 Modified: examples/embedding/java/embedding ExampleDOM2PDF.java Log: Style, javadoc and tab character fixes Revision Changes Path 1.3 +21 -15 xml-fop/examples/embedding/java/embedding/ExampleDOM2PDF.java Index: ExampleDOM2PDF.java =================================================================== RCS file: /home/cvs/xml-fop/examples/embedding/java/embedding/ExampleDOM2PDF.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ExampleDOM2PDF.java 13 Aug 2003 23:19:57 -0000 1.2 +++ ExampleDOM2PDF.java 9 Jan 2004 08:56:43 -0000 1.3 @@ -4,7 +4,7 @@ * The Apache Software License, Version 1.1 * ============================================================================ * - * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * Copyright (C) 1999-2004 The Apache Software Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: @@ -62,7 +62,6 @@ // DOM import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.Text; @@ -86,7 +85,7 @@ /** * Converts a DOM Document to a PDF file using FOP. - * @param doc the DOM Document + * @param xslfoDoc the DOM Document * @param pdf the target PDF file * @throws IOException In case of an I/O problem * @throws FOPException In case of a FOP problem @@ -166,7 +165,7 @@ ele2 = foDoc.createElementNS(foNS, "fo:flow"); ele1.appendChild(ele2); ele2.setAttributeNS(null, "flow-name", "xsl-region-body"); - AddElement(ele2, "fo:block", "Hello World!"); + addElement(ele2, "fo:block", "Hello World!"); ExampleDOM2PDF app = new ExampleDOM2PDF(); app.convertDOM2PDF(foDoc, pdffile); @@ -178,15 +177,22 @@ } } - protected static void AddElement(Node parent, String newNodeName, - String textVal) - { - if (textVal == null) return; // use only with text nodes - Element newElement = - parent.getOwnerDocument().createElementNS(foNS, newNodeName); - Text elementText = parent.getOwnerDocument().createTextNode(textVal); - newElement.appendChild(elementText); - parent.appendChild(newElement); - } + /** + * Adds an element to the DOM. + * @param parent parent node to attach the new element to + * @param newNodeName name of the new node + * @param textVal content of the element + */ + protected static void addElement(Node parent, String newNodeName, + String textVal) { + if (textVal == null) { + return; + } // use only with text nodes + Element newElement = parent.getOwnerDocument().createElementNS( + foNS, newNodeName); + Text elementText = parent.getOwnerDocument().createTextNode(textVal); + newElement.appendChild(elementText); + parent.appendChild(newElement); + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]