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

use Perl Log In

Log In

[ Create a new account ]

Journal of Dom2 (2981)

Thursday December 02, 2004
03:57 AM

XML::Genx

[ #22102 ]

After seeing the article on Extending Ruby with C, I thought "I wonder how easy that would be in Perl?" The article is mostly about providing access to the Genx library. So, I spent a little while playing with it and came up XML::Genx. I don't know whether Perl needed another XML writing library; XML::SAX::Writer is pretty good. But Genx has some really useful features.

  • Doesn't require SAX. :-)
  • Will not output non-well-formed XML.
  • Always outputs UTF-8.
  • Ouputs canonical XML, which makes for much easier testing.

Anyway, it's been an interesting exercise. My C skills needed bringing out of storage, although I made few really daft mistakes. XS is still an "interesting" tool to work with. Coding at that level certainly makes you appreciate how high level Perl is.

On the whole though, the most useful surprise has been CPAN Testers. That's a really good way to find out that the world isn't just as FreeBSD faced as it looks like to me. Now all I need to do is figure out how to get a development environment working under windows.

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.
  • You know, when I saw that on the CPAN recent modules list I'd wondered if it had been prompted by the article. Good to know people are reading my stuff ;-)
    • Your assertions about XS in there were quite correct. ;-)

      The other thing I really admire about the ruby version is the block syntax. Of course, it's possible in Perl, just ugly. And no, I refuse to use a source filter.

      But yes, thanks for the inspiration!

      -Dom

      • Another thing that wasn't mentioned in the article, but which is present in the latest version is a builder mode, so you can do stuff like this:

        require 'genx/builder'

        w = GenX::Writer.new(STDOUT)

        w.builder do |b|
          b.foo do
            b.bar('blah')
            b.bar('zot')
          end
        end

        And get output like this:

        <foo>
          <bar>blah</bar>
          <bar>zot</bar>
        </foo>

        This also caches elements and attributes so they don't get recreated each time through, and it a

        • I'm glad I'm not the only one implemented it "because it looks interesting". ;-)

          That said, it's one of those things that I'm sure I'll find a use for before long, probably at work.

          -Dom

        • Looking closer at that, I implemented something similiar [cpan.org] before... That was interesting; I wanted to see how closures and SAX would go together.

          -Dom