XML::SAX first release is heading to CPAN now.
This is basically DBI for XML.
If you remember the days before DBI, we all used to use either OraPerl or Sybperl, which were hacked versions of the perl binary with Oracle or Sybase support compiled in (as functions).
Well that's about where Perl's XML support was until now - that is before today.
Now, instead of using a specific XML parser (e.g. XML::Parser, XML::LibXML, XML::SAX::PurePerl or something else), you can just use XML::SAX as a factory for parsers. Of course the parsers need to comply with the Perl SAX2 spec (so XML::Parser is out, but there will be SAX2 parsers based on XML::Parser coming out soon now), so that you're using the same interface regardless of the parser. But that's a good thing.
In XML::SAX you get the base XML::SAX, which is a registry of installed parsers on your machine. Then you get XML::SAX::Base, which is Kip Hampton's uber-cool Driver/Parser/Filter base class, which helps make sure you do the right thing wrt those types of "things" (see his XML.com column for more details). Also there's XML::SAX::Exception, which all Perl SAX2 parsers should use as an exception class. Then the all important XML::SAX::ParserFactory, which gives you something similar to DBI's "->connect" method, but better :-) Finally, the whole thing ships with XML::SAX::PurePerl, so that you always have a fallback parser.
I look forward to feedback from this. It's been a fun process.
Re:Cool!
Matts on 2001-11-13T16:26:19
No problem. Just derive from XML::SAX::Base and you'll be fine.