M
Mark McKay
I'm creating a DOM tree with elements containing svg, fo, xlink and
xsl elements. I'm then attempting to write it to a file. While the
local names are being written correctly, the namespace information is
being omitted. If I define
final String NS_SVG = "http://www.w3.org/2000/svg";
I'd like the output to look something like
<root xmlns:svg="http://www.w3.org/2000/svg">
<svg:svg width="372" height="452" viewBox="0 0 372 452">
<svg:rect x="10" y="10" width="352" height="432"
fill="none" stroke="black" stroke-width="2"/>
</svg:svg>
</root>
Is there a way to do this with DOM?
I'm writing it to disk with:
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.setParameter("svg", NS_SVG);
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
"4");
DOMSource ds = new DOMSource(doc);
StreamResult sr = new StreamResult(ostream);
t.transform(ds, sr);
Mark McKay
xsl elements. I'm then attempting to write it to a file. While the
local names are being written correctly, the namespace information is
being omitted. If I define
final String NS_SVG = "http://www.w3.org/2000/svg";
I'd like the output to look something like
<root xmlns:svg="http://www.w3.org/2000/svg">
<svg:svg width="372" height="452" viewBox="0 0 372 452">
<svg:rect x="10" y="10" width="352" height="432"
fill="none" stroke="black" stroke-width="2"/>
</svg:svg>
</root>
Is there a way to do this with DOM?
I'm writing it to disk with:
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.setParameter("svg", NS_SVG);
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
"4");
DOMSource ds = new DOMSource(doc);
StreamResult sr = new StreamResult(ostream);
t.transform(ds, sr);
Mark McKay