SPUG: Generating XML

Colin Meyer cmeyer at helvella.org
Tue Nov 20 13:02:15 CST 2001


Amidst 90% the offtopic messages on this list recently, here's a
question about dealing with XML from Perl.

I've done a fair bit of work with XML in Perl, but typically it has had
to do with receiving information formatted in XML, with the task of
having to decipher the contents and sift the groolly bits of data out.
My current project adds another task: generating XML to match particular
DTDs. I'll receive Perl data structures, and need to translate them into
valid XML.

I've two thoughts on how to do this. In my simple proof-of-concept
program sketches, they seem to be approximately equal. One is to use a
template file, and fill in the changing pieces, and the other is to
create a DOM structure, and then call its $d->toString() method. Does
anyone on the list have experience with either of these styles of
generating XML? A third style that I haven't tried would be to create
a system that would interpret the Perl data structure, and then
generate SAX events. This also seems easy enough, but I haven't played
with it yet.

A SAX style pipeline for all processing from input to output won't work
in this case, as the data from the querying doc is quite different than
the data of the replying doc.

The tricky bit that I haven't solved is complying to the DTD in such
a manner that I'll be sure that my generated doc is correct.  

Thanks for any advice,

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/

More information about the spug-list mailing list