Hi Dahuts and AxKittens.

I sent a message a while back about my AxXMLCatalog patch, but just in case 
you may not remember it or have it in your mail box, I'm attaching it here 
again.

I'd like to apply this to CVS soon, so if anyone has any comments, please let 
me know.

Essentially, this patch intends to add the "AxXMLCatalog" Apache directive 
which defines which XML catalogs to include into XML::LibXML.

-- 
Michael A. Nachbaur <[EMAIL PROTECTED]>
http://nachbaur.com/pgpkey.asc


diff -Nurw --exclude=CVS xml-axkit.dirhandler/axconfig.c xml-axkit.catalog/axconfig.c
--- xml-axkit.dirhandler/axconfig.c	2004-05-12 17:29:03.513940384 -0700
+++ xml-axkit.catalog/axconfig.c	2004-04-25 00:47:03.000000000 -0700
@@ -115,6 +115,7 @@
     new->type_map = NULL;
     new->processors = NULL;
     new->xsp_taglibs = NULL;
+    new->xml_catalogs = NULL;
     new->current_styles = NULL;
     new->current_medias = NULL;
     new->error_stylesheet = NULL;
@@ -141,6 +142,7 @@
         "new.type_map: %d\n"
         "new.processors: %d\n"
         "new.xsp_taglibs: %d\n"
+        "new.xml_catalogs: %d\n"
         "new.current_styles: %d\n"
         "new.current_medias: %d\n"
         "new.error_stylesheet: %d\n"
@@ -164,6 +166,7 @@
         new->type_map,
         new->processors,
         new->xsp_taglibs,
+        new->xml_catalogs,
         new->current_styles,
         new->current_medias,
         new->error_stylesheet,
@@ -192,6 +195,9 @@
     new->xsp_taglibs = newHV();
     ap_register_cleanup(p, (void*)new->xsp_taglibs, ax_cleanup_hv, ap_null_cleanup);
 
+    new->xml_catalogs = newHV();
+    ap_register_cleanup(p, (void*)new->xml_catalogs, ax_cleanup_hv, ap_null_cleanup);
+
     new->output_transformers = newAV();
     ap_register_cleanup(p, (void*)new->output_transformers, ax_cleanup_av, ap_null_cleanup);
     
@@ -288,6 +294,7 @@
         "parent_dir.type_map: %d\n"
         "parent_dir.processors: %d\n"
         "parent_dir.xsp_taglibs: %d\n"
+        "parent_dir.xml_catalogs: %d\n"
         "parent_dir.current_styles: %d\n"
         "parent_dir.current_medias: %d\n"
         "parent_dir.error_stylesheet: %d\n"
@@ -311,6 +318,7 @@
         parent_dir->type_map,
         parent_dir->processors,
         parent_dir->xsp_taglibs,
+        parent_dir->xml_catalogs,
         parent_dir->current_styles,
         parent_dir->current_medias,
         parent_dir->error_stylesheet,
@@ -336,6 +344,7 @@
         "subdir.type_map: %d\n"
         "subdir.processors: %d\n"
         "subdir.xsp_taglibs: %d\n"
+        "subdir.xml_catalogs: %d\n"
         "subdir.current_styles: %d\n"
         "subdir.current_medias: %d\n"
         "subdir.error_stylesheet: %d\n"
@@ -359,6 +368,7 @@
         subdir->type_map,
         subdir->processors,
         subdir->xsp_taglibs,
+        subdir->xml_catalogs,
         subdir->current_styles,
         subdir->current_medias,
         subdir->error_stylesheet,
@@ -562,6 +572,31 @@
     }
 
     {
+        /* cfg->xml_catalogs */
+        new->xml_catalogs = newHV();
+        if (HvKEYS(parent_dir->xml_catalogs)) {
+            SV * val;
+            char * key;
+            I32 len;
+            hv_iterinit(parent_dir->xml_catalogs);
+            while (val = hv_iternextsv(parent_dir->xml_catalogs, &key, &len)) {
+                hv_store(new->xml_catalogs, key, len, newSViv(1), 0);
+            }
+        }
+        if (HvKEYS(subdir->xml_catalogs)) {
+            SV * val;
+            char * key;
+            I32 len;
+            hv_iterinit(subdir->xml_catalogs);
+            while (val = hv_iternextsv(subdir->xml_catalogs, &key, &len)) {
+                hv_store(new->xml_catalogs, key, len, newSViv(1), 0);
+            }
+        }
+
+        ap_register_cleanup(p, (void*)new->xml_catalogs, ax_cleanup_hv, ap_null_cleanup);
+    }
+
+    {
         /* cfg->processors */
         SV * val;
         I32 len;
@@ -721,6 +756,7 @@
         "typemap: %d\n"
         "processors: %d\n"
         "taglibs: %d\n"
+        "catalogs: %d\n"
         "c_styles: %d\n"
         "c_medias: %d\n"
         "out_trans: %d\n"
@@ -729,6 +765,7 @@
         new->type_map,
         new->processors,
         new->xsp_taglibs,
+        new->xml_catalogs,
         new->current_styles,
         new->current_medias,
         new->output_transformers
@@ -940,6 +977,20 @@
 }
 
 CHAR_P
+ax_add_xml_catalog (cmd_parms *cmd, axkit_dir_config *ax, char *module)
+{
+    STRLEN len;
+
+    ax_preload_module(&module);
+
+    len = strlen(module);
+
+    hv_store(ax->xml_catalogs, module, len, newSViv(1), 0);
+
+    return NULL;
+}
+
+CHAR_P
 ax_add_output_transformer (cmd_parms *cmd, axkit_dir_config *ax, char *module)
 {
     SV * mod_sv = newSVpv(module, 0);
@@ -1330,6 +1381,10 @@
       NULL, OR_ALL, TAKE1,
       "module that provides a taglib functionality" },
 
+    { "AxAddXMLCatalog", ax_add_xml_catalog,
+      NULL, OR_ALL, TAKE1,
+      "XML catalog to add" },
+
     { "AxDependencyChecks", ap_set_flag_slot,
       (void *)XtOffsetOf(axkit_dir_config, dependency_checks),
       OR_ALL, FLAG,
@@ -1497,6 +1552,8 @@
             10, newRV_inc((SV*)cfg->processors), 0);
     hv_store(retval, "XSPTaglibs",
             10, newRV_inc((SV*)cfg->xsp_taglibs), 0);
+    hv_store(retval, "XMLCatalogs",
+            11, newRV_inc((SV*)cfg->xml_catalogs), 0);
     hv_store(retval, "Plugins",
             7, newRV_inc((SV*)cfg->current_plugins), 0);
 
diff -Nurw --exclude=CVS xml-axkit.dirhandler/axconfig.h xml-axkit.catalog/axconfig.h
--- xml-axkit.dirhandler/axconfig.h	2004-05-12 17:29:03.513940384 -0700
+++ xml-axkit.catalog/axconfig.h	2004-04-24 19:32:18.000000000 -0700
@@ -63,6 +63,7 @@
     HV *   processors;          /* processor map */
     AV *   dynamic_processors;  /* dynamic processor map */
     HV *   xsp_taglibs;
+    HV *   xml_catalogs;
     AV *   current_styles;
     AV *   current_medias;
     AV *   error_stylesheet;
diff -Nurw --exclude=CVS xml-axkit.dirhandler/lib/Apache/AxKit/ConfigReader.pm xml-axkit.catalog/lib/Apache/AxKit/ConfigReader.pm
--- xml-axkit.dirhandler/lib/Apache/AxKit/ConfigReader.pm	2004-05-12 17:29:03.514940232 -0700
+++ xml-axkit.catalog/lib/Apache/AxKit/ConfigReader.pm	2004-04-25 00:38:58.000000000 -0700
@@ -480,6 +480,25 @@
     return @others;
 }
 
+sub XMLCatalogs {
+    my $self = shift;
+    
+    my @others;
+    
+    print STDERR "XML Catalog: ", join(", ", %{ $self->{cfg}{XMLCatalogs} } ), "\n";
+    @others = eval { keys %{ $self->{cfg}{XMLCatalogs} } };
+    warn $@ if $@;
+    
+    if (@others) {
+        return @others;
+    }
+    
+    local $^W;
+    @others = split(/\s+/, $self->{apache}->dir_config('AxAddXMLCatalogs'));
+    
+    return @others;
+}
+
 sub OutputTransformers {
     my $self = shift;
 
diff -Nurw --exclude=CVS xml-axkit.dirhandler/lib/Apache/AxKit/Language/LibXSLT.pm xml-axkit.catalog/lib/Apache/AxKit/Language/LibXSLT.pm
--- xml-axkit.dirhandler/lib/Apache/AxKit/Language/LibXSLT.pm	2003-07-31 09:48:15.000000000 -0700
+++ xml-axkit.catalog/lib/Apache/AxKit/Language/LibXSLT.pm	2004-04-25 00:24:33.000000000 -0700
@@ -49,6 +49,11 @@
     
     my $parser = XML::LibXML->new();
     $parser->expand_entities(1);
+    AxKit::Debug(3,"Loading XML Catalogs");
+    foreach my $catalog ($AxKit::Cfg->XMLCatalogs) {
+        AxKit::Debug(3,"Loading XML Catalog $catalog");
+        $parser->load_catalog($catalog);
+    }
     local($XML::LibXML::match_cb, $XML::LibXML::open_cb,
           $XML::LibXML::read_cb, $XML::LibXML::close_cb);
     Apache::AxKit::LibXMLSupport->reset();
diff -Nurw --exclude=CVS xml-axkit.dirhandler/lib/Apache/AxKit/Provider.pm xml-axkit.catalog/lib/Apache/AxKit/Provider.pm
--- xml-axkit.dirhandler/lib/Apache/AxKit/Provider.pm	2004-01-31 11:28:32.000000000 -0800
+++ xml-axkit.catalog/lib/Apache/AxKit/Provider.pm	2004-04-24 19:44:36.000000000 -0700
@@ -140,6 +140,11 @@
     my $parser = XML::LibXML->new();
     $parser->expand_entities(1);
     $parser->expand_xinclude(1);
+    AxKit::Debug(3,"Loading XML Catalogs");
+    foreach my $catalog ($AxKit::Cfg->XMLCatalogs) {
+        AxKit::Debug(3,"Loading XML Catalog $catalog");
+        $parser->load_catalog($catalog);
+    }
     local($XML::LibXML::match_cb, $XML::LibXML::open_cb,
           $XML::LibXML::read_cb, $XML::LibXML::close_cb);
     Apache::AxKit::LibXMLSupport->reset($parser);
diff -Nurw --exclude=CVS xml-axkit.dirhandler/lib/AxKit.pm xml-axkit.catalog/lib/AxKit.pm
--- xml-axkit.dirhandler/lib/AxKit.pm	2003-09-18 15:12:33.000000000 -0700
+++ xml-axkit.catalog/lib/AxKit.pm	2004-05-12 17:41:49.115551248 -0700
@@ -1452,6 +1452,16 @@
 server startup (assuming that the config directive is in a httpd.conf,
 rather than a .htaccess file).
 
+=head2 AxXMLCatalog
+
+Use this directive to add additional XML catalogs to the XML transformation
+engine.  XML Catalogs provide an interoperable way to map information about
+an XML resource to a URI reference.  This enables you to, among other things,
+define custom URIs representing files or sections of your site, making
+references to such resources more portable.
+
+    AxXMLCatalog /catalog.xml
+
 =head2 AxIgnoreStylePI
 
 Turn off parsing and overriding stylesheet selection for XML files containing

Reply via email to