That's it! Given the XML file, a Perl script will generate the complete Perl code, Class::DBI modules, templates (using Template Toolkit), documentation and diagrams automatically. Of course, you can include as much details as needed. For instance, a project can have multiple tables and relationships:
I'm releasing AppML under the GNU General Public License, and the complete source code is available for download. Any feedback will be appreciated! Best wishes, Nelson --
In applm.pl, you say
$SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /Use of uninitialized value/ };
Why not just this?
no warnings 'uninitialized';Your program needs pod badly, there is no documentation.
After Compline,
Zaxo
I like that idea, but I've never liked having to write XML by hand. What's the benefit over an API more like:
my $project = APPML::Project->new(
name => "sample",
title => "Sample Application"
);
my $table = $project->add_table(
name => "contact",
caption => "contact",
descriptor => "name"
);
my $vc40notnull = AppML::FieldType->new(
type => "varchar",
size => "40",
notnull => "1",
);
$table->add_fields(
[
name => "name",
caption => "name",
type => $vc40notnull,
],
[
# more fields here...
]
);
$project->create();
That's the sort of interface I'd create. Maybe it's appropriate to make that write out the XML for you, but I'd personally skip the step of writing out XML, reading it in, and translating it into internal data structures.
nferraz@debian:~/appml$ ./appml.pl xml/sample.xml meta/db/create.tmpl -> sample/db/create.sql meta/db/view.tmpl -> sample/db/view.sql meta/db/stats.tmpl -> sample/db/stats.sql meta/db/drop.tmpl -> sample/db/drop.sql meta/pl/base.tmpl -> sample/lib/sample.pm meta/pl/base_cdbi.tmpl -> sample/lib/sample/cdbi.pm meta/pl/cdbi.tmpl -> sample/lib/sample/cdbi/contact.pm meta/templates/header.tmpl -> sample/templates/inc/header.tt2 meta/templates/menu.tmpl -> sample/templates/inc/menu.tt2 meta/templates/stats.tmpl -> sample/templates/inc/stats.tt2 meta/templates/footer.tmpl -> sample/templates/inc/footer.tt2 meta/templates/frm.tmpl -> sample/templates/contact/frm_contact.tt2 meta/templates/detail.tmpl -> sample/templates/contact/detail_contact.tt2 meta/templates/list.tmpl -> sample/templates/contact/list_contact.tt2 meta/templates/tbl.tmpl -> sample/templates/contact/tbl_contact.tt2 meta/doc/install.tmpl -> sample/doc/INSTALL meta/doc/plan.tmpl -> sample/doc/sample.html meta/doc/dot.tmpl -> sample/doc/sample.dot meta/data/strings.tmpl -> sample/data/sample.txtAs you can see, the source metafiles are divided in directories:
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
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
$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.
perlmonks.org content © perlmonks.org and autarch, chromatic, Jenda, nferraz, perlfan, Zaxo
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03