You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axkit-dev@xml.apache.org by ma...@apache.org on 2002/04/02 18:27:54 UTC

cvs commit: xml-axkit/lib/Apache/AxKit/Provider File.pm

matts       02/04/02 08:27:54

  Modified:    .        Makefile.PL axconfig.c axconfig.h
               demo/xsp esql.xsp
               lib      AxKit.pm
               lib/Apache/AxKit ConfigReader.pm Exception.pm Provider.pm
               lib/Apache/AxKit/Provider File.pm
  Log:
  Implemented AxHandleDirs
  Implemented AxIgnoreStylePI
  Submitted by: Michael Kroell (AxIgnoreStylePI only)
  
  Revision  Changes    Path
  1.6       +3 -3      xml-axkit/Makefile.PL
  
  Index: Makefile.PL
  ===================================================================
  RCS file: /home/cvs/xml-axkit/Makefile.PL,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Makefile.PL	28 Mar 2002 20:09:38 -0000	1.5
  +++ Makefile.PL	2 Apr 2002 16:27:53 -0000	1.6
  @@ -1,4 +1,4 @@
  -# $Id: Makefile.PL,v 1.5 2002/03/28 20:09:38 jwalt Exp $
  +# $Id: Makefile.PL,v 1.6 2002/04/02 16:27:53 matts Exp $
   
   package AxKit;
   # file Makefile.PL
  @@ -71,10 +71,10 @@
   that module before installing AxKit.
   REASON
   
  -test_module('Error', '0.13', <<"REASON") || die;
  +test_module('Error', '0.14', <<"REASON") || die;
   ***** ERROR *****
   
  -Error 0.13 or higher required. This module is required for 
  +Error 0.14 or higher required. This module is required for 
   AxKit's internal exception handling
   routines. You will need to install that module before installing
   AxKit.
  
  
  
  1.2       +70 -32    xml-axkit/axconfig.c
  
  Index: axconfig.c
  ===================================================================
  RCS file: /home/cvs/xml-axkit/axconfig.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- axconfig.c	13 Jan 2002 20:45:08 -0000	1.1
  +++ axconfig.c	2 Apr 2002 16:27:53 -0000	1.2
  @@ -1,4 +1,4 @@
  -/* $Id: axconfig.c,v 1.1 2002/01/13 20:45:08 matts Exp $ */
  +/* $Id: axconfig.c,v 1.2 2002/04/02 16:27:53 matts Exp $ */
   
   #ifndef WIN32
   #include <modules/perl/mod_perl.h>
  @@ -83,9 +83,9 @@
   axkit_dir_config *
   new_axkit_dir_config (pool *p)
   {
  -    axkit_dir_config *new = 
  +    axkit_dir_config *new =
           (axkit_dir_config *) ap_palloc(p, sizeof(axkit_dir_config));
  -    
  +
       new->translate_output = -1;
       new->gzip_output = -1;
       new->log_declines = -1;
  @@ -93,10 +93,12 @@
       new->no_cache = -1;
       new->debug_level = -1;
       new->dependency_checks = -1;
  +    new->ignore_style_pi = -1;
  +    new->handle_dirs = -1;
       new->reset_processors = 0;
       new->reset_output_transformers = 0;
       new->reset_plugins = 0;
  -    
  +
       new->cache_dir = 0;
       new->config_reader_module = 0;
       new->provider_module = 0;
  @@ -105,7 +107,7 @@
       new->default_media = 0;
       new->cache_module = 0;
       new->output_charset = 0;
  -    
  +
       /* complex types */
       new->type_map = NULL;
       new->processors = NULL;
  @@ -116,7 +118,7 @@
       new->error_stylesheet = NULL;
       new->output_transformers = NULL;
       new->current_plugins = NULL;
  -    
  +
   /*
       warn("[AxKit] created new dir_config:\n"
           "location: %d\n"
  @@ -190,14 +192,14 @@
       
       new->xsp_taglibs = newHV();
       ap_register_cleanup(p, (void*)new->xsp_taglibs, ax_cleanup_hv, ap_null_cleanup);
  -    
  +
       new->output_transformers = newAV();
       ap_register_cleanup(p, (void*)new->output_transformers, ax_cleanup_av, ap_null_cleanup);
       
       new->current_styles = newAV();
       av_push(new->current_styles, newSVpv("#default", 0));
       ap_register_cleanup(p, (void*)new->current_styles, ax_cleanup_av, ap_null_cleanup);
  -    
  +
       new->current_medias = newAV();
       av_push(new->current_medias, newSVpv("screen", 0));
       ap_register_cleanup(p, (void*)new->current_medias, ax_cleanup_av, ap_null_cleanup);
  @@ -234,7 +236,7 @@
           }
           sub1 = (HV*)SvRV(*sub1p);
       }
  -    
  +
       key2 = SvPV(two, len);
       if (!hv_exists(sub1, key2, len)) {
           sub2 = newAV();
  @@ -372,7 +374,7 @@
       else if (parent_dir->cache_dir) {
           new->cache_dir = ap_pstrdup(p, parent_dir->cache_dir);
       }
  -    
  +
       if (subdir->config_reader_module) {
           new->config_reader_module = ap_pstrdup(p, subdir->config_reader_module);
       }
  @@ -400,14 +402,14 @@
       else if (parent_dir->default_style) {
           new->default_style = ap_pstrdup(p, parent_dir->default_style);
       }
  -    
  +
       if (subdir->default_media) {
           new->default_media = ap_pstrdup(p, subdir->default_media);
       }
       else if (parent_dir->default_media) {
           new->default_media = ap_pstrdup(p, parent_dir->default_media);
       }
  -    
  +
       if (subdir->cache_module) {
           new->cache_module = ap_pstrdup(p, subdir->cache_module);
       }
  @@ -445,11 +447,18 @@
       new->no_cache =
           subdir->no_cache != -1 ? subdir->no_cache :
                                        parent_dir->no_cache;
  -    
  +
       new->dependency_checks =
           subdir->dependency_checks != -1 ? subdir->dependency_checks :
                                        parent_dir->dependency_checks;
  -    
  +
  +    new->ignore_style_pi =
  +        subdir->ignore_style_pi != -1 ? subdir->ignore_style_pi :
  +                                    parent_dir->ignore_style_pi;
  +
  +    new->handle_dirs =
  +        subdir->handle_dirs != -1 ? subdir->handle_dirs :
  +                                    parent_dir->handle_dirs;
       
       /* complex types */
       
  @@ -470,7 +479,7 @@
               char *stylesheet;
               SV ** avitem;
               STRLEN len;
  -            
  +
               avitem = av_fetch(from, 0, 0);
               mime = ap_pstrdup(p, SvPV(*avitem, len));
               av_push(new->error_stylesheet, newSVpvn(mime, strlen(mime)));
  @@ -479,7 +488,7 @@
               stylesheet = ap_pstrdup(p, SvPV(*avitem, len));
               av_push(new->error_stylesheet, newSVpvn(stylesheet, strlen(stylesheet)));
           }
  -        
  +
           ap_register_cleanup(p, (void*)new->error_stylesheet, ax_cleanup_av, ap_null_cleanup);
       }
       
  @@ -540,7 +549,7 @@
           
           ap_register_cleanup(p, (void*)new->dynamic_processors, ax_cleanup_av, ap_null_cleanup);
       }
  -    
  +
       {
           /* cfg->xsp_taglibs */
           new->xsp_taglibs = newHV();
  @@ -645,7 +654,7 @@
                   SvREFCNT_dec(two);
               }
           }
  -        
  +
           ap_register_cleanup(p, (void*)new->processors, ax_cleanup_hv, ap_null_cleanup);
       }
       
  @@ -680,7 +689,7 @@
           
           ap_register_cleanup(p, (void*)new->output_transformers, ax_cleanup_av, ap_null_cleanup);
       }
  -    
  +
       {
           /* cfg->current_plugins */
           new->current_plugins = newAV();
  @@ -1016,30 +1025,40 @@
   {
       int retval;
       SV * handler_sv = newSVpv("AxKit::fast_handler", 0);
  -    
  +
       SV * cfg = perl_get_sv("AxKit::Cfg", FALSE);
       SV * cache = perl_get_sv("AxKit::Cache", FALSE);
       SV * hs = perl_get_sv("AxKit::HeadersSent", FALSE);
       SV * debuglevel = perl_get_sv("AxKit::DebugLevel", FALSE);
       SV * errorlevel = perl_get_sv("Error::Debug", FALSE);
  -    
  +
       ENTER;
  -    
  +
       save_item(cfg);
       save_item(cache);
       save_item(hs);
       save_item(debuglevel);
       save_item(errorlevel);
  -    
  +
       retval = perl_call_handler(handler_sv, (request_rec *)r, Nullav);
   
       LEAVE;
  -    
  +
       SvREFCNT_dec(handler_sv);
  -    
  +
       return retval;
   }
   
  +static int axkit_ok_handler(request_rec *r)
  +{
  +    return OK;
  +}
  +
  +static int axkit_declined_handler(request_rec *r)
  +{
  +    return DECLINED;
  +}
  +
   static command_rec axkit_mod_cmds[] = {
   
       { "AxAddProcessor", ax_add_processor,
  @@ -1055,7 +1074,7 @@
         "a mime type, a stylesheet, and a dtd filename" },
   
       { "AxAddDynamicProcessor", ax_add_dynamic_processor,
  -      NULL, OR_ALL, TAKE1, 
  +      NULL, OR_ALL, TAKE1,
         "a package name" },
   
       { "AxAddRootProcessor", ax_add_type_processor,
  @@ -1125,11 +1144,11 @@
         "a default media to use other than screen" },
   
       { "AxAddOutputTransformer", ax_add_output_transformer,
  -      NULL, OR_ALL, TAKE1, 
  +      NULL, OR_ALL, TAKE1,
         "An output transformer function, qualified with package name." },
   
       { "AxResetOutputTransformers", ax_reset_output_transformers,
  -      NULL, OR_ALL, NO_ARGS, 
  +      NULL, OR_ALL, NO_ARGS,
         "Reset list of output transformers." },
   
       { "AxCacheModule", ax_set_module_slot,
  @@ -1178,7 +1197,7 @@
       { "AxAddXSPTaglib", ax_add_xsp_taglib,
         NULL, OR_ALL, TAKE1,
         "module that provides a taglib functionality" },
  -    
  +
       { "AxDependencyChecks", ap_set_flag_slot,
         (void *)XtOffsetOf(axkit_dir_config, dependency_checks),
         OR_ALL, FLAG,
  @@ -1192,12 +1211,23 @@
           NULL, OR_ALL, NO_ARGS,
           "reset the list of plugins" },
   
  +    { "AxHandleDirs", ap_set_flag_slot,
  +      (void *)XtOffsetOf(axkit_dir_config, handle_dirs),
  +      OR_ALL, FLAG,
  +      "On or Off [default] to make AxKit process directory requests using XML::Directory" },
  +
  +    { "AxIgnoreStypePI", ap_set_flag_slot,
  +      (void *)XtOffsetOf(axkit_dir_config, ignore_style_pi),
  +      OR_ALL, FLAG,
  +      "On or Off [default] to disable xml-stylesheet PI processing" },
  +
       { NULL }
   };
   
   static const handler_rec axkit_handlers[] =
   {
       {"axkit", axkit_handler},
  +    { DIR_MAGIC_TYPE, axkit_handler },
       {NULL}
   };
   
  @@ -1227,7 +1257,7 @@
   ax_get_config (axkit_dir_config * cfg)
   {
       HV * retval;
  -    
  +
       retval = newHV();
       if (cfg->cache_dir) {
           hv_store(retval, "CacheDir", 
  @@ -1285,7 +1315,15 @@
           hv_store(retval, "NoCache",
                   7, (newSViv(cfg->no_cache)), 0);
       }
  -    
  +    if (cfg->ignore_style_pi != -1) {
  +        hv_store(retval, "IgnoreStylePI",
  +                13, (newSViv(cfg->ignore_style_pi)), 0);
  +    }
  +    if (cfg->handle_dirs != -1) {
  +        hv_store(retval, "HandleDirs",
  +                10, (newSViv(cfg->handle_dirs)), 0);
  +    }
  +
       if (cfg->dependency_checks != -1) {
           hv_store(retval, "DependencyChecks",
                   16, (newSViv(cfg->dependency_checks)), 0);
  @@ -1294,7 +1332,7 @@
           hv_store(retval, "DependencyChecks",
                   16, (newSViv(1)), 0);
       }
  -    
  +
       hv_store(retval, "OutputTransformers",
               18, newRV_inc((SV*)cfg->output_transformers), 0);
       hv_store(retval, "ErrorStylesheet",
  
  
  
  1.2       +6 -4      xml-axkit/axconfig.h
  
  Index: axconfig.h
  ===================================================================
  RCS file: /home/cvs/xml-axkit/axconfig.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- axconfig.h	13 Jan 2002 20:45:08 -0000	1.1
  +++ axconfig.h	2 Apr 2002 16:27:53 -0000	1.2
  @@ -1,4 +1,4 @@
  -/* $Id: axconfig.h,v 1.1 2002/01/13 20:45:08 matts Exp $ */
  +/* $Id: axconfig.h,v 1.2 2002/04/02 16:27:53 matts Exp $ */
   
   #ifdef WIN32
   #define _INC_DIRENT
  @@ -43,7 +43,7 @@
       char * output_charset;
       int    debug_level;
       int    translate_output;
  -    int    gzip_output; 
  +    int    gzip_output;
       int    reset_processors;
       int    log_declines;
       int    stack_trace;
  @@ -51,7 +51,9 @@
       int    dependency_checks;
       int    reset_output_transformers;
       int    reset_plugins;
  -    
  +    int    handle_dirs;
  +    int    ignore_style_pi;
  +
       /* complex types */
       HV *   type_map;            /* mime type => module mapping */
       HV *   processors;          /* processor map */
  @@ -62,7 +64,7 @@
       AV *   error_stylesheet;
       AV *   output_transformers;
       AV *   current_plugins;
  -    
  +
   } axkit_dir_config;
   
   extern module MODULE_VAR_EXPORT XS_AxKit;
  
  
  
  1.2       +173 -172  xml-axkit/demo/xsp/esql.xsp
  
  Index: esql.xsp
  ===================================================================
  RCS file: /home/cvs/xml-axkit/demo/xsp/esql.xsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- esql.xsp	14 Mar 2002 22:29:58 -0000	1.1
  +++ esql.xsp	2 Apr 2002 16:27:54 -0000	1.2
  @@ -1,174 +1,175 @@
  -<xsp:page 
  +<xsp:page
       xmlns:xsp="http://apache.org/xsp/core/v1"
       xmlns:esql="http://apache.org/xsp/SQL/v2"
  ->
  -
  -<xsp:import>File::Spec</xsp:import>
  -
  -<xsp:logic>my $dbname = File::Spec->catdir(File::Spec->tmpdir, "esqldemo.db");</xsp:logic>
  -
  -<html>
  -    <head>
  -        <title>ESQL Example</title>
  -        <link rel="stylesheet" url="/axkit/stylesheets/style.css"/>
  -    </head>
  -    
  -    <body>
  -    <h1>ESQL Example (<xsp:expr>$dbname</xsp:expr>)</h1>
  -    
  -    <!-- remove/recreate the db on every hit -->
  -    <xsp:logic>
  -      <esql:connection>
  -        <esql:driver transactions="yes">SQLite</esql:driver>
  -        <esql:dburl>dbname=<xsp:expr>$dbname</xsp:expr></esql:dburl>
  -        
  -        <xsp:logic>
  -        
  -        if ($cgi->param('reset')) {
  -          eval {
  -            <esql:execute-query>
  -                <esql:query>drop table example</esql:query>
  -                <esql:update-results/>
  -            </esql:execute-query>
  -          };
  -        }
  -
  -        <!-- Create Tables -->
  -        eval {
  -            <esql:execute-query>
  -                <esql:query>create table example ( id integer primary key, firstname, lastname, email )</esql:query>
  -                <esql:update-results>
  -                    <p>Table (re)created successfully.</p>
  -                </esql:update-results>
  -            </esql:execute-query>
  -        };
  -        
  -        if ($cgi->param('type') eq 'query') {
  -            <!-- Query Database -->
  -            <esql:execute-query>
  -                <esql:query>
  -                    select * from example
  -                    where firstname = <esql:parameter><xsp:expr>$cgi->param('firstname')</xsp:expr></esql:parameter>
  -                    and lastname = <esql:parameter><xsp:expr>$cgi->param('lastname')</xsp:expr></esql:parameter>
  -                    and email = <esql:parameter><xsp:expr>$cgi->param('email')</xsp:expr></esql:parameter>
  -                </esql:query>
  -                <esql:results>
  -                    <p>Results:
  -                    <table border="1">
  -                        <tr>
  -                            <th>First Name</th><th>Last Name</th><th>Email</th>
  -                        </tr>
  -                        <esql:row-results>
  -                        <tr>
  -                            <td><esql:get-column column="firstname"/></td>
  -                            <td><esql:get-column column="lastname"/></td>
  -                            <td><esql:get-column column="email"/></td>
  -                        </tr>
  -                        </esql:row-results>
  -                    </table>
  -                    </p>
  -                </esql:results>
  -                <esql:no-results>
  -                    <p>No results found for your query.</p>
  -                </esql:no-results>
  -            </esql:execute-query>
  -        }
  -        elsif ($cgi->param('type') eq 'show all') {
  -            <esql:execute-query>
  -                <esql:query>
  -                    select * from example
  -                </esql:query>
  -                <esql:results>
  -                    <p>Results:
  -                    <table border="1">
  -                        <tr>
  -                            <th>id</th><th>First Name</th><th>Last Name</th><th>Email</th>
  -                        </tr>
  -                        <esql:row-results>
  -                        <tr>
  -                            <td><esql:get-column column="id"/></td>
  -                            <td><esql:get-column column="firstname"/></td>
  -                            <td><esql:get-column column="lastname"/></td>
  -                            <td><esql:get-column column="email"/></td>
  -                        </tr>
  -                        </esql:row-results>
  -                    </table>
  -                    </p>
  -                </esql:results>
  -                <esql:no-results>
  -                    <p>No results found for your query.</p>
  -                </esql:no-results>
  -            </esql:execute-query>
  -        }
  -        elsif ($cgi->param('type') eq 'insert') {
  -            <!-- Insert new row -->
  -            <esql:execute-query>
  -                <esql:query>
  -                    insert into example (firstname, lastname, email) values (
  -                        <esql:parameter><xsp:expr>$cgi->param('firstname')</xsp:expr></esql:parameter>,
  -                        <esql:parameter><xsp:expr>$cgi->param('lastname')</xsp:expr></esql:parameter>,
  -                        <esql:parameter><xsp:expr>$cgi->param('email')</xsp:expr></esql:parameter>
  -                        )
  -                </esql:query>
  -                <esql:update-results>
  -                    <p>Row inserted successfully.</p>
  -                </esql:update-results>
  -            </esql:execute-query>
  -        }
  -            
  -        <p>
  -        <!-- Show Form -->
  -        <form method="GET">
  -            <table>
  -            <tr>
  -                <td>First name:</td>
  -                <td><input type="text" name="firstname">
  -                    <xsp:attribute name="VALUE">
  -                        <xsp:expr>$cgi->param('firstname')</xsp:expr>
  -                    </xsp:attribute>
  -                    </input>
  -                </td>
  -            </tr>
  -            <tr>
  -                <td>Last name:</td>
  -                <td><input type="text" name="lastname">
  -                    <xsp:attribute name="value">
  -                        <xsp:expr>$cgi->param('lastname')</xsp:expr>
  -                    </xsp:attribute>
  -                    </input>
  -                </td>
  -            </tr>
  -            <tr>
  -                <td>Email:</td>
  -                <td><input type="text" name="email">
  -                    <xsp:attribute name="value">
  -                        <xsp:expr>$cgi->param('email')</xsp:expr>
  -                    </xsp:attribute>
  -                    </input>
  -                </td>
  -            </tr>
  -            <tr>
  -                <td></td>
  -                <td>
  -                    <input type="submit" name="type" value="query"/>
  -                    <input type="submit" name="type" value="insert"/>
  -                    <input type="submit" name="type" value="show all"/>
  -                </td>
  -            </tr>
  -        </table>
  -        </form>
  -        </p>
  -        
  -        </xsp:logic>
  -    
  -      </esql:connection>
  -    </xsp:logic>
  -    
  -    <p><a href="esql.xsp?reset=1">Reset Database</a></p>
  -    
  -    <p><a href="showsource.xsp?esql.xsp">View Source</a></p>
  -    
  -    </body>
  -</html>
  -
  -</xsp:page>
  +>
  +
  +<xsp:import>File::Spec</xsp:import>
  +
  +<xsp:logic>my $dbname = File::Spec->catdir(File::Spec->tmpdir, "esqldemo.db");</xsp:logic>
  +
  +<html>
  +    <head>
  +        <title>ESQL Example</title>
  +        <link rel="stylesheet" url="/axkit/stylesheets/style.css"/>
  +    </head>
  +
  +    <body>
  +    <h1>ESQL Example (<xsp:expr>$dbname</xsp:expr>)</h1>
  +
  +    <!-- remove/recreate the db on every hit -->
  +    <xsp:logic>
  +      <esql:connection>
  +        <esql:driver transactions="yes">SQLite</esql:driver>
  +        <esql:dburl>dbname=<xsp:expr>$dbname</xsp:expr></esql:dburl>
  +
  +        <xsp:logic>
  +
  +        if ($cgi->param('reset')) {
  +          eval {
  +            <esql:execute-query>
  +                <esql:query>drop table example</esql:query>
  +                <esql:update-results/>
  +            </esql:execute-query>
  +          };
  +        }
  +
  +        <!-- Create Tables -->
  +        eval {
  +            <esql:execute-query>
  +                <esql:query>create table example ( id integer primary key, firstname, lastname, email )</esql:query>
  +                <esql:update-results>
  +                    <p>Table (re)created successfully.</p>
  +                </esql:update-results>
  +            </esql:execute-query>
  +        };
  +
  +        if ($cgi->param('type') eq 'insert') {
  +            AxKit::Debug(1, "**** Inserting *****");
  +            <!-- Insert new row -->
  +            <esql:execute-query>
  +                <esql:query>
  +                    insert into example (firstname, lastname, email) values (
  +                        <esql:parameter><xsp:expr>$cgi->param('firstname')</xsp:expr></esql:parameter>,
  +                        <esql:parameter><xsp:expr>$cgi->param('lastname')</xsp:expr></esql:parameter>,
  +                        <esql:parameter><xsp:expr>$cgi->param('email')</xsp:expr></esql:parameter>
  +                        )
  +                </esql:query>
  +                <esql:update-results>
  +                    <p>Row inserted successfully.</p>
  +                </esql:update-results>
  +            </esql:execute-query>
  +        }
  +        elsif ($cgi->param('type') eq 'query') {
  +            <!-- Query Database -->
  +            <esql:execute-query>
  +                <esql:query>
  +                    select * from example
  +                    where firstname = <esql:parameter><xsp:expr>$cgi->param('firstname')</xsp:expr></esql:parameter>
  +                    and lastname = <esql:parameter><xsp:expr>$cgi->param('lastname')</xsp:expr></esql:parameter>
  +                    and email = <esql:parameter><xsp:expr>$cgi->param('email')</xsp:expr></esql:parameter>
  +                </esql:query>
  +                <esql:results>
  +                    <p>Results:
  +                    <table border="1">
  +                        <tr>
  +                            <th>First Name</th><th>Last Name</th><th>Email</th>
  +                        </tr>
  +                        <esql:row-results>
  +                        <tr>
  +                            <td><esql:get-column column="firstname"/></td>
  +                            <td><esql:get-column column="lastname"/></td>
  +                            <td><esql:get-column column="email"/></td>
  +                        </tr>
  +                        </esql:row-results>
  +                    </table>
  +                    </p>
  +                </esql:results>
  +                <esql:no-results>
  +                    <p>No results found for your query.</p>
  +                </esql:no-results>
  +            </esql:execute-query>
  +        }
  +        elsif ($cgi->param('type') eq 'show all') {
  +            <esql:execute-query>
  +                <esql:query>
  +                    select * from example
  +                </esql:query>
  +                <esql:results>
  +                    <p>Results:
  +                    <table border="1">
  +                        <tr>
  +                            <th>id</th><th>First Name</th><th>Last Name</th><th>Email</th>
  +                        </tr>
  +                        <esql:row-results>
  +                        <tr>
  +                            <td><esql:get-column column="id"/></td>
  +                            <td><esql:get-column column="firstname"/></td>
  +                            <td><esql:get-column column="lastname"/></td>
  +                            <td><esql:get-column column="email"/></td>
  +                        </tr>
  +                        </esql:row-results>
  +                    </table>
  +                    </p>
  +                </esql:results>
  +                <esql:no-results>
  +                    <p>No results found for your query.</p>
  +                </esql:no-results>
  +            </esql:execute-query>
  +        }
  +
  +        <p>
  +        <!-- Show Form -->
  +        <form method="GET">
  +            <table>
  +            <tr>
  +                <td>First name:</td>
  +                <td><input type="text" name="firstname">
  +                    <xsp:attribute name="VALUE">
  +                        <xsp:expr>$cgi->param('firstname')</xsp:expr>
  +                    </xsp:attribute>
  +                    </input>
  +                </td>
  +            </tr>
  +            <tr>
  +                <td>Last name:</td>
  +                <td><input type="text" name="lastname">
  +                    <xsp:attribute name="value">
  +                        <xsp:expr>$cgi->param('lastname')</xsp:expr>
  +                    </xsp:attribute>
  +                    </input>
  +                </td>
  +            </tr>
  +            <tr>
  +                <td>Email:</td>
  +                <td><input type="text" name="email">
  +                    <xsp:attribute name="value">
  +                        <xsp:expr>$cgi->param('email')</xsp:expr>
  +                    </xsp:attribute>
  +                    </input>
  +                </td>
  +            </tr>
  +            <tr>
  +                <td></td>
  +                <td>
  +                    <input type="submit" name="type" value="query"/>
  +                    <input type="submit" name="type" value="insert"/>
  +                    <input type="submit" name="type" value="show all"/>
  +                </td>
  +            </tr>
  +        </table>
  +        </form>
  +        </p>
  +
  +        </xsp:logic>
  +
  +      </esql:connection>
  +    </xsp:logic>
  +
  +    <p><a href="esql.xsp?reset=1">Reset Database</a></p>
  +
  +    <p><a href="showsource.xsp?esql.xsp">View Source</a></p>
  +
  +    </body>
  +</html>
  +
  +</xsp:page>
  
  
  
  1.6       +41 -23    xml-axkit/lib/AxKit.pm
  
  Index: AxKit.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/AxKit.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AxKit.pm	21 Mar 2002 23:26:47 -0000	1.5
  +++ AxKit.pm	2 Apr 2002 16:27:54 -0000	1.6
  @@ -1,4 +1,4 @@
  -# $Id: AxKit.pm,v 1.5 2002/03/21 23:26:47 matts Exp $
  +# $Id: AxKit.pm,v 1.6 2002/04/02 16:27:54 matts Exp $
   
   package AxKit;
   use strict;
  @@ -91,7 +91,7 @@
               return map { $map->convert( $_ ) } ($outputfunc->(@_));
           };
       }
  -    
  +
       foreach my $AxOutputTransformer ( $AxKit::Cfg->OutputTransformers() ) {
           $actually_transform = 1;
           my $outputfunc = $func;
  @@ -135,9 +135,9 @@
   
   sub fast_handler {
       my $r = shift;
  -    
  +
       local $SIG{__DIE__} = sub { AxKit::prep_exception(@_)->throw };
  -    
  +
       $AxKit::Cfg = Apache::AxKit::ConfigReader->new($r);
   
   #    if ($AxKit::Cfg->DebugTime) {
  @@ -180,7 +180,7 @@
   #     ##############################
   
       local $SIG{__DIE__} = sub { AxKit::prep_exception(@_)->throw };
  -    
  +
       local $AxKit::Cfg;
       local $AxKit::Cache;
       local $AxKit::HeadersSent;
  @@ -210,36 +210,37 @@
       return $provider->decline(reason => "passthru set")
               if $r->notes('axkit_passthru');
   
  +    return main_handler($r, $provider);
  +}
  +
  +sub main_handler {
  +    my ($r, $provider) = @_;
  +
       # Do we process this URL?
  +    # (moved down here from slow_handler because of AxHandleDirs)
       AxKit::Debug(2, "checking if we process this resource");
       if (!$provider->process()) {
           return $provider->decline();
       }
  -    
  -    return main_handler($r, $provider);
  -}
   
  -sub main_handler {
  -    my ($r, $provider) = @_;
  -    
       my $retcode = eval {
           # $r->header_out('X-AxKit-Version', $VERSION);
  -        
  +
           chdir(File::Basename::dirname($r->filename));
  -        
  +
           $AxKit::OrigType = $r->content_type('changeme');
  -        
  +
           # get preferred stylesheet and media type
           my ($preferred, $media) = get_style_and_media();
           AxKit::Debug(2, "media: $media, preferred style: $preferred");
  -        
  +
           # get cache object
           my $cache = Apache::AxKit::Cache->new($r, $r->filename() . '.gzip' . ($ENV{PATH_INFO} || ''), $preferred, $media, $r->notes('axkit_cache_extra'));
  -        
  +
           my $recreate; # regenerate from source (not cached)
  -        
  +
           my $styles = get_styles($media, $preferred, $cache, $provider);
  -        
  +
           {
               local $^W;
               if ($preferred && ($styles->[0]{title} ne $preferred)) {
  @@ -250,14 +251,14 @@
                   $cache = Apache::AxKit::Cache->new($r, $r->filename() . '.gzip' . $ENV{PATH_INFO}, '', $media, $r->notes('axkit_cache_extra'));
               }
           }
  -        
  +
           if (!$cache->exists()) {
               AxKit::Debug(2, "cache doesn't exist");
               # set no_cache header if cache doesn't exist due to no_cache option
               $r->no_cache(1) if $cache->no_cache();
               $recreate++;
           }
  -        
  +
           if (!$recreate && $AxKit::Cfg->DependencyChecks()) {
               $recreate = check_dependencies($r, $provider, $cache);
           }
  @@ -817,7 +818,7 @@
           $self->pnotes('xml_string', '');
           $self->notes('resetstring', 0);
       }
  -    
  +
       my $current = $self->pnotes('xml_string');
       $self->pnotes('xml_string', $current . join('', @_));
   }
  @@ -1098,6 +1099,21 @@
   server startup (assuming that the config directive is in a httpd.conf,
   rather than a .htaccess file).
   
  +=head2 AxIgnoreStylePI
  +
  +Turn off parsing and overriding stylesheet selection for XML files containing
  +an C<xml-stylesheet> processing instruction at the start of the file. This is
  +a FLAG option - On or Off. The default value is "Off".
  +
  +  AxIgnoreStylePI On
  +
  +=head2 AxHandleDirs
  +
  +Enable this option to allow AxKit to process directories. Uses XML::Directory
  +and XML::SAX::Writer to create the directory listing.
  +
  +  AxHandleDirs On
  +
   =head2 AxStyle
   
   A default stylesheet title to use. This is useful when a single XML
  @@ -1145,8 +1161,10 @@
   
   There are several directives specifically designed to allow you to build
   a flexible sitemap that specifies how XML files get processed on your
  -system. These directives are used only if your XML file does not have the
  -<?xml-stylesheet?> directives.
  +system.
  +
  +B<Note:> <?xml-stylesheet?> directives in your XML files override these
  +directives unless you enable the AxIgnoreStylePI option listed above.
   
   =head2 AxAddProcessor
   
  
  
  
  1.2       +15 -1     xml-axkit/lib/Apache/AxKit/ConfigReader.pm
  
  Index: ConfigReader.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/ConfigReader.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigReader.pm	13 Jan 2002 20:45:11 -0000	1.1
  +++ ConfigReader.pm	2 Apr 2002 16:27:54 -0000	1.2
  @@ -1,4 +1,4 @@
  -# $Id: ConfigReader.pm,v 1.1 2002/01/13 20:45:11 matts Exp $
  +# $Id: ConfigReader.pm,v 1.2 2002/04/02 16:27:54 matts Exp $
   
   package Apache::AxKit::ConfigReader;
   
  @@ -143,6 +143,20 @@
       my $self = shift;
       return $self->{cfg}{LogDeclines} ||
               $self->{apache}->dir_config('AxLogDeclines') ||
  +            0;
  +}
  +
  +sub HandleDirs {
  +    my $self = shift;
  +    return $self->{cfg}{HandleDirs} ||
  +            $self->{apache}->dir_config('AxHandleDirs') ||
  +            0;
  +}
  +
  +sub IgnoreStylePI {
  +    my $self = shift;
  +    return $self->{cfg}{IgnoreStylePI} ||
  +            $self->{apache}->dir_config('AxIgnoreStylePI') ||
               0;
   }
   
  
  
  
  1.2       +2 -6      xml-axkit/lib/Apache/AxKit/Exception.pm
  
  Index: Exception.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Exception.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Exception.pm	13 Jan 2002 20:45:11 -0000	1.1
  +++ Exception.pm	2 Apr 2002 16:27:54 -0000	1.2
  @@ -1,7 +1,7 @@
  -# $Id: Exception.pm,v 1.1 2002/01/13 20:45:11 matts Exp $
  +# $Id: Exception.pm,v 1.2 2002/04/02 16:27:54 matts Exp $
   
   package Apache::AxKit::Exception;
  -use Error;
  +use Error 0.14;
   @ISA = ('Error');
   
   sub new {
  @@ -53,9 +53,5 @@
   
   package Apache::AxKit::Exception::IO;
   @ISA = ('Apache::AxKit::Exception');
  -
  -# a hack to fix broken Error.pm 0.13 (fixed in 0.14)
  -package Error;
  -use overload bool => sub { 1 };
   
   1;
  
  
  
  1.4       +22 -20    xml-axkit/lib/Apache/AxKit/Provider.pm
  
  Index: Provider.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Provider.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Provider.pm	15 Mar 2002 13:35:04 -0000	1.3
  +++ Provider.pm	2 Apr 2002 16:27:54 -0000	1.4
  @@ -1,4 +1,4 @@
  -# $Id: Provider.pm,v 1.3 2002/03/15 13:35:04 matts Exp $
  +# $Id: Provider.pm,v 1.4 2002/04/02 16:27:54 matts Exp $
   
   package Apache::AxKit::Provider;
   use strict;
  @@ -21,7 +21,7 @@
       $self->init(@_);
       
       AxKit::add_depends($self->key());
  -    
  +
       return $self;
   }
   
  @@ -46,7 +46,7 @@
   
   sub decline {
       my $self = shift;
  -    
  +
       AxKit::Debug(4, "provider declined");
       return DECLINED;
   }
  @@ -78,7 +78,7 @@
               }
               die "Cannot download https (SSL) or ftp URL's yet. Patches welcome";
           }
  -        
  +
   #        warn "File provider ext_ent_handler called with '$sysid'\n";
           my $provider = Apache::AxKit::Provider->new(
                   AxKit::Apache->request,
  @@ -95,46 +95,48 @@
   sub get_styles {
       my $self = shift;
       my ($media, $pref_style) = @_;
  -    
  +
       if ($pref_style eq '#default') {
           undef $pref_style;
       }
  -    
  +
       my $xml_styles = [];
       my $vals = [];
  -    
  +
       my $key = $self->key();
  -    
  +
       # need to extract the following from the XML file:
       #   DocType Public Identifier
       #   DTD filename
       #   Root element name (including namespace)
       # use three element array @$vals
  -    
  +
       if (defined &Apache::AxKit::Provider::xs_get_styles_fh) {
           AxKit::Debug(2, "using XS get_styles (libxml2)");
  -        my ($xs_styles, $doctype, $dtd, $root) = 
  +        my ($xs_styles, $doctype, $dtd, $root) =
                   $self->xs_get_styles($media, $pref_style);
  -        @$xml_styles = @$xs_styles;
  +        @$xml_styles = @$xs_styles unless $AxKit::Cfg->IgnoreStylePI();
           @$vals = ($doctype, $dtd, $root);
       }
       else {
           require XML::Parser;
  -        
  +
           AxKit::Debug(4, "get_styles: creating XML::Parser");
  -        
  +
  +        my $handlers = {
  +                    Start => \&parse_start,
  +                    Doctype => \&parse_dtd,
  +                    $AxKit::Cfg->IgnoreStylePI() ? () : (Proc => \&parse_pi),
  +                    };
  +
           my $xml_parser = XML::Parser->new(
                   Namespaces => 1,
                   ErrorContext => 2,
  -                Handlers => {
  -                    Start => \&parse_start,
  -                    Doctype => \&parse_dtd,
  -                    Proc => \&parse_pi,
  -                },
  +                Handlers => $handlers,
               );
  -    
  +
           my $to_parse;
  -        eval { 
  +        eval {
               $to_parse = $self->get_fh();
           };
           if ($@) {
  
  
  
  1.3       +35 -14    xml-axkit/lib/Apache/AxKit/Provider/File.pm
  
  Index: File.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Provider/File.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- File.pm	17 Mar 2002 11:13:22 -0000	1.2
  +++ File.pm	2 Apr 2002 16:27:54 -0000	1.3
  @@ -1,4 +1,4 @@
  -# $Id: File.pm,v 1.2 2002/03/17 11:13:22 matts Exp $
  +# $Id: File.pm,v 1.3 2002/04/02 16:27:54 matts Exp $
   
   package Apache::AxKit::Provider::File;
   use strict;
  @@ -17,29 +17,29 @@
   sub init {
       my $self = shift;
       my (%p) = @_;
  -    
  +
       my $stats_done;
       if ($p{key}) {
           $self->{file} = $p{key};
       }
       else {
  -        
  +
           if ($p{uri} and $p{uri} =~ s|^file:(//)?||) {
               $p{file} = delete $p{uri};
           }
  -        
  +
           if ($p{uri}) {
               my $r = $p{rel} ? $p{rel}->apache_request() : $self->apache_request();
  -            
  +
               AxKit::Debug(8, "[uri] File Provider looking up" . ($p{rel} ? " relative" : "") . " uri $p{uri}");
  -    
  +
               $self->{apache} = $r->lookup_uri($p{uri});
               my $status = $self->{apache}->status();
               if ($status != HTTP_OK) {
                   throw Apache::AxKit::Exception::Error(-text => "Subrequest failed with status: " . $status);
               }
               $self->{file} = $self->{apache}->filename();
  -            
  +
               AxKit::Debug(8, "[uri] File Provider set filename to $self->{file}");
           }
           elsif ($p{file}) {
  @@ -73,7 +73,7 @@
               $stats_done++;
           }
       }
  -    
  +
       if (!$stats_done) {
           my @stats = stat($self->{file});
           $self->{mtime} = $stats[9];
  @@ -121,19 +121,23 @@
   
   sub process {
       my $self = shift;
  -    
  +
       my $xmlfile = $self->{file};
  -    
  +
       unless ($self->exists()) {
           AxKit::Debug(5, "file '$xmlfile' does not exist or is not readable");
           return 0;
       }
  -    
  -    if ($self->_is_dir) {
  +
  +    if ( $self->_is_dir ) {
  +        if ($AxKit::Cfg->HandleDirs()) {
  +            return 1;
  +        }
  +        # else
           AxKit::Debug(5, "'$xmlfile' is a directory");
           return 0;
       }
  -    
  +
       local $^W;
       if (($xmlfile =~ /\.xml$/i) ||
           ($self->{apache}->content_type() =~ /^(text|application)\/xml/) ||
  @@ -142,7 +146,7 @@
               # chdir(dirname($xmlfile));
               return 1;
       }
  -    
  +
       AxKit::Debug(5, "'$xmlfile' not recognised as XML");
       return 0;
   }
  @@ -158,6 +162,9 @@
       if (!$self->exists()) {
           throw Apache::AxKit::Exception::IO(-text => "File '$self->{file}' does not exist or is not readable");
       }
  +    if ($self->_is_dir()) {
  +        throw Apache::AxKit::Exception::IO(-text => "$self->{file} is a directory");
  +    }
       my $filename = $self->{file};
       # chdir(dirname($filename));
       my $fh = Apache->gensym();
  @@ -170,6 +177,20 @@
   
   sub get_strref {
       my $self = shift;
  +    if ($self->_is_dir() && $AxKit::Cfg->HandleDirs()) {
  +        require XML::Directory::SAX;
  +        require XML::SAX::Writer;
  +
  +        my $str = '';
  +        XML::Directory::SAX->new(
  +            Handler => XML::SAX::Writer->new(
  +                Output => \$str
  +            )
  +        )->parse_dir($self->{file});
  +
  +        AxKit::Debug(4, "Directory listing: $str");
  +        return \$str;
  +    }
       my $fh = $self->get_fh();
       local $/;
       my $contents = <$fh>;