Michalis has asked for the wisdom of the Perl Monks concerning the following question:

Ok, straight to the point: I have a web-site being a database application. It contains html pages (with server-side includes) and CGI scripts (created dynamically, interacting with a database) with CGI.pm

I think everybody has something like this these days :-)

The question is:

Is it possible to "port" the site to XML (completely)? I know how to do the static pages (although I have no idea about the ssi) but I don't know how to handle the dynamically created pages (i.e. CGIs).

Do you think a module like CGI.pm creating XML instead of html be usefull? (yes, I know the DTD and schema considerations).

Thanks in advance for any answers.

Replies are listed 'Best First'.
Re: Dynamic XML
by davorg (Chancellor) on Jun 16, 2000 at 16:50 UTC
    You could use CGI.pm for creating XML as it has nice feature that it will autogenerate HTML functions. Try this:
    use CGI qw(:standard tag); print tag({-type=>'invented', 'I made this up');
    Which will print
    <TAG TYPE="invented">I made this up</TAG>
    ... but is does have the disadvantage that it converts all tag names to upper case.

    A quick check on CPAN also finds a module called XML::Generator which looks like it might do what you want.

    How are you planning to deliver the XML to the browser? You should check out AxKit.
Re: Dynamic XML
by Michalis (Pilgrim) on Jun 16, 2000 at 18:25 UTC
    Regarding the delivery to server, i intend to use cocoon.

    Yes, I know of that feature of CGI, but as you said, it converts all tags to upper case which is not valid xml.

    I will check XML::Senerator, but I think it would probably be easier if I created a module (based on CGI.pm of course, for not re-inventig the weel :-)) for creating XML output.

      Upper case tag names _are_ valid XML as long as your DTD defines than as upper case. It looks to me like XML::Generator is probably based on CGI.pm already. You can do stuff like:
      use XML::Generator; my $x = XML::Generator->new('escape' => 'always', 'conformance' => 'strict'); print $x->foo($x->bar({baz=>3}, $x->bam()), $x->bar(['qux'],"Hey there,\n", "world"));
      which would generate
      <foo><bar baz="3"><bam /></bar><qux:bar>Hey there, world</qux:bar></foo>
      So the API looks very similar to CGI.pm - even down to the hash reference for attributes.

      --
      http://www.dave.org.uk

      European Perl Conference - Sept 22/24 2000
      http://www.yapc.org/Europe/
        How would you change this up to includes thousands of entries? I just started fiddling around with it, but so far I am only returning the last entry in my query. all of my data is stored in a hash right now, but I thought it would be great to use the XML generator to drop all of that data in the proper format, but could use a little guidance.