aboutsummaryrefslogtreecommitdiffstats
path: root/examples/plan
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-10-20 07:16:47 +0000
committerJeremias Maerki <jeremias@apache.org>2008-10-20 07:16:47 +0000
commit430c6f6b18eab333e0ebd36a4ef6823d42d014db (patch)
tree64e6e506870e3c1eca451d2857e548d4f00e5b09 /examples/plan
parentd99dc61714ce6fa3f91342deacc0ddfdcdc4beef (diff)
downloadxmlgraphics-fop-430c6f6b18eab333e0ebd36a4ef6823d42d014db.tar.gz
xmlgraphics-fop-430c6f6b18eab333e0ebd36a4ef6823d42d014db.zip
Check for plan namespace to avoid errors while parsing plan XML.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@706135 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'examples/plan')
-rw-r--r--examples/plan/src/org/apache/fop/plan/PreloaderPlan.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java b/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java
index b8a7a612c..f99c94af9 100644
--- a/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java
+++ b/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java
@@ -30,6 +30,7 @@ import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -66,7 +67,7 @@ public class PreloaderPlan extends AbstractImagePreloader {
return info;
}
- private ImageInfo getImage(String uri, Source src, ImageContext context) {
+ private ImageInfo getImage(String uri, Source src, ImageContext context) throws IOException {
InputStream in = new UnclosableInputStream(ImageUtil.needInputStream(src));
try {
@@ -78,7 +79,14 @@ public class PreloaderPlan extends AbstractImagePreloader {
//Have to render the plan to know its size
PlanRenderer pr = new PlanRenderer();
- Document svgDoc = pr.createSVGDocument((Document)res.getNode());
+ Document planDoc = (Document)res.getNode();
+ Element rootEl = planDoc.getDocumentElement();
+ if (!PlanElementMapping.NAMESPACE.equals(rootEl.getNamespaceURI())) {
+ in.reset();
+ return null;
+ }
+
+ Document svgDoc = pr.createSVGDocument(planDoc);
float width = pr.getWidth();
float height = pr.getHeight();