garyp       00/10/23 14:12:04

  Modified:    java/src/org/apache/xalan/lib Redirect.java
  Log:
  Update comments for new package; specify ElemExtensionCall;
  evaluate attributes within current XPathContext.
  
  Revision  Changes    Path
  1.7       +18 -20    xml-xalan/java/src/org/apache/xalan/lib/Redirect.java
  
  Index: Redirect.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/Redirect.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Redirect.java     2000/10/13 02:33:08     1.6
  +++ Redirect.java     2000/10/23 21:12:04     1.7
  @@ -59,17 +59,15 @@
   import java.util.*;
   import java.io.*;
   import java.net.URL;
  -import org.w3c.dom.*;
   import org.xml.sax.ContentHandler;
   import org.apache.serialize.OutputFormat;
   import org.apache.xalan.extensions.XSLProcessorContext;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xalan.templates.StylesheetRoot;
   import org.apache.xalan.templates.ElemExtensionCall;
  -import org.apache.xalan.templates.ElemTemplateElement;
   import org.apache.xalan.res.XSLTErrorResources;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.XPathAPI;
  +import org.apache.xpath.XPath;
   
   /**
    * Implements three extension elements to allow an XSLT transformation to
  @@ -95,7 +93,7 @@
    * <?xml version="1.0"?>
    * <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0";
    *                 xmlns:lxslt="http://xml.apache.org/xslt";
  - *                 xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
  + *                 xmlns:redirect="org.apache.xalan.lib.Redirect"
    *                 extension-element-prefixes="redirect">
    *
    *   <xsl:template match="/">
  @@ -151,7 +149,7 @@
     /**
      * Open the given file and put it in the XML, HTML, or Text formatter 
listener's table.
      */
  -  public void open(XSLProcessorContext context, Element elem)
  +  public void open(XSLProcessorContext context, ElemExtensionCall elem)
       throws java.net.MalformedURLException,
              java.io.FileNotFoundException,
              java.io.IOException,
  @@ -162,12 +160,12 @@
       if(null == flistener)
       {
         String mkdirsExpr 
  -        = ((ElemExtensionCall)elem).getAttribute ("mkdirs", 
context.getContextNode(), 
  +        = elem.getAttribute ("mkdirs", context.getContextNode(), 
                                                     context.getTransformer());
         boolean mkdirs = (mkdirsExpr != null)
                          ? (mkdirsExpr.equals("true") || 
mkdirsExpr.equals("yes")) : true;
          // ContentHandler fl = 
  -       makeFormatterListener(context, (ElemTemplateElement)elem, fileName, 
true, mkdirs);
  +       makeFormatterListener(context, elem, fileName, true, mkdirs);
          // fl.startDocument();
       }
     }
  @@ -176,7 +174,7 @@
      * Write the evalutation of the element children to the given file. Then 
close the file
      * unless it was opened with the open extension element and is in the 
formatter listener's table.
      */
  -  public void write(XSLProcessorContext context, Element elem)
  +  public void write(XSLProcessorContext context, ElemExtensionCall elem)
       throws java.net.MalformedURLException,
              java.io.FileNotFoundException,
              java.io.IOException,
  @@ -194,7 +192,7 @@
                                                     context.getTransformer());
         boolean mkdirs = (mkdirsExpr != null)
                          ? (mkdirsExpr.equals("true") || 
mkdirsExpr.equals("yes")) : true;
  -      formatter = makeFormatterListener(context, (ElemTemplateElement)elem, 
fileName, true, mkdirs);
  +      formatter = makeFormatterListener(context, elem, fileName, true, 
mkdirs);
       }
       else
       {
  @@ -204,7 +202,7 @@
       
       TransformerImpl transf = context.getTransformer();
       
  -    transf.executeChildTemplates((ElemTemplateElement)elem,
  +    transf.executeChildTemplates(elem,
                                    context.getContextNode(),
                                    context.getMode(), formatter);
       
  @@ -225,7 +223,7 @@
     /**
      * Close the given file and remove it from the formatter listener's table.
      */
  -  public void close(XSLProcessorContext context, Element elem)
  +  public void close(XSLProcessorContext context, ElemExtensionCall elem)
       throws java.net.MalformedURLException,
       java.io.FileNotFoundException,
       java.io.IOException,
  @@ -250,7 +248,7 @@
     /**
      * Get the filename from the 'select' or the 'file' attribute.
      */
  -  private String getFilename(XSLProcessorContext context, Element elem)
  +  private String getFilename(XSLProcessorContext context, ElemExtensionCall 
elem)
       throws java.net.MalformedURLException,
       java.io.FileNotFoundException,
       java.io.IOException,
  @@ -265,20 +263,20 @@
       {
         org.apache.xpath.XPathContext xctxt 
           = context.getTransformer().getXPathContext();
  -      XObject xobj = XPathAPI.eval(context.getContextNode(), fileNameExpr, 
xctxt.getNamespaceContext());
  +      XPath myxpath = new XPath(fileNameExpr, elem, 
xctxt.getNamespaceContext(), XPath.SELECT);
  +      XObject xobj = myxpath.execute(xctxt, context.getContextNode(), 
xctxt.getNamespaceContext());
         fileName = xobj.str();
         if((null == fileName) || (fileName.length() == 0))
         {
  -        fileName = ((ElemExtensionCall)elem).getAttribute ("file", 
  -                                                context.getContextNode(), 
  -                                                context.getTransformer());
  +        fileName = elem.getAttribute ("file", 
  +                                      context.getContextNode(), 
  +                                      context.getTransformer());
         }
       }
       else
       {
  -      fileName = ((ElemExtensionCall)elem).getAttribute ("file", 
  -                                                         
context.getContextNode(), 
  -                                                         
context.getTransformer());
  +      fileName = elem.getAttribute ("file", context.getContextNode(), 
  +                                                               
context.getTransformer());
       }
       if(null == fileName)
       {
  @@ -323,7 +321,7 @@
      * Create a new ContentHandler, based on attributes of the current 
ContentHandler.
      */
     private ContentHandler makeFormatterListener(XSLProcessorContext context,
  -                                               ElemTemplateElement elem,
  +                                               ElemExtensionCall elem,
                                                  String fileName,
                                                  boolean shouldPutInTable,
                                                  boolean mkdirs)
  
  
  

Reply via email to