PLEASE DO NOT REPLY TO THIS MESSAGE. TO FURTHER COMMENT
ON THE STATUS OF THIS BUG PLEASE FOLLOW THE LINK BELOW
AND USE THE ON-LINE APPLICATION. REPLYING TO THIS MESSAGE
DOES NOT UPDATE THE DATABASE, AND SO YOUR COMMENT WILL
BE LOST SOMEWHERE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3261

*** shadow/3261 Fri Aug 24 09:37:54 2001
--- shadow/3261.tmp.21366       Fri Aug 24 09:37:54 2001
***************
*** 0 ****
--- 1,170 ----
+ +============================================================================+
+ | "Could not determine base pathname of the file" when using Xalan 1.2 with  |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 3261                        Product: XalanC                  |
+ |       Status: NEW                         Version: 1.2.x                   |
+ |   Resolution:                            Platform: PC                      |
+ |     Severity: Normal                   OS/Version: Linux                   |
+ |     Priority: Other                     Component: XalanC                  |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: [EMAIL PROTECTED]                                     |
+ |  Reported By: [EMAIL PROTECTED]                                          |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ Used packages:
+ Mandrake Linux 8.0
+ Apache 1.3.20
+ Xalan C 1.2
+ Xerces C 1.5.1
+ ICU 1.8.1
+ Problem: when using XalanTransformToHandler C API function with NULL xsl sheet
+ parameter, "Could not determine base pathname of the file" error occurs. Here is
+ the source code of the apache module mod_polarxslt.c (all other components are
+ standard). The only change in Makefile you'll need to compile the module is to
+ indicate -lxalan-c1_2 library and a path to xalan includes.
+ -----------
+ #include "httpd.h"
+ #include "http_config.h"
+ #include "http_core.h"
+ #include "http_log.h"
+ #include "http_main.h"
+ #include "http_protocol.h"
+ #include "util_script.h"
+ 
+ #include <stdio.h>
+ #include <XalanTransformer/XalanCAPI.h>
+ 
+ typedef struct {
+ 
+   request_rec *r;
+   int fHeadersSent;
+ 
+ } CONTROL_STRUCT;
+     
+ 
+ module MODULE_VAR_EXPORT polarxslt_module;
+ 
+ static int xslt_handler(request_rec *);
+ 
+ static const handler_rec xslt_handlers[] =
+   {
+    {"polarxslt-handler", xslt_handler}, 
+    {NULL}
+   };
+ 
+ static void xslt_init(){
+   ap_add_version_component("polarXSLT/0.1");
+ }
+ 
+ static void xslt_child_init(server_rec *s, pool *p){
+   XalanInitialize();
+ }
+ 
+ static void xslt_child_exit(server_rec *s, pool *p){
+   XalanTerminate();
+ }
+ 
+ static unsigned long xalan_output_handler(const void *data, unsigned long
+ length, const void *handle)
+ {
+   CONTROL_STRUCT *ctrl = (CONTROL_STRUCT *)handle;
+ 
+   request_rec *r = ctrl->r;
+ 
+   char* d = (char *)data;
+   if (!ctrl->fHeadersSent){
+     ap_send_http_header(r);
+     ctrl->fHeadersSent=1;
+   }
+   return ap_rwrite(d, length, r);
+ }
+ 
+ 
+ 
+ static void xalan_flush_handler(const void *handle)
+ {
+       CONTROL_STRUCT *ctrl = (CONTROL_STRUCT *)handle;
+       ap_rflush(ctrl->r);
+ }
+ 
+ 
+ // main handler function
+ static int xslt_handler(request_rec *r){
+   XalanHandle xalan = NULL;
+   int error = 0;
+   char *xalan_error, *uri;
+   CONTROL_STRUCT ctrl = {0,0};
+ 
+   ctrl.r = r;
+   
+   /* return HTTP 404 if there is no such file! */
+   if (r->finfo.st_mode==0)
+     return NOT_FOUND;
+   
+ 
+   if (!r->header_only) {
+     xalan = CreateXalanTransformer();
+     uri=ap_pstrcat(r->pool, r->filename, NULL);
+    
+     /* Try to convert XML file using an XSL indicate in the file with a
+ processing instruction */
+     error = XalanTransformToHandler(uri, , xalan, &ctrl, xalan_output_handler,
+ xalan_flush_handler);
+   }else{
+     ap_send_http_header(r);
+     ap_rflush(r);
+    }
+ 
+   /* if XSLTransformation was unsuccessful - send an error info along with 422
+ error to client */
+   if (error!=0){
+     /* build the error message first */
+     xalan_error=ap_psprintf(r->pool,"%s %s %s %s %s","<html><head><title>XSLT
+ error</title></head><body><h1>XSLT error ", uri, "occured:</h2><pre>",(char
+ *)XalanGetLastError(xalan),"</pre></body></html>");
+     /* set necessary HTTP headers */
+     r->status=HTTP_UNPROCESSABLE_ENTITY;
+     r->content_type="text/html";
+     /* send HTTP headers (apache won't send them when an error occurs) */
+     ap_send_http_header(r);
+     /* send the error text */
+     ap_rputs(xalan_error, r);
+     /* Flush output stream */
+     ap_rflush(r);
+   }
+   /* now we can delete the transformer... */
+   DeleteXalanTransformer(xalan);
+   /* ... and send OK to apache (it means "no need for further processing") */
+   return OK;
+ }
+ 
+ module MODULE_VAR_EXPORT polarxslt_module = 
+   {
+    STANDARD_MODULE_STUFF, 
+    xslt_init,                                 // Initializer
+    NULL,                              // Create per-directory config structure
+    NULL,                              // Merge per-directory config structure
+    NULL,                              // Create per-server config structure
+    NULL,                              // Merge per-server config structure
+    NULL,              
+       // Command table
+    xslt_handlers,                             // Handlers
+    NULL,              
+       // Translate_handler
+    NULL,              
+       // Check user id
+    NULL,              
+       // Check auth
+    NULL,                              // Check access
+    NULL,                              // Type checker
+    NULL,                              // Pre-run fixups
+    NULL,                              // Logger
+    NULL,                              // Header parser
+    xslt_child_init,                   // Child init
+    xslt_child_exit,                   // Child exit
+    NULL               
+               // Post read-request
+   };

Reply via email to