From: TAKAHASHI Masayoshi Date: 2002-02-08T03:01:06+09:00 Subject: Re: XML::SAX2 critique Hello, First of all, I'm very glad to read a critique and suggestion by heavy user of SAX (and also author of XML::SAX::PurePerl!), especially SAX in Perl, one of lightweight-languages like Ruby. msergeant@star.net.uk (Matt Sergeant) wrote: > XML::SAX2 seems to be an almost verbatim copy of the Java SAX2 APIs. Yes, almost, with some exceptions. For example, characters(chars) doesn't use start and length. > I strongly believe that they have made a very poor choice in their API > by passing the node information to the callbacks as a list of > parameters. Hmm... > Now picture a cleaner API: > > handler.start_element(el) > > Where element is a lightweight class Element [1], which encapsulates > the above information and the attributes. Simple to construct, but > most importantly: extensible. This is how the Perl SAX APIs have been > designed, right from the start, and it meant that Perl SAX1 was mostly > compatible with Perl SAX2 [2]. > > I really urge people to consider the implications of something like > this - it's a major design decision - if you carve in stone the Ruby > SAX2 API now, and copy the Java design, you may regret it. I consider this issue before. The reasons I choose this interface are: 1. compatibility of other language's SAX API 2. speed I know that Perl use not strings but object as parameter of startElement, but C, Java and Python use strings, and I don't know other language which use Perl sytle API. In addition, creating objects need cost. Yes, this cost is not so expensive, and Ruby usually pays many many cost :-) But IMO, SAX should be sensitive about cost. If we can ignore cost, we can use, say, tree API like REXML. It maybe more Ruby-stic and easy to use. But.... I think that compatibility is not so important, and simplicity and extensibility is very important. Matt's suggestion is thoughtful. At least, I should write other API using Element object and compare them. By the way: I don't catch up with Perl-XML ML, but (maybe last year) I found discussion about ParserDetails.ini in Perl SAX2. I think Ruby also need similar configuration, but I don't know what conclution they come to. Could you tell me how to use (or not use) ParserDetails.ini in Perl? Is there a document about it? Thanks, TAKAHASHI 'Maki' Masayoshi E-mail: maki@rubycolor.org