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.
  • A friend and I had a similar discussion about generating XML in a simple way today -- we trawled CPAN and found XML::Generator [cpan.org]. Does it do (most of) what you're looking for?

    • I had looked at XML::Generator and I liked it, but it had some problems. First, because of autoload, it's easy to do this:

      print $xml->feild('foobared');

      I probably meant "field". My version forces you to map methods to tags and will die if you try to print a tag that doesn't exist (though you can add methods/tags on the fly).

      Also, as far as I can tell, I would not be able to conveniently dump out data in the Yahoo! IDIF format. Here's an snippet:

      <?xml version="1.0"?>
      <IDIF>
       

      • This is not XML, so really it should not be labelled as such. AFAICT it is pretty close to being SGML though. It might even be SGML, the XML declaration would be seen by an SGML parser as a regular PI, you can add a DTD when you parse the file, and unenclosed tags and &\W are valid in SGML. You just need the characters to be in latin1.

        So why don't you go and pollute the SGML namespace ;--)

        Seriously, I don't think you should release your module in the XML namespace. An IDIF module would be OK, it its o

        --
        mirod
        • I have decided not to put this in the XML namespace. That much I agree on.

          I think my main problem with your module is the way you seem to advertise it, which sounds a bit like "let's generate more quasi XML to p.o. real XML guys" to me.

          I can see how that might appear to be what I was doing. I'll be sure to clarify that. Unfortunately, this is a real problem space that developers constantly face: legacy XML "variants" or third-party resources which require malformed XML. Since it's not always possible to force others (Yahoo!, for example) to conform to the spec, we have to have some flexibility here.

          One thing I think I will need to do is include a section on "testing tips". Testing poorly formed XML is difficult. I've a few pointers I can offer on that score. Fortunately, I've been writing it so programmers can have complete control over the output, down to the ordering of attributes (passing them as an array reference in lieu of a hash reference, if desired).

          • down to the ordering of attributes

            I feel your pain, having had to deal with exactly that request for XML::Twig (not a model of XML purity itself): apparently some Microsoft tool needs attributes in a specific order. The easiest solution I found was to use Tie::IxHash objects to store the attributes.

            --
            mirod