]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Change TransformerHandler to ContentHandler. Use comment method when
authorSimon Pepping <spepping@apache.org>
Fri, 27 Jan 2006 20:24:15 +0000 (20:24 +0000)
committerSimon Pepping <spepping@apache.org>
Fri, 27 Jan 2006 20:24:15 +0000 (20:24 +0000)
available.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@372971 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/xml/XMLRenderer.java
test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java

index c51c33522bcb6b5a92e8701b754f7fd8d41d473f..833f3df8a07407697fc6bc4e5eebbcc93661bfce 100644 (file)
@@ -36,6 +36,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.w3c.dom.Document;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
 import org.xml.sax.helpers.AttributesImpl;
 import org.xml.sax.ContentHandler;
 
@@ -111,7 +112,7 @@ public class XMLRenderer extends PrintRenderer {
     /** If not null, the XMLRenderer will mimic another renderer by using its font setup. */
     protected Renderer mimic;
 
-    /** TransformerHandler that the generated XML is written to */
+    /** ContentHandler that the generated XML is written to */
     protected ContentHandler handler;
 
     /** AttributesImpl instance that can be used during XML generation. */
@@ -196,6 +197,20 @@ public class XMLRenderer extends PrintRenderer {
         throw new RuntimeException(saxe.getMessage());
     }
 
+    /**
+     * Writes a comment to the generated XML.
+     * @param comment the comment
+     */
+    protected void comment(String comment) {
+        if (handler instanceof LexicalHandler) { 
+            try {
+                ((LexicalHandler) handler).comment(comment.toCharArray(), 0, comment.length());
+            } catch (SAXException saxe) {
+                handleSAXException(saxe);
+            }
+        }
+    }
+    
     /**
      * Starts a new element (without attributes).
      * @param tagName tag name of the element
@@ -406,6 +421,9 @@ public class XMLRenderer extends PrintRenderer {
         } catch (SAXException saxe) {
             handleSAXException(saxe);
         }
+        if (userAgent.getProducer() != null) {
+            comment("Produced by " + userAgent.getProducer());
+        }
         startElement("areaTree");
     }
 
index 63796658046642ca06e1bdd32eb987e08aff26b3..245dc25ebb0b1dad8a5945499e816ab7e7c83206 100644 (file)
@@ -192,7 +192,7 @@ public class AreaTreeParserTestCase extends XMLTestCase {
         
         XMLRenderer renderer = new XMLRenderer();
         renderer.mimicRenderer(targetRenderer);
-        renderer.setTransformerHandler(handler);
+        renderer.setContentHandler(handler);
         renderer.setUserAgent(userAgent);
 
         userAgent.setRendererOverride(renderer);
@@ -223,7 +223,7 @@ public class AreaTreeParserTestCase extends XMLTestCase {
         DOMResult domResult = new DOMResult();
         handler.setResult(domResult);
         XMLRenderer renderer = new XMLRenderer();
-        renderer.setTransformerHandler(handler);
+        renderer.setContentHandler(handler);
 
         FOUserAgent userAgent = createUserAgent();
         userAgent.setRendererOverride(renderer);