in reply to Code Generation in Perl

If you needed a little more info that the SQL already contained you could have added it in there, eg. in the form of some specialy formated comments. That way your users do not have to learn a whole new "language", just a few additional attributes. And if someone does have the SQL ready, he/she doesn't have to rewrite it into XML to be able to use your generator.

I would prefer

create table occupation /*#descriptor="description"*/ ( description varchar(40) not null /*#caption="occupation"*/, comments text )
to
<table name="occupation" caption="occupation" descriptor="description" +> <field name="description" type="varchar" size="40" notnull="1" cap +tion="occu +pation"/> <field name="comments" type="text" caption="comments"/> </table>
anytime. But that's maybe because I would prefer anything to XML.

Jenda
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
   -- Rick Osborne

Replies are listed 'Best First'.
Re^2: Code Generation in Perl
by nferraz (Monk) on Jun 19, 2004 at 13:19 UTC
    Interestingly, that's exactly what I did in the first versions of auto_coder.

    One of the problems with this approach is that we don't have an easy way to define broader project properties -- we're too focused on the database design.

    Moreover, we must write different scripts for different databases; with XML we can write a single source and generate different scripts.

    Another advantage of XML is the avaibility of modules like XML::Simple, which translates a XML source into a Perl data structure like this:

    $VAR1 = { 'table' => [ { 'descriptor' => 'name', 'caption' => 'contact', 'name' => 'contact', 'field' => [ { 'notnull' => '1', 'caption' => 'first name', 'name' => 'name', 'type' => 'varchar', 'size' => '40' }, { 'visible' => '1', 'caption' => 'organization', 'name' => 'organization', 'type' => 'varchar', 'size' => '40' }, # ...and so on.

    In other words, extending SQL with comments *was* my first approach, but it had its shortcomings.