I just tried using the Crimson parser (as discussed in other places in the archives) and lo and behold my code snippet now runs successfully.
However my question is: In the long term is this going to cause me problems? I seem to remember an entry where someone noted that Batik was having problems with the latest version of Crimson....Kevin

-------- Original Message --------
Subject: SAX Parser problems
Date: Tue, 25 Nov 2003 05:01:12 -0600
From: Kevin Maione <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: batik-dev <[EMAIL PROTECTED]>


Hi all,
    I am trying to load an SVG example from the file system based on the 
example and having a problem. I am running the following code snippet:

String fileURI = 
"file:///C:\\java\\batik-src\\xml-batik\\samples\\extensions\\flowTextAlign.svg";    

try {
   
    String cls = "org.apache.xerces.parsers.SAXParser";
    Class aClass = Class.forName( cls );
    System.out.println( "Successfully created :"+aClass+"\n" );
    Object theParser = aClass.newInstance();
    System.out.println( "Successfully created instance of:"+aClass+"\n" 
);   
   
    org.w3c.dom.Document doc = null;
    String parser = 
org.apache.batik.util.XMLResourceDescriptor.getXMLParserClassName();
    System.out.println( "Parser class name:"+parser+"\n" );       
    org.apache.batik.dom.svg.SAXSVGDocumentFactory f = new 
org.apache.batik.dom.svg.SAXSVGDocumentFactory(parser);
    doc = f.createDocument(fileURI);
    System.out.println( "Successfully loaded document from :"+fileURI );
} catch (Exception e ) {
    System.out.println( "Failed to load from: "+fileURI );
    e.printStackTrace();
}


The results are as follows:
Successfully created :class org.apache.xerces.parsers.SAXParser

Successfully created instance of:class org.apache.xerces.parsers.SAXParser

Parser class name:org.apache.xerces.parsers.SAXParser

Failed to load from: 
file:///C:\java\batik-src\xml-batik\samples\extensions\flowTextAlign.svg
java.io.IOException: SAX2 driver class 
org.apache.xerces.parsers.SAXParser not found
    at 
org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:376)
    at 
org.apache.batik.dom.util.SAXDocumentFactory.createDocument(SAXDocumentFactory.java:299)
    at 
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(SAXSVGDocumentFactory.java:186)
    at CodeSnippet_10.run(CodeSnippet_10.java:16)
    at 
org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain1.eval(ScrapbookMain1.java:14)
    at java.lang.reflect.Method.invoke(Native Method)
    at 
org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain.evalLoop(ScrapbookMain.java:48)
    at 
org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain.main(ScrapbookMain.java:29)

I am runnng this test from a scrapbook page in Eclipse using a Sun JRE 
1.3.1.
The Eclipse project has the xerces_2_3_0.jar provided with the Batik 
distribution in the first position in the build classpath.

I've searched these archives and the FAQ and am stumped. Any help would 
be greatly appreciated. Thanks...Kevin



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


Reply via email to