You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by BUFFET Philippe <ph...@airbus.com> on 2003/05/23 09:20:40 UTC

Problems with xerces parser in an applet

Hi,

I am currently developping an applet and I encounter some difficulties. [I
precise that I am a newbee of batik]
I wanted to create an HTML button which allows to change the SVG file
loaded in the viewer... 
In fact, I defined a public method in the applet class :

 /** Change the current file loaded in the applet
     *  Can be called from the HTML page via JavaScript
     *  @param uri : uri of the SVG file to load in the viewer
     */
    public void setSVGDocument(String uri){
 
canvas.setURI(getClass().getClassLoader().getResource(uri).toExternalForm())
;
    }

When this method is called from a JButton inside the applet it woks fine,
but when this method is called outside the applet from an HTMLButton, it
produces an error : "SAX2 driver class org.apache.xerces.parsers.SAXParser
not found"

java.io.IOException: SAX2 driver class org.apache.xerces.parsers.SAXParser
not found 	at
org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)
at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
Source) 	at
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
Source) 	at
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createSVGDocument(Unknown
Source) 	at
org.apache.batik.bridge.DocumentLoader.loadDocument(Unknown Source) 	at
org.apache.batik.swing.svg.SVGDocumentLoader.run(Unknown Source)

Apparently, this problem comes from the Xerces parser itself, because the
only way I found to avoid this is to use Crimson parser (included in the JRE
1.4) [
XMLResourceDescriptor.setXMLParserClassName("org.apache.crimson.parser.XMLRe
aderImpl");]
Any ideas about that?? (I consider that I solve my problem.. (I hope Batik
works fine with Crimson) and I just want to have an explanation about this
bug..)

regards all.. I hope this can help for others

	Philippe


RE: Problems with xerces parser in an applet

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "BP" == BUFFET Philippe <ph...@airbus.com> writes:

BP> Hi, I am currently developping an applet and I encounter some
BP> difficulties. [I precise that I am a newbee of batik] I wanted to
BP> create an HTML button which allows to change the SVG file loaded
BP> in the viewer...  In fact, I defined a public method in the applet
BP> class :

BP>  /** Change the current file loaded in the applet * Can be called
BP> from the HTML page via JavaScript * @param uri : uri of the SVG
BP> file to load in the viewer */ public void setSVGDocument(String
BP> uri){
 
BP> canvas.setURI(getClass().getClassLoader().getResource(uri).toExternalForm())
BP> ; }

BP> When this method is called from a JButton inside the applet it
BP> woks fine, but when this method is called outside the applet from
BP> an HTMLButton, it produces an error : "SAX2 driver class
BP> org.apache.xerces.parsers.SAXParser not found"

    I suspect that the problem is that Xerces is not on the classpath
for the 'sandbox' that the HTMLButton is in (classloaders are a bit
funny for applets).

BP> Apparently, this problem comes from the Xerces parser itself,
BP> because the only way I found to avoid this is to use Crimson
BP> parser (included in the JRE 1.4) [
BP> XMLResourceDescriptor.setXMLParserClassName("org.apache.crimson.parser.XMLRe
BP> aderImpl");] Any ideas about that?? (I consider that I solve my
BP> problem.. (I hope Batik works fine with Crimson) and I just want
BP> to have an explanation about this bug..)

    I would consider the use of the JDK Crimson the 'Right thing'(TM)
in the case of Applets that require JRE 1.4 - this can save
significant download time.  Be aware that while Batik does work well
for the version of Crimson included in the JDK it has issues with the
latest Crimson releases, which is why we switched to Xerces.

BP> regards all.. I hope this can help for others

BP> 	Philippe

BP> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD>
BP> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
BP> charset=iso-8859-1"> <META NAME="Generator" CONTENT="MS Exchange
BP> Server version 5.5.2655.35"> <TITLE>Problems with xerces parser in
BP> an applet</TITLE> </HEAD> <BODY>

BP> <P><FONT SIZE=2 FACE="Arial">Hi,</FONT> </P>

BP> <P><FONT SIZE=2 FACE="Arial">I am currently developping an applet
BP> and I encounter some difficulties. [I precise that I am a newbee
BP> of batik]</FONT> <BR><FONT SIZE=2 FACE="Arial">I wanted to create
BP> an HTML button which allows to change the SVG file&nbsp; loaded in
BP> the viewer... </FONT> <BR><FONT SIZE=2 FACE="Arial">In fact, I
BP> defined a public method in the applet class :</FONT> </P>

BP> <P><I><FONT SIZE=2 FACE="Arial">&nbsp;/** Change the current file
BP> loaded in the applet</FONT></I> <BR><I><FONT SIZE=2
BP> FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp; Can be called from
BP> the HTML page via JavaScript</FONT></I> <BR><I><FONT SIZE=2
BP> FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp; @param uri : uri of
BP> the SVG file to load in the viewer</FONT></I> <BR><I><FONT SIZE=2
BP> FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp; */</FONT></I> <BR><I><FONT
BP> SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; public void
BP> setSVGDocument(String uri){</FONT></I> <BR><I><FONT SIZE=2
BP> FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
BP> canvas.setURI(getClass().getClassLoader().getResource(uri).toExternalForm());</FONT></I>
BP> <BR><I><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; }</FONT></I>
BP> </P>

BP> <P><FONT SIZE=2 FACE="Arial">When this method is called from a
BP> JButton inside the applet it woks fine, but when this method is
BP> called outside the applet from an HTMLButton, it produces an
BP> error</FONT><I> <FONT SIZE=2 FACE="Arial">: &quot;SAX2 driver
BP> class org.apache.xerces.parsers.SAXParser not
BP> found&quot;</FONT></I></P>

BP> <P><I><FONT SIZE=2 FACE="Arial">java.io.IOException: SAX2 driver
BP> class org.apache.xerces.parsers.SAXParser not found &nbsp;&nbsp;
BP> at
BP> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
BP> Source)&nbsp; at
BP> org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown
BP> Source)&nbsp; at
BP> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
BP> Source) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at
BP> org.apache.batik.dom.svg.SAXSVGDocumentFactory.createSVGDocument(Unknown
BP> Source) &nbsp;&nbsp;&nbsp; at
BP> org.apache.batik.bridge.DocumentLoader.loadDocument(Unknown
BP> Source)&nbsp; at
BP> org.apache.batik.swing.svg.SVGDocumentLoader.run(Unknown
BP> Source)</FONT></I></P>

BP> <P><FONT SIZE=2 FACE="Arial">Apparently, this problem comes from
BP> the Xerces parser itself, because the only way I found to avoid
BP> this is to use Crimson parser (included in the JRE 1.4)
BP> [&nbsp;&nbsp;
BP> XMLResourceDescriptor.setXMLParserClassName(&quot;org.apache.crimson.parser.XMLReaderImpl&quot;);]</FONT></P>

BP> <P><FONT SIZE=2 FACE="Arial">Any ideas about that?? (I consider
BP> that I solve my problem.. (I hope Batik works fine with Crimson)
BP> and I just want to have an explanation about this
BP> bug..)</FONT></P>

BP> <P><FONT SIZE=2 FACE="Arial">regards all.. I hope this can help
BP> for others</FONT> </P>

BP> <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2
BP> FACE="Arial">Philippe</FONT> </P>

BP> </BODY> </HTML>
BP> ---------------------------------------------------------------------
BP> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org For
BP> additional commands, e-mail: batik-users-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org