Some time ago, I published an article about an open source Customer Relationship Management (CRM) application I was working on.

What I didn't tell you at the time, is that I was also working on a code generation tool which would allow me to generate a database-driven web application, just like this, in minutes.

The first version, called auto_coder, took an SQL script and generated all the required Perl scripts, modules and templates. The problem was that SQL isn't extensible: there's only so much information you can infer from a SQL script.

The solution was to use an extensible markup language -- XML for short :) -- to describe the database and all the required information.

This lead to a new version of my code generator, which I called "AppML" ("Application Markup Language").

Here's a small application described in AppML:

<project name="sample" title="Sample Application"> <table name="contact" caption="contact" descriptor="name"> <field name="name" type="varchar" size="40" notnull="1" caption="n +ame"/> <field name="organization" type="varchar" size="40" caption="organ +ization" visible="1"/> <field name="phone" type="varchar" size="40" caption="work phone"/ +> <field name="fax" type="varchar" size="40" caption="fax"/> <field name="mobile" type="varchar" size="40" caption="mobile"/> <field name="email" type="varchar" size="40" caption="e-mail" visi +ble="1"/> <field name="notes" type="text" caption="notes"/> </table> </project>

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:

<project name="crm" title="CRM"> <table name="sector" caption="sector" descriptor="description"> <field name="description" type="varchar" size="40" notnull="1" cap +tion="sector"/> <field name="comments" type="text" caption="comments"/> </table> <table name="comp_size" caption="company size" descriptor="descripti +on"> <field name="description" type="varchar" size="40" notnull="1" cap +tion="size"/> <field name="comments" type="text" caption="comments"/> </table> <table name="occupation" caption="occupation" descriptor="descriptio +n"> <field name="description" type="varchar" size="40" notnull="1" cap +tion="occupation"/> <field name="comments" type="text" caption="comments"/> </table> <table name="contact" caption="contacts" descriptor="display_name"> <rel name="sector" type="association" table="sector" caption="sect +or"/> <rel name="comp_size" type="association" table="comp_size" caption +="comp_size"/> <rel name="occupation" type="association" table="occupation" capti +on="occupation"/> <field name="first_name" type="varchar" size="40" notnull="1" capt +ion="first name" visible="1"/> <field name="last_name" type="varchar" size="40" notnull="1" capti +on="last name" visible="1"/> <field name="display_name" type="varchar" size="40" notnull="1" ca +ption="display name"/> <field name="organization" type="varchar" size="40" caption="organ +ization"/> <field name="address" type="varchar" size="40" caption="address"/> <field name="city" type="varchar" size="40" caption="city"/> <field name="state" type="varchar" size="40" caption="state"/> <field name="country" type="varchar" size="40" caption="country"/> <field name="phone" type="varchar" size="40" caption="work phone"/ +> <field name="fax" type="varchar" size="40" caption="fax"/> <field name="mobile" type="varchar" size="40" caption="mobile"/> <field name="email" type="varchar" size="40" caption="e-mail"/> <field name="notes" type="text" caption="notes"/> </table> </project>

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

--
Nelson Ferraz
GNU BIS


In reply to Code Generation in Perl by nferraz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.