Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • by Matts (1087) on 2003.01.04 16:55 (#15748) Journal
    The SAX code has a bunch of case statements in the handlers for which kind of tag is being processed. I would prefer to see this coded another way with SAX. I try to avoid big case statements.

    That's pretty much just how SAX works I'm afraid. It has a tendency to contain a large case statement with things that say: "If tag is this do this. If tag is that do that."

    I'd welcome alternate ways of designing SAX handlers though. Unfortunately that tends to be the way data driven code works.

    Trying SAX Modules

    Installed Pod::SAX with cpan. This has many dependencies, including XML::SAX::Writer. Installed okay. Pod documentation for the functions is missing. This style of code doesn't look like the kind of code that I like write.


    It only requires three modules - XML::SAX, XML::SAX::Writer (for the tests - though potentially I could write the tests without this) and Pod::Parser - which should be shipped with your perl.

    As for the style, mostly I copied other Pod::Parser based code. It tends to inforce a certain way of writing code unfortunately, and I find it a bit hacky. Though I would appreciate it if you could be more specific as it might help me clean up the module.

    The docs suck, I know. I'll work on that. It's tricky because partly I want to say "Uses SAX, generates XML that looks like this", but obviously that's not enough for most people.

    Installed XML::Generator::DBI with cpan. It failed tests looking for DBD/Pg.pm

    Strange. I'll look into it.

    there is some manual configuration that needs to be done. I didn't pursue this further because I have no database on this machine. The code is interesting to read though, both as an example of using XML::Handler::YAWriter and a nifty flexible DBI query.

    Theoretically the tests shouldn't require any DBD driver but I'll look into that tomorrow. Thanks.
    • I'd welcome alternate ways of designing SAX handlers though. Unfortunately that tends to be the way data driven code works.

      I'm not really knowledgable enough about SAX to understand this design problem to make a good suggestion, but I won't let that stop me.

      I have been using XML::Twig and XML::Writer with some success, and have enjoyed the XPath features in XML::Twig.

      Instead of writing a large case statement, I usually use a dispatch table. Typically I use a hash of anonymous subs, where the key to

      --
      It should work perfectly the first time! - toma