Chapter 7
XML::SAX
The Perl XML
21
 community has come a long way in recent years. In the beginning 
there was XML::Parser, created by Larry Wall and maintained by Clark Cooper. 
XML::Parser provides a thin wrapper around the Expat XML parsing library 
written in C.
22
 At the same time, the Perl XML mailing list, 
perl xml@listserv.ActiveState.com, got started to provide a place to discuss using 
XML with Perl.
XML::Parser did (and still does) an excellent job of parsing XML. But it suffers 
from a quirky interface that is difficult to learn to use effectively. As a result, many 
wrapper modules grew up around XML::Parser XML::Twig, XML::Simple, and 
XML::TokeParser, to name a few. These modules have helped the situation a great 
deal and are basically the  state of the art  in Perl XML usage.
XML::SAX
23
 may not be the most popular module at present, but it represents 
an evolutionary step forward in the development of Perl's capabilities. It provides an 
interface for XML parser usage in the same way that DBI provides an interface for 
SQL database usage. Individual XML parsers can be plugged into the back end API 
provided by XML::SAX. Much like using MySQL through DBI means loading the 
DBD::MySQL module, using Expat through XML::SAX loads XML::SAX::Expat. On 
the front end modules can make use a of consistent and standardized
24
 interface 
to whichever parser is in use.
XML::SAX is an object oriented module, and it provides much of its function 
ality through inheritance. To start building a SAX parser or filter, the user creates a 
module that inherits from XML::SAX::Base and overrides methods as required to 
implement the desired functionality. It is interesting to note that although XML::SAX is 
tackling a similar problem to DBI, the choice of object oriented methods differs 
DBI chooses a complex mix of composition and inheritance, whereas XML::SAX 
chooses a pure inheritance model.
One of the most interesting front end modules to make use of XML::SAX thus 
far is XML::SAX::Machines by Barrie Slaymaker. XML::SAX::Machines provides a 
layer over XML::SAX based parsers and filters that allows the end user to easily 
construct XML processing pipelines. Using XML::SAX::Machines, XML::SAX com 
ponents can be assembled into systems of almost limitless capability. Typically, 
input XML enters one end of the pipeline through a SAX parser, is transformed and 
processed by the configured SAX filters, and is output by a SAX writer at the end. 
21. XML stands for the eXtensible Markup Language. See http://www.w3c.org/XML for details.
22. Written by James Clark. See http://expat.sourceforge.net for details.
23. Written by Matt Sergeant. See http://sergeant.org.
24. XML::SAX implements the SAX standard, versions 1 and 2. See http://www.saxproject.org
for details.
172






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved