Reputation: 59
I've created the following code as a test of Batik's Rhino integration:
public class BatikTest
{
public static void main(String...args) throws SAXException, IOException, ParserConfigurationException, TranscoderException, TransformerException
{
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
Document document = factory.createSVGDocument(null, new StringReader("<svg xmlns=\"http://www.w3.org/2000/svg\"><script>java.lang.System.out.println('Hello, World!');</script></svg>"));
TranscoderInput input = new TranscoderInput(document);
ImageTranscoder transcoder = new ImageTranscoder()
{
private BufferedImage image;
@Override
public BufferedImage createImage(int width, int height) {
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}
@Override
public void writeImage(BufferedImage image, TranscoderOutput output) throws TranscoderException {
this.image = image;
}};
StringWriter writer = new StringWriter();
transcoder.transcode(input, null);
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(writer);
TransformerFactory factori = TransformerFactory.newInstance();
Transformer transformer = factori.newTransformer();
transformer.transform(source, result);
System.out.println(writer.toString());
}
}
Why isn't the string "Hello, World!" printing to console? What am I missing?
Upvotes: 0
Views: 51