Hi

I am have a webapp which is trying to generate JPEG file from SVG DOM. The SVG DOM itself is generated using XSL Translations from an XML data representation. When I simply save the SVG DOM to a file using FileStream and open the SVG file, I am getting the desired result. However, The JPEG transformation of the same SVG DOM using JPEGTranscoder::transcode()  fails (nothing is generated)

Some of the previous postings on this alias indicate that the DOM from the XSL transformer is not suitable for JPEGTranscoder. So, I am converting the DOM using the SVGDOMImplementation as follows:

         // svgDocument is the document generated using javax.xml.transform.Transformer::transform()
         //  prior to the code block shown below
         .....
        SVGDOMImplementation impl = (SVGDOMImplementation)SVGDOMImplementation.getDOMImplementation();
        Document batikDoc = DOMUtilities.deepCloneDocument(svgDocument,impl);

        // convert the SVG DOM into Jpeg format
        FileOutputStream oStream = null;
        try {
            JPEGTranscoder transcoder = new JPEGTranscoder();
            transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(0.8));
            TranscoderInput input = new TranscoderInput(batikDoc);
            oStream = new FileOutputStream(jpgFileName);
            TranscoderOutput output = new TranscoderOutput(oStream);
            transcoder.transcode(input,output);
            oStream.flush();
            oStream.close();
        }
         ......

The transcode() method invocation always results in throwing Exception that some of the mandatory attributes are required ( Eg: The attribute "r" of the element <circle> is required ). By printing the DOMs, It appears that the attribute values in the original DOM are not copied in the deepCloneDocument() method. All elements and the corresponding attributes in the original document are present but the attributes do not have any values.

Can someone please guide me how to workaround this problem? Also, Please let me know if there is an entirely different way to do what I am trying to?

thanks
Venkat

Reply via email to