1 17 18 19 20 package org.apache.fop.fo.extensions.svg; 21 22 import java.util.HashMap ; 23 import javax.xml.parsers.SAXParserFactory ; 24 25 import org.apache.batik.util.XMLResourceDescriptor; 26 import org.apache.fop.fo.ElementMapping; 27 import org.apache.fop.fo.FONode; 28 import org.w3c.dom.DOMImplementation ; 29 30 34 public class BatikExtensionElementMapping extends ElementMapping { 35 36 37 public static final String URI = "http://xml.apache.org/batik/ext"; 38 39 private boolean batikAvail = true; 40 41 42 public BatikExtensionElementMapping() { 43 namespaceURI = URI; 44 } 45 46 47 public DOMImplementation getDOMImplementation() { 48 return null; } 50 51 56 private final String getAParserClassName() { 57 try { 58 SAXParserFactory factory = SAXParserFactory.newInstance(); 60 return factory.newSAXParser().getXMLReader().getClass().getName(); 61 } catch (Exception e) { 62 return null; 63 } 64 } 65 66 protected void initialize() { 67 if (foObjs == null && batikAvail == true) { 68 try { 72 XMLResourceDescriptor.setXMLParserClassName( 73 getAParserClassName()); 74 75 foObjs = new HashMap (); 76 foObjs.put("batik", new SE()); 77 foObjs.put(DEFAULT, new SVGMaker()); 78 } catch (Throwable t) { 79 batikAvail = false; 82 } 83 } 84 } 85 86 static class SVGMaker extends ElementMapping.Maker { 87 public FONode make(FONode parent) { 88 return new SVGObj(parent); 89 } 90 } 91 92 static class SE extends ElementMapping.Maker { 93 public FONode make(FONode parent) { 94 return new SVGElement(parent); 95 } 96 } 97 98 } 99 | Popular Tags |