Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: RFC: XML::Composer

by diotalevi (Canon)
on Sep 30, 2005 at 21:46 UTC ( #496525=note: print w/replies, xml ) Need Help??


in reply to RFC: XML::Composer

So which modules am I supposed to use if I want to make XML? The very few times I've had to deal with this I found myself having to manually encode data for interpolation into a string area. I also found that XML::Simple made it difficult to create XML that had the tags in all the right order so it would still pass DTD validation.

So please let me know what is actually supposed to be used and probably include that in your module too.

Replies are listed 'Best First'.
Re^2: RFC: XML::Composer
by Tanktalus (Canon) on Sep 30, 2005 at 23:01 UTC

    Monk 1: What X should I use?
    Monk 2: My favourite is a.
    Monk 3: Oh, I always use b. b rules!
    Anonymonk 1: Oh, come on, b is the sux0r! It can't even handle z properly
    Monk 3: Can't we just get rid of anonymonks? They're such a pain.
    Monk 4: Everyone I know is using c. Seems to do the job for me ...


    Translation: oi, you could start a flamewar with a question like that. :-)

    I may not have many tools in my XML toolbox, but XML::Twig has seemed to handle everything so far. Admittedly it won't handle "bad" XML as Ovid is trying to do, but for "good" XML production, I've been quite happy with XML::Twig. My requirements when I chose XML::Twig were to be able to read in an XML template, look up data from other data sources, process it, and insert transformed data into the XML template, and then have that parsed/used by a Java application where order usually mattered. XML::Twig allowed me to turn around that project in a matter of time that impressed me. YMMV

Re^2: RFC: XML::Composer
by Ovid (Cardinal) on Sep 30, 2005 at 21:53 UTC

    There are tons of modules that let you write XML. <snark>Which one you want to use depends upon which set of bugs you want to avoid</snark>. Seriously, XML::Genx and XML::Writer are both fairly decent thought getting namespaces to work can be excruciatingly painful.

    Cheers,
    Ovid

    New address of my CGI Course.

      FYI - XML::Writer does allow you to generate invalid XML. You just have to turn off the well-defined check(s) that you're violating. :-)

      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

        Part of the problem with that module is explained in the bug report I just filed. Namespaces are handled poorly. Also, I don't know that it allows me to insert unescaped data between tags. I know I should do that, but I don't have a choice. There are some really, really bad XML "variants" out there.

        Cheers,
        Ovid

        New address of my CGI Course.

Re^2: RFC: XML::Composer
by grantm (Parson) on Sep 30, 2005 at 22:00 UTC
Re^2: RFC: XML::Composer
by Anonymous Monk on Sep 30, 2005 at 22:16 UTC
    Any XML generator module that you use will have the same problem with regard to tag ordering. If you need to get tag a and then tag b in the right order, it's really up to you to do that. Usually, the best way is a small wrapper library on top of whatever XML generator you're using. As to which one, I have to point out XML::Genx, which I wrote (well wrote the XS interface anyway). It's very, very careful about making damned sure that you don't end up with non-well-formed XML. That means that you'll either produce parseable XML, or get an exception. If you make it produce non-well-formed XML, it's a bug. -Dom

      I just modified my code so that attributes are passed in an array reference instead of a hash reference, thus preserving attribute order.

      Update: I modified it again so it takes either a hashref or an arrayref.

      Cheers,
      Ovid

      New address of my CGI Course.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://496525]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2020-05-31 11:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (173 votes). Check out past polls.

    Notices?