git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196868 13f79535-47bb-0310-9956-ffa450edef68pull/30/head
@@ -55,17 +55,12 @@ import java.util.Map; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
// XML | |||
import org.w3c.dom.Document; | |||
// Avalon | |||
import org.apache.avalon.framework.logger.LogEnabled; | |||
import org.apache.avalon.framework.logger.Logger; | |||
// FOP | |||
import org.apache.fop.pdf.PDFEncryptionParams; | |||
import org.apache.fop.render.XMLHandler; | |||
import org.apache.fop.render.RendererContext; | |||
/** | |||
* The User Agent for fo. | |||
@@ -188,39 +183,5 @@ public class FOUserAgent implements LogEnabled { | |||
return true; | |||
} | |||
/** | |||
* Render the xml document with the given xml namespace. | |||
* The Render Context is by the handle to render into the current | |||
* rendering target. | |||
* @param ctx rendering context | |||
* @param doc DOM Document containing the source document | |||
* @param namespace Namespace URI of the document | |||
*/ | |||
public void renderXML(RendererContext ctx, Document doc, | |||
String namespace) { | |||
String mime = ctx.getMimeType(); | |||
Map mh = (Map) 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 | |||
getLogger().error("Some XML content will be ignored. " | |||
+ "Could not render XML", t); | |||
} | |||
} else { | |||
// no handler found for document | |||
getLogger().warn("Some XML content will be ignored. " | |||
+ "No handler defined for XML: " + namespace); | |||
} | |||
} | |||
} | |||
@@ -58,6 +58,9 @@ import java.util.Map; | |||
import java.util.List; | |||
import java.util.Iterator; | |||
// XML | |||
import org.w3c.dom.Document; | |||
// FOP | |||
import org.apache.fop.apps.FOPException; | |||
import org.apache.fop.area.Area; | |||
@@ -702,5 +705,39 @@ public abstract class AbstractRenderer extends AbstractLogEnabled | |||
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. | |||
* @param ctx rendering context | |||
* @param doc DOM Document containing the source document | |||
* @param namespace Namespace URI of the document | |||
*/ | |||
public void renderXML(FOUserAgent foua, RendererContext ctx, Document doc, | |||
String namespace) { | |||
String mime = ctx.getMimeType(); | |||
Map mh = (Map) foua.handlers.get(mime); | |||
XMLHandler handler = null; | |||
if (mh != null) { | |||
handler = (XMLHandler) mh.get(namespace); | |||
} | |||
if (handler == null) { | |||
handler = (XMLHandler) foua.defaults.get(mime); | |||
} | |||
if (handler != null) { | |||
try { | |||
handler.handleXML(ctx, doc, namespace); | |||
} catch (Throwable t) { | |||
// could not handle document | |||
getLogger().error("Some XML content will be ignored. " | |||
+ "Could not render XML", t); | |||
} | |||
} else { | |||
// no handler found for document | |||
getLogger().warn("Some XML content will be ignored. " | |||
+ "No handler defined for XML: " + namespace); | |||
} | |||
} | |||
} | |||
@@ -1190,7 +1190,7 @@ public class PDFRenderer extends PrintRenderer { | |||
new Integer((int) pos.getWidth())); | |||
context.setProperty(PDFXMLHandler.PDF_HEIGHT, | |||
new Integer((int) pos.getHeight())); | |||
userAgent.renderXML(context, doc, ns); | |||
renderXML(userAgent, context, doc, ns); | |||
} | |||
@@ -885,7 +885,7 @@ public class PSRenderer extends AbstractRenderer { | |||
context.setProperty(PDFXMLHandler.PDF_HEIGHT, | |||
new Integer((int) pos.getHeight())); | |||
*/ | |||
userAgent.renderXML(context, doc, ns); | |||
renderXML(userAgent, context, doc, ns); | |||
} | |||
@@ -354,7 +354,7 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { | |||
public void renderForeignObject(ForeignObject fo) { | |||
org.w3c.dom.Document doc = fo.getDocument(); | |||
String ns = fo.getNameSpace(); | |||
userAgent.renderXML(context, doc, ns); | |||
renderXML(userAgent, context, doc, ns); | |||
} | |||
/** |
@@ -429,7 +429,7 @@ public class XMLRenderer extends AbstractRenderer { | |||
org.w3c.dom.Document doc = fo.getDocument(); | |||
String ns = fo.getNameSpace(); | |||
context.setProperty(XMLXMLHandler.WRITER, writer); | |||
userAgent.renderXML(context, doc, ns); | |||
renderXML(userAgent, context, doc, ns); | |||
writeEndTag("</foreignObject>"); | |||
} | |||