jeffa has asked for the wisdom of the Perl Monks concerning the following question:

This is really a question for Matts, but maybe someone else here has an answer. I am trying to use XML::Filter::SAX1toSAX2 and XML::Filter::SAX2toSAX1, but can't even get the Synopsis code to compile. If you want to try this out, you will need to download and install the following:
Here is the code for SAX1to2:
use strict; use XML::Handler::AxPoint; use XML::Filter::SAX1toSAX2; use XML::Parser::PerlSAX; my $handler = XML::Handler::AxPoint->new(); my $filter = XML::Filter::SAX1toSAX2->new(Handler => $handler); my $parser = XML::Parser::PerlSAX->new(Handler => $filter); $parser->parse(Source => { SystemId => "foo.xml" }); __END__ yields: Can't call method "push_context" on an undefined value at /usr/lib/perl5/site_perl/5.6.0/XML/Filter/SAX1toSAX2.pm line 25.
And here is SAX2to1:
use strict; use XML::Handler::YAWriter; use XML::Filter::SAX2toSAX1; use XML::SAX::ParserFactory; my $handler = XML::Handler::YAWriter->new(); my $filter = XML::Filter::SAX2toSAX1->new(Handler => $handler); my $parser = XML::SAX::ParserFactory->parser(Handler => $filter); $parser->parse_uri( "foo.xml" ); __END__ yields: Not an ARRAY reference at /usr/lib/perl5/site_perl/5.6.0/XML/Filter/SAX2toSAX1.pm line 47.
These seem like bugs, but since i am new to these modules, i suspect i am doing something wrong. Thanks in advance. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: SAX Filter: 2to1 and 1to2
by Matts (Deacon) on Jul 08, 2002 at 10:29 UTC
    Bug. Working on it.

    Note to self: Write more tests in modules. Repeat ad infinitum.

      OK, this is now fixed and uploaded to CPAN.

      The main problem was some mixup with the XML::NamespaceSupport API - I had misread the docs, basically. Following that, I had some plain hashes where I needed hashrefs. And then I hadn't implemented start/end prefix mappings.

      All fixed now and on CPAN. Including tests this time.

Re: SAX Filter: 2to1 and 1to2
by esskar (Deacon) on Jul 07, 2002 at 23:50 UTC
    does the file foo.xml really exist?
      Yep, sure does. This is generated from XML::Generator::DBI
      <?xml version="1.0" encoding="UTF-8"?> <database> <select query="select * from songs limit 3"> <row> <id>1</id> <title>Spanish Fly</title> <artist>Van Halen</artist> <album>Van Halen II</album> <year>1979</year> <genre>Rock &amp; Roll</genre> </row> <row> <id>2</id> <title>Beautiful Girls</title> <artist>Van Halen</artist> <album>Van Halen II</album> <year>1979</year> <genre>Rock &amp; Roll</genre> </row> <row> <id>3</id> <title>Dance The Night Away</title> <artist>Van Halen</artist> <album>Van Halen II</album> <year>1979</year> <genre>Rock &amp; Roll</genre> </row> </select> </database>
      The errors for a non-existant file are:
      # for SAX1toSAX2: Couldn't open oops: No such file or directory at /usr/lib/perl5/site_perl/5.6.0/XML/Parser/PerlSAX.pm line 146 # for SAX2toSAX1: Could not create file parser context for file 'oops' : No such file or directory at /usr/lib/perl5/site_perl/5.6.0/i386-linux/XML/LibXML.pm line 351. at /usr/lib/perl5/site_perl/5.6.0/i386-linux/XML/LibXML/SAX/Parser.pm line 37

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)