From fc6a15c27b59633a456dc8d3fcb97dd2c56201f0 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 7 Feb 2006 14:18:38 +0000 Subject: [PATCH] Non-SVG XML got loaded into a non-namespace-aware node which caused problems later when serializing the foreign XML to the intermediate format. Fixes a problem with serializing barcodes (Barcode4J) to the intermediate format. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@375604 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/XMLObj.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/fop/fo/XMLObj.java b/src/java/org/apache/fop/fo/XMLObj.java index cf64136fd..c7b3d1b6f 100644 --- a/src/java/org/apache/fop/fo/XMLObj.java +++ b/src/java/org/apache/fop/fo/XMLObj.java @@ -24,6 +24,8 @@ import java.util.HashMap; import javax.xml.parsers.DocumentBuilderFactory; +import org.apache.batik.dom.svg.SVGDOMImplementation; +import org.apache.batik.dom.util.XMLSupport; import org.apache.fop.apps.FOPException; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -167,11 +169,16 @@ public abstract class XMLObj extends FONode { DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); fact.setNamespaceAware(true); doc = fact.newDocumentBuilder().newDocument(); - Element el = doc.createElement(name); + Element el = doc.createElementNS(getNamespaceURI(), name); doc.appendChild(el); element = doc.getDocumentElement(); buildTopLevel(doc, element); + if (!element.hasAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns")) { + element.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns", + getNamespaceURI()); + } + } catch (Exception e) { log.error("Error while trying to instantiate a DOM Document", e); } -- 2.39.5