This tutorial contains an sample Java code to produce a SVG file that will be rendered in graphic form by an SVG-compatible browser using XSLT (XSL transformation), using the Transformer Java class.
| Java Code |
|---|
public void GetSVG(String XmlFileName,String XslFileName,String OutputFileSvg)
{
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer =tFactory.newTransformer (new javax.xml.transform.stream.StreamSource(XslFileName));
transformer.transform(new javax.xml.transform.stream.StreamSource(XmlFileName),new javax.xml.transform.stream.StreamResult ( new FileOutputStream(OutputFileSvg)));
}
catch (TransformerException ex) {
System.out.println("Transformer exception ");
}
catch (IOException ex) {
System.out.println("Exceptie I/O");
}
}
|
| Select all |
The XmlFileName parameter of the method "GetSvg" is the XML file path that needs to be graphically transformed in svg file format.
The XslFileName parameter is the XSLT file path that generates the SVG code.
The OutputFileSvg parameter is the svg file that will be created on the disk, after the transformation.
Nobody posted any comments regarding this story. Be the first!
Discuss