Pennington / Example

XTRAN Demonstration:  Generating HTML Table of Images

You have a directory full of graphic images, and you need a way to see what they look like in a convenient form.  How about an HTML page showing them with their file names?  Then you can just point your favorite browser at it.

This example uses a set of XTRAN rules (meta-code) that reads image file names (one per line) from a text file, and generates an HTML table to show the images with their file names.  It picks up its input and output file names, a title, and the table's number of columns from environment variables.  In this case, we specified 5 columns in the table, and for demonstration purposes, we used an input file that repeatedly names two image files used elsewhere on this Web site.



* Rules:

The following is an English paraphrase of the XTRAN rules used for this example.  These rules comprise 42 (net) lines of XTRAN's rules language, and took less than an hour to create, refine, and debug.

    Open input file named by environment variable
    Create output file named by environment variable
    Fetch table's title and number of columns from environment variables
    Start HTML table
    For each image file name read from input file
        If table row already completed
            End table row, start next one
        Add table entry with image reference and file name
    End last table row, finalize table
    Close input and output files


* Input file name file:

new.gif
updated.gif
new.gif
updated.gif
new.gif
updated.gif
new.gif
new.gif
updated.gif


* Output (rendered HTML):

"New" and "Updated" Animated GIFs


new.gif

updated.gif

new.gif

updated.gif

new.gif

updated.gif

new.gif

new.gif

updated.gif


* Output (HTML text):

<HTML>

<TITLE>"New" and "Updated" Animated GIFs</TITLE>

<DIV>

<H2 ALIGN="center"><FONT FACE="Arial">&quot;New&quot; and
&quot;Updated&quot; Animated GIFs</FONT></H2>

<TABLE BORDER="1" CELLSPACING="1" CELLPADDING="1">

<TR>
<TD ALIGN="center"><IMG SRC="new.gif" /><BR />new.gif</TD>
<TD ALIGN="center"><IMG SRC="updated.gif" /><BR />updated.gif</TD>
<TD ALIGN="center"><IMG SRC="new.gif" /><BR />new.gif</TD>
<TD ALIGN="center"><IMG SRC="updated.gif" /><BR />updated.gif</TD>
<TD ALIGN="center"><IMG SRC="new.gif" /><BR />new.gif</TD>
</TR>

<TR>
<TD ALIGN="center"><IMG SRC="updated.gif" /><BR />updated.gif</TD>
<TD ALIGN="center"><IMG SRC="new.gif" /><BR />new.gif</TD>
<TD ALIGN="center"><IMG SRC="new.gif" /><BR />new.gif</TD>
<TD ALIGN="center"><IMG SRC="updated.gif" /><BR />updated.gif</TD>
</TR>

</TABLE>

</DIV>

</HTML>


COPYRIGHT 2008; reproduction prohibited without permission.  Revised 2006-11-27

XTRAN is a trademark of Pennington Systems Incorporated.

Pennington Systems Incorporated
8655 East Via de Ventura, Suite G200
Scottsdale, Arizona 85258-3321

Phone:  +1(480)626-5503
Fax:  +1(480)626-7618
Email:  Info@Pennington.com
Web:  http://WWW.Pennington.com

[home] Home