Hello all, I am loading svg file through following lines of code into my application parser = XMLResourceDescriptor.getXMLParserClassName();
factory = new SAXSVGDocumentFactory(parser); // ua = new UserAgentAdapter(); // loader = new DocumentLoader(ua); // ctx = new BridgeContext(ua, loader); // ctx.setDynamicState(BridgeContext.DYNAMIC); doc = factory.createSVGDocument(svg.toURI().toString()); generator = new SVGGraphics2D(doc); the document is generated previously with the SVG generator and it can be view in all the SVG browser and it does not contain any error. now i am updating document // do here height / width calculation for canvas and image itself Dimension d = calculateImageSize(true, true); System.out.println(" 400 DPI Original width " + d.getWidth() + " height " + d.getHeight()); generator.setSVGCanvasSize(d); Element root = doc.getDocumentElement(); //root.setAttributeNS(null, "viewBox", ("0 0 " + (d.getWidth() + " " + d // .getHeight()))); NodeList imageList = root.getElementsByTagName("image"); Node imageNode = imageList.item(0); Element image = (Element) imageNode; image.setAttributeNS(null, "width", String.valueOf(d.getWidth())); image.setAttributeNS(null, "height", String.valueOf(d.getHeight())); updateCanvas(); following is updateCanvas implementation public void updateCanvas() { Element root = doc.getDocumentElement(); generator.getRoot(root); canvas.setSVGDocument(doc); } now when i try to save this updated doc with following method *public void savePngImage(String pngFile, boolean is400DPI) throws IOException { OutputStream ostream = null; try { System.gc(); ostream = new FileOutputStream(pngFile); transCoder = new PNGTranscoder(); if (is400DPI) { transCoder.addTranscodingHint( ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new Float(0.0635f)); } else { transCoder.addTranscodingHint( ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, new Float(0.3528f)); } transCoder.addTranscodingHint(PNGTranscoder.KEY_INDEXED, new Integer(5)); transCoder.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen"); TranscoderInput input = new TranscoderInput(canvas.getSVGDocument()); TranscoderOutput output = new TranscoderOutput(ostream); // perform Transcoding transCoder.transcode(input, output); } catch (TranscoderException te) { te.printStackTrace(); throw new IOException(te.getMessage()); } finally { ostream.flush(); ostream.close(); } }* with every run , the program throws random exception, like **** CSSEngine: exception property.syntax.error:org.w3c.dom.DOMException: The "o" identifier is not a valid value for the "shape-rendering" property. AttrValue:auto ***** CSSEngine: exception property.syntax.error:org.w3c.dom.DOMException: The "" identifier is not a valid value for the "shape-rendering" property. AttrValue:auto Exception:org.w3c.dom.DOMException org.w3c.dom.DOMException: The "" identifier is not a valid value for the "shape-rendering" property. at org.apache.batik.css.engine.value.AbstractValueFactory.createInvalidIdentifierDOMException(AbstractValueFactory.java:50) at org.apache.batik.css.engine.value.IdentifierManager.createValue(IdentifierManager.java:48) at org.apache.batik.css.engine.CSSEngine$1.property(CSSEngine.java:744) at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java:768) at org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java:876) at org.apache.batik.bridge.CSSUtilities.getComputedStyle(CSSUtilities.java:82) at org.apache.batik.bridge.CSSUtilities.convertVisibility(CSSUtilities.java:579) at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(SVGSVGElementBridge.java:142) at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:76) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208) at com.mmg.app.svg.TiledImageTranscoder.transcode(TiledImageTranscoder.java:61) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156) at com.mmg.app.svg.ShoeComponentPNGCreator.savePngImage(ShoeComponentPNGCreator.java:601) at com.mmg.app.svg.ShoeComponentPNGCreator.create72DPIOriginalImage(ShoeComponentPNGCreator.java:305) at com.mmg.app.svg.ShoeComponentPNGCreator.processStyleImaging(ShoeComponentPNGCreator.java:226) at com.mmg.app.svg.ShoeComponentPNGCreator.traverseFolder(ShoeComponentPNGCreator.java:186) at com.mmg.app.svg.ShoeComponentPNGCreator.main(ShoeComponentPNGCreator.java:662) ***** CSSEngine: exception.... org.w3c.dom.DOMException: file:/F:/workspace/MonoGeneiousShoe/src/svg/72DPI/Style-5/Left_Style-5.svg: The attribute "shape-rendering" represents an invalid CSS value ("auto"). Original message: The "" identifier is not a valid value for the "shape-rendering" property. at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java:784) at org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java:876) at org.apache.batik.bridge.CSSUtilities.getComputedStyle(CSSUtilities.java:82) at org.apache.batik.bridge.CSSUtilities.convertVisibility(CSSUtilities.java:579) at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(SVGSVGElementBridge.java:142) at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:76) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208) at com.mmg.app.svg.TiledImageTranscoder.transcode(TiledImageTranscoder.java:61) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156) at com.mmg.app.svg.ShoeComponentPNGCreator.savePngImage(ShoeComponentPNGCreator.java:601) at com.mmg.app.svg.ShoeComponentPNGCreator.create72DPIOriginalImage(ShoeComponentPNGCreator.java:305) at com.mmg.app.svg.ShoeComponentPNGCreator.processStyleImaging(ShoeComponentPNGCreator.java:226) at com.mmg.app.svg.ShoeComponentPNGCreator.traverseFolder(ShoeComponentPNGCreator.java:186) at com.mmg.app.svg.ShoeComponentPNGCreator.main(ShoeComponentPNGCreator.java:662) Exception:org.w3c.dom.DOMException org.w3c.dom.DOMException: The "o" identifier is not a valid value for the "shape-rendering" property. at org.apache.batik.css.engine.value.AbstractValueFactory.createInvalidIdentifierDOMException(AbstractValueFactory.java:50) at org.apache.batik.css.engine.value.IdentifierManager.createValue(IdentifierManager.java:48) at org.apache.batik.css.engine.CSSEngine$1.property(CSSEngine.java:744) at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java:768) at org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java:876) at org.apache.batik.bridge.CSSUtilities.getComputedStyle(CSSUtilities.java:82) at org.apache.batik.bridge.CSSUtilities.convertVisibility(CSSUtilities.java:579) at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(SVGSVGElementBridge.java:142) at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:76) at org.apache.batik.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:96) ERROR: null Enclosed Exception: file:/F:/workspace/MonoGeneiousShoe/src/svg/72DPI/Style-5/Left_Style-5.svg: The attribute "shape-rendering" represents an invalid CSS value ("auto"). Original message: The "" identifier is not a valid value for the "shape-rendering" property. ***** CSSEngine: exception.... org.w3c.dom.DOMException: file:/F:/workspace/MonoGeneiousShoe/src/svg/72DPI/Style-5/Left_Style-5.svg: The attribute "shape-rendering" represents an invalid CSS value ("auto"). Original message: The "o" identifier is not a valid value for the "shape-rendering" property. at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java:784) at org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java:876) at org.apache.batik.bridge.CSSUtilities.getComputedStyle(CSSUtilities.java:82) at org.apache.batik.bridge.CSSUtilities.convertVisibility(CSSUtilities.java:579) at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(SVGSVGElementBridge.java:142) at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:76) at org.apache.batik.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:96) ERROR: null Enclosed Exception: file:/F:/workspace/MonoGeneiousShoe/src/svg/72DPI/Style-5/Left_Style-5.svg: The attribute "shape-rendering" represents an invalid CSS value ("auto"). Original message: The "o" identifier is not a valid value for the "shape-rendering" property. ***** CSSEngine: exception property.syntax.error:org.w3c.dom.DOMException: The "lormal" identifier is not a valid value for the "font-style" property. AttrValue:normal Exception:org.w3c.dom.DOMException org.w3c.dom.DOMException: The "lormal" identifier is not a valid value for the "font-style" property. at org.apache.batik.css.engine.value.AbstractValueFactory.createInvalidIdentifierDOMException(AbstractValueFactory.java:50) at org.apache.batik.css.engine.value.IdentifierManager.createValue(IdentifierManager.java:48) at org.apache.batik.css.engine.CSSEngine$1.property(CSSEngine.java:744) at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java:768) at org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java:876) at org.apache.batik.bridge.CSSUtilities.getComputedStyle(CSSUtilities.java:82) at org.apache.batik.bridge.CSSUtilities.convertVisibility(CSSUtilities.java:579) at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(SVGSVGElementBridge.java:142) at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:76) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208) at com.mmg.app.svg.TiledImageTranscoder.transcode(TiledImageTranscoder.java:61) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156) at com.mmg.app.svg.ShoeComponentPNGCreator.savePngImage(ShoeComponentPNGCreator.java:601) at com.mmg.app.svg.ShoeComponentPNGCreator.create72DPIOriginalImage(ShoeComponentPNGCreator.java:305) at com.mmg.app.svg.ShoeComponentPNGCreator.processStyleImaging(ShoeComponentPNGCreator.java:226) at com.mmg.app.svg.ShoeComponentPNGCreator.traverseFolder(ShoeComponentPNGCreator.java:186) at com.mmg.app.svg.ShoeComponentPNGCreator.main(ShoeComponentPNGCreator.java:662) ***** CSSEngine: exception.... org.w3c.dom.DOMException: file:/F:/workspace/MonoGeneiousShoe/src/svg/72DPI/Style-5/Left_Style-5.svg: The attribute "font-style" represents an invalid CSS value ("normal"). Original message: The "lormal" identifier is not a valid value for the "font-style" property. at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java:784) at org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java:876) at org.apache.batik.bridge.CSSUtilities.getComputedStyle(CSSUtilities.java:82) at org.apache.batik.bridge.CSSUtilities.convertVisibility(CSSUtilities.java:579) at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(SVGSVGElementBridge.java:142) at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:76) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208) at com.mmg.app.svg.TiledImageTranscoder.transcode(TiledImageTranscoder.java:61) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156) at com.mmg.app.svg.ShoeComponentPNGCreator.savePngImage(ShoeComponentPNGCreator.java:601) at com.mmg.app.svg.ShoeComponentPNGCreator.create72DPIOriginalImage(ShoeComponentPNGCreator.java:305) at com.mmg.app.svg.ShoeComponentPNGCreator.processStyleImaging(ShoeComponentPNGCreator.java:226) at com.mmg.app.svg.ShoeComponentPNGCreator.traverseFolder(ShoeComponentPNGCreator.java:186) at com.mmg.app.svg.ShoeComponentPNGCreator.main(ShoeComponentPNGCreator.java:662) ERROR: null Enclosed Exception: file:/F:/workspace/MonoGeneiousShoe/src/svg/72DPI/Style-5/Left_Style-5.svg: The attribute "font-style" represents an invalid CSS value ("normal"). Original message: The "lormal" identifier is not a valid value for the "font-style" property. java.lang.NullPointerException at com.mmg.app.svg.TiledImageTranscoder.transcode(TiledImageTranscoder.java:69) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156) at com.mmg.app.svg.ShoeComponentPNGCreator.savePngImage(ShoeComponentPNGCreator.java:601) at com.mmg.app.svg.ShoeComponentPNGCreator.create72DPIOriginalImage(ShoeComponentPNGCreator.java:305) at com.mmg.app.svg.ShoeComponentPNGCreator.processStyleImaging(ShoeComponentPNGCreator.java:226) at com.mmg.app.svg.ShoeComponentPNGCreator.traverseFolder(ShoeComponentPNGCreator.java:186) at com.mmg.app.svg.ShoeComponentPNGCreator.main(ShoeComponentPNGCreator.java:662) sometimes it says height is 0 , sometimes it says stroke-width is not valid attributes etc. i think it is CSS engine related issue. what do i do wrong here ? Thank You Mihir Parekh -- View this message in context: http://batik.2283329.n4.nabble.com/Strange-CSS-Exception-while-loading-updating-and-transcoding-svg-document-tp4655504.html Sent from the Batik - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org