Using Apache Batik to create SVG files, the version always comes out as "1.0" (seems to be hard coded) but Batik says it implements 1.1. How do I change the version, is it as simple as setting the attribute manually on the <svg>
element or would that have other consequences? Or does the SVG version not matter? I used an SVG validator and it recommended setting the version to 1.1 or omitting it.
import java.io.IOException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.batik.anim.dom.SVGDOMImplementation;
import org.w3c.dom.*;
import org.w3c.dom.svg.SVGDocument;
public class Test {
public static void main(String[] args) throws IOException, TransformerException {
DOMImplementation imp = SVGDOMImplementation.getDOMImplementation();
SVGDocument doc = (SVGDocument) imp.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);
TransformerFactory tf = TransformerFactory.newDefaultInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(new DOMSource(doc), new StreamResult(System.out));
}
}
output
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
contentScriptType="text/ecmascript"
zoomAndPan="magnify"
contentStyleType="text/css"
preserveAspectRatio="xMidYMid meet"
version="1.0"/>