aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-10-26 09:27:00 +0000
committerKeiron Liddle <keiron@apache.org>2001-10-26 09:27:00 +0000
commitaf113ef5a388ac87b4f1dac63e07ffc7160f8b14 (patch)
treed40d1802b6728e0e5819e2e2939ff4254da47ffa /src/org/apache/fop/fo
parent3c34d76dfaa0908026069b0763558fa7d464ceb2 (diff)
downloadxmlgraphics-fop-af113ef5a388ac87b4f1dac63e07ffc7160f8b14.tar.gz
xmlgraphics-fop-af113ef5a388ac87b4f1dac63e07ffc7160f8b14.zip
updates to area tree and reading/rendering with xml
added user agent, xml handlers added inline level property git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194521 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo')
-rw-r--r--src/org/apache/fop/fo/FOUserAgent.java62
1 files changed, 54 insertions, 8 deletions
diff --git a/src/org/apache/fop/fo/FOUserAgent.java b/src/org/apache/fop/fo/FOUserAgent.java
index b9f74a9f6..05ae93456 100644
--- a/src/org/apache/fop/fo/FOUserAgent.java
+++ b/src/org/apache/fop/fo/FOUserAgent.java
@@ -7,13 +7,18 @@
package org.apache.fop.fo;
+import org.apache.fop.render.XMLHandler;
+import org.apache.fop.render.RendererContext;
+
import org.w3c.dom.*;
+import java.util.HashMap;
+
/**
* The User Agent for fo.
* This user agent is used by the processing to obtain user configurable
* options.
- *
+ *
* Renderer specific extensions (that do not produce normal areas on
* the output) will be done like so:
* The extension will create an area, custom if necessary
@@ -24,14 +29,55 @@ import org.w3c.dom.*;
* These areas may contain resolveable areas that will be processed
* with other resolveable areas
*/
-public interface FOUserAgent {
-public void renderXML(RendererContext ctx, Document doc, String namespace);
+public class FOUserAgent {
+ HashMap defaults = new HashMap();
+ HashMap handlers = new HashMap();
-}
+ /**
+ * Set the default xml handler for the given mime type.
+ */
+ public void setDefaultXMLHandler(String mime, XMLHandler handler) {
+ defaults.put(mime, handler);
+ }
-class RendererContext {
-String getMimeType() {
-return null;
-}
+ /**
+ * Add an xml handler for the given mime type and xml namespace.
+ */
+ public void addXMLHandler(String mime, String ns, XMLHandler handler) {
+ HashMap mh = (HashMap) handlers.get(mime);
+ if (mh == null) {
+ mh = new HashMap();
+ handlers.put(mime, mh);
+ }
+ mh.put(ns, handler);
+ }
+
+ /**
+ * Render the xml document with the given xml namespace.
+ * The Render Context is by the handle to render into the current
+ * rendering target.
+ */
+ public void renderXML(RendererContext ctx, Document doc,
+ String namespace) {
+ String mime = ctx.getMimeType();
+ HashMap mh = (HashMap) handlers.get(mime);
+ XMLHandler handler = null;
+ if (mh != null) {
+ handler = (XMLHandler) mh.get(namespace);
+ }
+ if (handler == null) {
+ handler = (XMLHandler) defaults.get(mime);
+ }
+ if (handler != null) {
+ try {
+ handler.handleXML(ctx, doc, namespace);
+ } catch (Throwable t) {
+ // could not handle document
+ //t.printStackTrace();
+ }
+ } else {
+ // no handler found for document
+ }
+ }
}