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>
       

      • 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).

        What if you wrote the correct tag name, but it gets inserted in the wrong place? What if the content is bad or a required attribute is missing?

        Of course, a schema can only be used to validate well-formed documents…

      • 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 possib

          • 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
      • 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:

        That is not even remotely well-formed XML (note the unclosed "br" tags, for example), but it's perfectly valid for Yahoo!'s IDIF format. Trying to produce a bunch of stuff like this with most XML modules is what finally led me to start writing my own. From what I can see, XML::Generator will not allow me to write that.

        I'm sure the usefulness of this information is long gone for you,