Slash Boxes
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.
More | Login | Reply
Loading... please wait.
  • For what it's worth, it sounds like what you're doing is a job that SAX is perfect for - reading, transforming, writing. SAX cleanly gives you these layers in a well designed manner. Unfortunately the book you're learning from doesn't cover SAX very well, because it was started before the XML::SAX project was finalised, however there's another book published by New Riders called XML and Perl [] which is supposed to cover SAX better (I haven't received my copy yet).

    Not that you'd re-write all this now you have
    • by toma (3098) on 2002.12.28 5:17 (#15628) Homepage Journal
      I'll give SAX a try. I have no problems with rewriting all my code, especially since I am trying to create an example for others to follow, not just a quick solution for a specific problem.

      Perl & XML has a chapter on SAX. I'll start there, and I have ordered the New Riders book. Let me know if you have more recommendations for good SAX tutorials or documentation! Otherwise I'll just start slogging through XML::SAX::Intro and friends.

      As I mentioned, I am particularly interested in exploiting the symmetry between reading and writing a quasi-flat (lumpy?) file. Is there a trick that will let me accomplish this? The existance of such a trick would be a light at the end of the tunnel for me.

      I would like to be able to create a SAX driver for my non-XML source that can do this. This would enable me to change the code in only one place when I need to fix a bug or adapt to changes in the quasi-flat file format. As my code stands now, I will have to change both the reader and the writer.


      It should work perfectly the first time! - toma
      • Unfortunately in SAX readers and writers are distinct too, simply because the operations tend to be very different. So you would have to write separate modules that did both.

        However there's nothing stopping you unifying some of the code if it's relevant to do that. You could put functions that you would use for both reading and writing in a separate package.

        A good example to look at for readers is Pod::SAX. Also check out XML::Generator::DBI. As far as writers go, there's not much detail on them. I tend t