Please find attached a test case Java program and SVG file. When the program is run, a NullPointerException is thrown during transcoding. If we directly treat the SVG document instead of the copy obtained using DomUtilities.deepCloneDocument() the result is ok. If we transform the SVG file by hand to remove usage of the clipPath (simply by switching to another style), then the program just works fine in both cases (with and without cloning). We are using Batik 1.5b4, JDK 1.3.1/Windows 2000 & JDK1.4.1/Windows 98.
Thank you,
Bertrand Fontaine & CE Mosneron Dupin
Note: The sample SVG file doesn't look great, but it's normal ;)
_________________________________________________________________
Internet access plans that fit your lifestyle -- join MSN. http://resourcecenter.msn.com/access/plans/default.asp
import java.io.*; import java.net.*; import org.w3c.dom.svg.*; import org.apache.batik.transcoder.image.*; import org.apache.batik.transcoder.*; import org.apache.batik.dom.util.*; import org.apache.batik.dom.svg.*; import org.apache.batik.util.*;
public class SvgCrashTest {
public SvgCrashTest() throws Exception {
code("sample");
}
protected void code(String file) throws Exception {
File f = new File(file + ".svg");
SVGDocument svgdoc = getSvgDocument(f);
JPEGTranscoder p = new JPEGTranscoder();
p.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));
TranscoderInput input = new TranscoderInput(svgdoc);
OutputStream ostream = new FileOutputStream(file + ".jpg");
BufferedOutputStream bufOut = new BufferedOutputStream(ostream);
TranscoderOutput output = new TranscoderOutput(bufOut);
// crashes here
p.transcode(input, output);
//
bufOut.close();
return;
}
public static SVGDocument getSvgDocument(File file) throws Exception {
URL url = file.toURL();
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
SVGDocument svgdoc = (SVGDocument)f.createDocument(url.toString());
return (SVGDocument)DOMUtilities.deepCloneDocument(svgdoc, svgdoc.getImplementation());
}
public static void main(String[] args) throws Exception {
SvgCrashTest cloneTest1 = new SvgCrashTest();
return;
}
}
<?xml version="1.0" encoding="iso-8859-1"?> <!-- Generator: Adobe Illustrator 9.0, SVG Export Plug-In --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd" [ <!ENTITY st1 "fill:none;stroke-width:0.6596;stroke-miterlimit:3.8637;"> <!ENTITY st2 "stroke-linecap:round;"> <!ENTITY st3 "fill:#BFBFBF;stroke-width:0.6595;"> <!ENTITY st4 "fill:#BFBFBF;stroke-width:0.6622;"> <!ENTITY st5 "fill:#000000;stroke:none;"> <!ENTITY st6 "display:inline;fill:#000000;stroke:none;"> <!ENTITY st13 "stroke-width:1.3193;stroke-linecap:round;"> <!ENTITY st16 "stroke-width:0.5793;stroke-linecap:square;"> <!ENTITY st17 "fill:#000000;stroke-linecap:square;"> <!ENTITY st22 "fill:#000000;stroke-width:1.3193;stroke-linecap:square;"> <!ENTITY st29 "font-size:11;letter-spacing:0.025em;"> <!ENTITY st37 "stroke-width:8.76;stroke-linecap:square;"> <!ENTITY st41 "font-family:'ArialMT';"> <!ENTITY st45 "stroke-linecap:square;"> <!ENTITY st51 "fill-rule:nonzero;clip-rule:nonzero;stroke:#000000;stroke-miterlimit:4;"> <!ENTITY st52 "stroke-width:1.3193;"> <!ENTITY st55 "stroke:none;"> <!ENTITY st60 "fill-rule:evenodd;clip-rule:evenodd;fill:#000000;"> <!ENTITY st64 "clip-path:url(#aiclp);"> ]> <svg width="280.641pt" height="266.141pt" viewBox="0 0 280.641 266.141" xml:space="preserve"> <g id="ND4DF00C" style="&st51; &st41; &st29;"> <g style="&st1;"> <clipPath id="aiclp" style="&st55;"> <path d="M0,242.412V132.569h260.645v109.843H0z"/> </clipPath> <g style="&st64;"> <path style="&st45;" d="M48.586,223.143c-0.016-1.925,1.53-3.498,3.455-3.514c1.925-0.018,3.498,1.529,3.515,3.453c0.018,1.925-1.529,3.499-3.453,3.516c-1.924,0.016-3.499-1.531-3.517-3.455z"/> <path style="&st45;" d="M42.895,223.289c-0.045-5.124,4.071-9.311,9.193-9.356c5.121-0.045,9.308,4.07,9.354,9.193c0.044,5.122-4.069,9.311-9.192,9.354c-5.121,0.045-9.312-4.071-9.354-9.191z"/> <path style="&st37;" d="M37.607,223.387c-0.072-8.072,6.414-14.672,14.484-14.743c8.072-0.07,14.67,6.416,14.74,14.486c0.072,8.071-6.414,14.671-14.484,14.742c-8.07,0.07-14.671-6.415-14.74-14.485z"/> <path d="M190.743,212.234c1.305-11.48,9.839-14.55,19.722-14.637c8.225-0.072,15.479,2.795,18.891,9.568"/> <path d="M34.221,205.82c3.618-7.116,9.085-9.24,19.006-9.16c11.123,0.092,20.937,6.031,21.867,24.72"/> <path d="M59.412,168.813l0.336,28.787"/> <path d="M38.886,168.897l20.688-0.085"/> <path d="M118.627,140.112l-1.187,35.931l0.295,17.085l0.006,28.25"/> <path d="M116.266,140.279l-1.372,35.629l-0.271,9.874l-3.273,7.402l-1.66,3.396l0.083,24.868"/> <path style="&st45;" d="M185.911,140.527l1.134,45.286l-0.426,35.798"/> <path d="M13.989,187.053l47.083-1.324l188.245,0.296"/> <path d="M241.054,136.159c0,0-1.063-0.01,0.337,5.29c1.398,5.3,7.268,28.872,7.268,28.872s0.87,0.331,1.088,25.333"/> <path d="M246.453,141.361c0,0-1.921,0.365-1.104,3.798c0.817,3.435,6.037,23.535,6.037,23.535s0.444,2.577,2.918,2.68"/> <path d="M59.485,168.727c0,0,17.508-18.986,23.158-24.154c5.099-4.661,11.19-4.321,11.19-4.321l24.793-0.14l67.222,0.083l55.112,0.571"/> <path d="M54.323,168.612c0,0,22.804-21.967,27.881-26.647c5.079-4.679,11.189-4.321,11.189-4.321l24.794-0.14l67.22,0.084l55.115,0.571"/> <path d="M74.3,140.009c0,0,1.194-0.022,3.132,0.783c1.943,0.803,2.729,1.251,2.729,1.251s1.125,0.646,0.711,1.134"/> <path style="&st45;" d="M124.573,142.728l55.392,0.001c1.209,0,2.189,0.98,2.189,2.19l0.002,26.52c0,1.21-0.979,2.191-2.188,2.191l-55.393-0.002c-1.21,0-2.189-0.98-2.189-2.19l-0.002-26.521c0-1.209,0.979-2.189,2.189-2.188z"/> <path style="&st16;" d="M124.644,169.815l-0.001-23.291c0-1.063,0.861-1.924,1.923-1.924l51.571,0.002c1.063,0,1.924,0.861,1.924,1.924l0.002,23.291"/> <path style="&st45;" d="M192.647,173.227c-1.208,0-2.189-0.635-2.19-1.843l-0.613-26.576c0-1.208,0.979-2.189,2.189-2.189l36.034,0.786l6.072,0.168c1.21,0,2.047,0.923,2.188,2.191l5.265,25.132c0,1.212-0.98,2.332-2.188,2.332h-46.757z"/> <path style="&st45;" d="M192.971,169.7l-0.548-23.076c0-1.075,1.059-1.947,2.134-1.947l32.044,0.7l5.772,0.149c1.075,0,1.82,0.82,1.947,1.948l4.682,22.351"/> <path d="M60.932,174.396l-23.729,0.131l-9.548-1.453"/> <path style="&st52;" d="M85.26,145.324c1.119-1.11,3.2-2.031,4.409-2.031l20.733-0.004c1.208,0,2.189,0.98,2.191,2.189l-3.163,26.55c0,1.209-0.979,2.189-2.188,2.189l-18.25-0.157c0,0-20.816,0.087-23.327,0.109c-1.595,0.013-1.058-4.833-1.07-6.379 c-0.017-1.949,20.665-22.466,20.665-22.466z"/> <path style="&st45;" d="M117.479,175.794l2.183-0.019c0.604-0.005,1.099,0.479,1.104,1.085l0.05,5.934c0.006,0.604-0.479,1.098-1.084,1.103l-2.128,0.021"/> <path style="&st17;" d="M114.685,183.938l-2.154-0.004c-0.604-0.011-1.086-0.51-1.075-1.115l0.102-5.93c0.012-0.603,0.51-1.085,1.112-1.075l2.229,0.008l-0.213,8.116z"/> <path style="&st45;" d="M117.427,175.795l-2.529,0.028"/> <path style="&st45;" d="M117.551,183.944l-2.854-0.008"/> <path style="&st45;" d="M76.273,162.696c0,0,2.659-0.263,2.684,2.693c0.025,2.956,0.043,4.862,0.043,4.862s0.015,2.055-2.451,2.225c-2.229,0.154-5.83,0.263-5.842-0.97"/> <path style="&st45;" d="M76.273,162.696l-3.627,0.032c0,0-2.017-0.007-1.994,2.33c0.02,2.337,0.01,1.225,0.01,1.225"/> <path style="&st45;" d="M68.798,167.934l2.351-0.021c0.605-0.005,1.101,0.46,1.104,1.037c0.005,0.579-0.481,1.053-1.088,1.059l-2.348,0.02c-0.604,0.004-1.101-0.459-1.104-1.037c-0.006-0.579,0.481-1.052,1.085-1.057z"/> <path d="M68.729,162.709l0.027,3.87"/> <path d="M68.807,171.293l0.016,2.836"/> <path style="&st2;" d="M67.061,166.325c0,0,0.7,0.289,1.454,0.283c0.753-0.007,3.383-0.245,4.329,0.338"/> <path style="&st2;" d="M67.106,171.485c0,0,0.694-0.302,1.447-0.309c0.752-0.007,3.388,0.187,4.323-0.414"/> <path style="&st13;" d="M256.945,207.047c0,0-0.087-8.463-0.197-10.104c-0.112-1.64-0.979-1.528-0.979-1.528c0.439-15.844-1.465-24.042-1.465-24.042s-6.044-22.728-7.793-29.678c-1.417-5.628-5.457-5.537-5.457-5.537c-91.983-4.798-142.081-1.964-153.564-0.997 c-11.484,0.971-13.189,4.847-13.189,4.847c-18.135,13.486-35.127,28.604-35.127,28.604l-3.35,0.029"/> <path style="&st17;" d="M33.253,173.687l1.912-1.381c1.505-0.737-0.542-2.606-0.542-2.606c-2.382,1.051-4.595,2.112-6.683,3.18l0.113,0.018l5.199,0.789z"/> <path style="&st13;" d="M35.823,168.643l-1.713,0.848"/> <path d="M60.932,174.445l4.591-0.04"/> <path style="&st22;" d="M6.356,206.325l0.096-4.487l0.055,0.008c0,0,3.17,0.25,3.184,1.823l0.024,2.646l27.582-0.271c-2.803,3.404-4.591,7.809-5.025,12.612c-0.365,4.01-0.689,6.486,0.508,10.665l-14.196,0.123c0,0-1.255,0.012-1.741-0.273 c-0.486-0.285-3.496-2.385-5.044-2.66c-1.548-0.277-10.279-4.835-10.354-13.335c-0.06-6.896,2.774-6.825,2.774-6.825l2.139-0.025z"/> <path style="&st13;" d="M8.848,187.347c0,0-1.078-1.75,1.607-3.899c0,0,6.576-5.187,17.218-10.63l1.323,0.004"/> <path style="&st13;" d="M6.465,201.837l0.119-5.393"/> <path d="M247.198,196.237L11.893,196.44"/> <path d="M25.173,181.629c-6.54,3.898-10.997,5.283-13.475,5.713"/> <path style="&st60;" d="M11.719,187.342c-2.288,0.398-3.156-0.018-3.156-0.018l-2.262,9.078l0.001,0.042l5.612-0.005c0,0-2.457,0.104-1.882-4.092c0.688-5.044,1.687-5.006,1.687-5.006z"/> <path style="&st45;" d="M207.202,222.615c-0.018-1.925,1.529-3.498,3.454-3.514c1.924-0.018,3.498,1.529,3.516,3.454c0.016,1.925-1.53,3.496-3.455,3.515c-1.924,0.017-3.498-1.53-3.515-3.455z"/> <path style="&st45;" d="M201.509,222.761c-0.045-5.123,4.07-9.31,9.193-9.354c5.121-0.045,9.31,4.07,9.354,9.191c0.046,5.124-4.07,9.31-9.192,9.355c-5.121,0.045-9.31-4.071-9.355-9.192z"/> <path style="&st37;" d="M196.221,222.859c-0.068-8.074,6.415-14.672,14.485-14.743c8.072-0.069,14.671,6.415,14.743,14.487c0.069,8.071-6.415,14.669-14.486,14.74s-14.67-6.415-14.742-14.484z"/> </g> </g> </g> </svg>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
