John Bokma Perl
freelance Perl programmer

Installing XML::SAX with ActiveState Perl

Short how to | 0 comments

If you install XML::SAX using ppm on Windows XP with ActiveState Perl you might in be for a surprise:

could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX

Somehow the ActiveState distribution of XML::SAX doesn't create ParserDetails.ini. You can fix it by either re-installing XML-SAX from a different repository, or run a Perl one-liner which executes code that should have been run after installation of XML::SAX.

Post install fix

If you enter the following Perl one-liner at the command line:

perl -MXML::SAX -e "XML::SAX->add_parser('XML::SAX::PurePerl')->save_parsers()"

and press enter, ParserDetails.ini is created with an entry for the default pure Perl parser which comes bundled with XML::SAX. Note that this one-liner complains about not being able to find ParserDetails.ini as well, but when it's finished this should be fixed from now on.

Re-installing XML-SAX from a different repository

Another way to get the missing ParserDetails.ini file is by running ppm again, uninstalling XML-SAX, and re-installing it from a different repository:

ppm> uninstall XML-SAX
Remove 'XML-SAX' version 0.12 from ActivePerl
unlink C:\Perl\html\site\lib\XML\SAX.html
31 lines removed for clarity
Successfully removed XML-SAX version 0.12 from ActivePerl
ppm> install
Install 'XML-SAX' version 0.12 in ActivePerl
Downloaded 53888 bytes.
Extracting 58/58: blib
Installing C:\Perl\html\site\lib\XML\SAX.html
30 lines removed for clarity
Do you want to alter ParserDetails.ini? [yes]
C:\Perl\bin\perl.exe -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::PurePerl))-
could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX
Successfully installed XML-SAX version 0.12 in ActivePerl
ppm> quit

When the installation asks if you want to alter ParserDetails.ini just press enter (yes). An ini file containing information regarding the bundled pure Perl parser will be created:

[XML::SAX::PurePerl] = 1

Test script

The following small Perl program should output each SAX parser available followed by a list of supported features:

use strict;
use warnings;

use XML::SAX;

for my $parser ( @{ XML::SAX->parsers } ) {

    print "$parser->{ Name }\n";

    my %features = %{ $parser->{ Features } };
    print "    $_ => $features{ $_ }\n"
        for sort keys %features;

    print "\n";

At the time of writing the aforementioned installation of XML::SAX only installs the pure Perl parser:

XML::SAX::PurePerl => 1

See also

Please post a comment | read 0 comments | RSS feed