Pass the extension element as the prefix resolve, instead of whatever
is pushed on the XPathContext stack.  The Variable hack needs this
to work correctly.

Comment out patch that makes the filename relative to the current
output URL.  Just to make fop codegen work.  This will need to
be commented back in, once we can get fop to change their
stylesheets.

diff --git a/src/org/apache/xalan/lib/Redirect.java b/src/org/apache/xalan/lib/Redirect.java
index 25619ee..b41eeaf 100644
--- a/src/org/apache/xalan/lib/Redirect.java
+++ b/src/org/apache/xalan/lib/Redirect.java
@@ -288,7 +288,7 @@
       org.apache.xpath.XPathContext xctxt 
         = context.getTransformer().getXPathContext();
       XPath myxpath = new XPath(fileNameExpr, elem, xctxt.getNamespaceContext(), XPath.SELECT);
-      XObject xobj = myxpath.execute(xctxt, context.getContextNode(), xctxt.getNamespaceContext());
+      XObject xobj = myxpath.execute(xctxt, context.getContextNode(), elem);
       fileName = xobj.str();
       if((null == fileName) || (fileName.length() == 0))
       {
@@ -367,11 +367,12 @@
       // TransformerImpl.setOutputTarget() to set the desired Result base.
   //      String base = urlToFileName(elem.getStylesheet().getSystemId());
 
-      Result outputTarget = transformer.getOutputTarget();
-      if ( (null != outputTarget) && ((base = outputTarget.getSystemId()) != null) ) {
-        base = urlToFileName(base);
-      }
-      else
+  // %REVIEW% This breaks FOP codegen. -sb
+//      Result outputTarget = transformer.getOutputTarget();
+//      if ( (null != outputTarget) && ((base = outputTarget.getSystemId()) != null) ) {
+//        base = urlToFileName(base);
+//      }
+//      else
       {
         base = urlToFileName(transformer.getBaseURLOfSource());
       }
@@ -381,6 +382,7 @@
         File baseFile = new File(base);
         file = new File(baseFile.getParent(), fileName);
       }
+      // System.out.println("file is: "+file.toString());
     }
 
     if(mkdirs)