$NetBSD: patch-ab,v 1.4 2012/11/23 11:37:41 joerg Exp $

This patch incorporates a patch from the mod_xslt project page on sourceforge
in order to have a valid base URI set during xslt processing, so that document
inclusion will DTRT.

It also fixes two multi-line literals which are disallowed in gcc 3.3.

--- mod_xslt.c.orig	2000-08-24 02:05:28.000000000 +0000
+++ mod_xslt.c
@@ -43,7 +43,7 @@
 #include "http_protocol.h"
 #include "ap_config.h"
 #include "util_uri.h"
-#include "alloc.h"
+#include "ap_alloc.h"
 #include "http_core.h"
 #include "sablot.h"
 #include "http_log.h"
@@ -195,6 +195,8 @@ MessageHandler sablotMH = {
 
 int transform(request_rec *r, char *styleSheetStr, char *inputStr, char **resultStr) {
   int se;
+  char *cwd = NULL;
+  char *baseURI = NULL;
   char *argums[] =
   {
     "/_stylesheet", styleSheetStr,
@@ -209,6 +211,14 @@ int transform(request_rec *r, char *styl
     se = SablotCreateProcessor (&theproc);
     if (cfg->debug)
       se |= SablotRegHandler(theproc, HLR_MESSAGE, &sablotMH, (void*)r);
+
+    /* get current working directory */
+    cwd = ap_palloc(r->pool, MAXCHAR +1);
+    getcwd(cwd, MAXCHAR);
+
+    /* set base URI to cwd */
+    baseURI = ap_pstrcat(r->pool, "file://", cwd, "/", NULL);
+    se |= SablotSetBase(theproc, baseURI);
     se |= SablotRunProcessor(theproc,"arg:/_stylesheet","arg:/_xmlinput","arg:/_output",NULL,argums);
     se |= SablotGetResultArg(theproc,"arg:/_output", resultStr);
     se |= SablotDestroyProcessor(theproc);
@@ -288,12 +298,12 @@ static int mod_xslt_handler(request_rec 
 
   if (!strcmp("xml",mimetype))
     if (cfg->debug){
-      return mod_xslt_debug_out(r, "XSLT DEBUG: \"AddHandler mod_xslt .xml\" will cause infinite
-      recursion. Remove it!\n"); 
-      return ;
+      return mod_xslt_debug_out(r, "XSLT DEBUG: \"AddHandler mod_xslt .xml\" will cause infinite\n"
+      "recursion. Remove it!\n"); 
+      return SERVER_ERROR;
     } else {
-      ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "\"AddHandler mod_xslt .xml\" will cause infinite
-      recursion. Remove it!\n");
+      ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "\"AddHandler mod_xslt .xml\" will cause infinite\n"
+      "recursion. Remove it!\n");
       return SERVER_ERROR;
     }
 
