Hello,
I have an eclipse ide svg viewer that shows svg in a tabbed fashion, using 
JSVGCanvas. I have overridden the SAXSVGDocumentFactory. I am mainly trying to 
move to batik1.7 to see if the java heap issue (using batik1.6 libs) that i 
encounter on opening about 6 to 7 jsvgcanvas instances to display 6 or more 
svgs go away.

public class EclipseSAXSVGDocumentFactory extends SAXSVGDocumentFactory {
    public EclipseSAXSVGDocumentFactory(String parser, boolean dd) {
        super(parser, dd);
    }

    protected Document createDocument(InputSource is) throws IOException {
        try {
            
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
            System.setProperty("javax.xml.parsers.SAXParserFactory", 
SAXParserFactoryImpl.class.getName());
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setFeature("http://xml.org/sax/features/namespaces";, true);
            
factory.setFeature("http://xml.org/sax/features/namespace-prefixes";, true);
            factory.setFeature("http://xml.org/sax/features/validation";, 
isValidating);
          
            SAXParser parser = factory.newSAXParser();
            parser.getXMLReader().setContentHandler(this);
            parser.getXMLReader().setDTDHandler(this);
            parser.getXMLReader().setEntityResolver(this);
            parser.getXMLReader().setErrorHandler((errorHandler == null) ? this 
: errorHandler);
            parser.setProperty("http://xml.org/sax/properties/lexical-handler";, 
this);
            parser.getXMLReader().parse(is);
        } catch (SAXException e) {
            Exception ex = e.getException();
            if (ex != null && ex instanceof InterruptedIOException) {
                throw (InterruptedIOException) ex;
            }
            throw new IOException(e.getMessage());
        } catch (ParserConfigurationException e) {
            throw new IOException(e.getMessage());
        }
        currentNode = null;
        Document ret = document;
        document = null;
        return ret;
    }
}

But on my createDocument i get the following exception:
java.lang.NullPointerException
        at 
org.apache.batik.dom.util.SAXDocumentFactory.startElement(SAXDocumentFactory.java:563)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at 
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown
 Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
 Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at 
com.dlsc.batik.viewer.EclipseSAXSVGDocumentFactory.createDocument(EclipseSAXSVGDocumentFactory.java:41)
        at 
org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:349)
        at 
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:201)
        at 
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createSVGDocument(SAXSVGDocumentFactory.java:125)
        at 
org.apache.batik.bridge.DocumentLoader.loadDocument(DocumentLoader.java:106)
        at 
org.apache.batik.swing.svg.SVGDocumentLoader.run(SVGDocumentLoader.java:84)

When i debug the inputsource is not null and the xmlreader is 
org.apache.xerces.SAXParser in batik1.7. But for batik 1.6 the parser is 
org.apache.xerces.jaxp.SAXParserImpl.
This code worked perfectly with batik1.6 but not on 1.7 does anybody have any 
pointers on what is wrong?

Thanks,
Emmy 
             

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to