SAX: Java-Specific Question

Tyler Baker tyler at infinet.com
Sat Apr 4 06:27:37 BST 1998


David Megginson wrote:

> Here's a Java question.  Let's say that I have a class with a method
>
>   public void parse (String publicId, String systemId, Reader reader)
>     throws java.lang.Exception;
>
> What will happen if the "java.io.Reader" class is not available on my
> system (perhaps because I'm using a 1.0.2 browser), but I never invoke
> this method (I'm assuming that I compiled my code under JDK 1.1 or JDK
> 1.2)?

Well this deals with the issue of backward compatibility.  Classes like
java.awt.Component may elect to add new methods, but they must still support the
old ones.  Having an additional public void parse(String publicID, String
systemID, Reader reader) would not be a problem for old 1.0.2 programs at run
time since the JVM only loads classes (new ones) as it needs them.  So if you
never invoke a method with a reader class, then the reader class will never ever
get a chance to try and be initialized (which is good cause otherwise you would
get a ClassNotFoundException).

An example of this is with the AWT.  With JDK 1.1 a lot of new methods were added
to java.awt.Component (a bunch more are being added in JDK 1.2 as well).  If I
have a compiled applet for JDK 1.1, it should work in a JDK 1.2 environment
because none of the JDK 1.1 methods were removed, only new ones were added.

> I'm becoming convinced that we need to support character streams in
> SAX, and I'm trying to figure out how to handle it in the Java
> version -- I think that I've worked out pretty much everything else
> now, except for a few minor details.

It is really not a problem to do what you are talking about from a compatibility
standpoint and I have wondered why this was not done earlier.

One major question I have is regarding character support in Java.  If you look at
the XML spec, there are a lot of differences between the tables of what is
whitespace, legal unicode characters, etc. which make it so parser writers need
to write their own isWhitespace(char c) functions instead of using
Character.isWhitespace().  In this particular case, Java sees a Form Feed as
white space while the XML spec does not.  Does anyone have any ideas as to why
there are so many inconsistencies?

Tyler


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list