Scott,

I'm not seeing any problems due to this redirect change with the FOP build
currently. What was the problem you were seeing?

-Kelly

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 19, 2001 3:14 PM
> To: [EMAIL PROTECTED]
> Cc: Fop-Dev
> Subject: Problem with Redirect patch for fop codegen
> 
> 
> >   +      Result outputTarget = transformer.getOutputTarget();
> >   +      if ( (null != outputTarget) && ((base = 
> outputTarget.getSystemId
> ()) != null) ) {
> >   +        base = urlToFileName(base);
> >   +      }
> 
> For the moment I need to comment this out in order to get the 
> fop codegen
> to work.  We can enable it again as soon soon as we can get 
> the fop folks
> to modify their stylesheets.  There's always the chance that 
> I'll screw
> someone else up in the gump chain my doing this, so I'm not 
> sure what the
> best answer is.
> 
> -scott
> 
> 
> ----- Forwarded by Scott Boag/CAM/Lotus on 06/19/2001 05:08 PM -----
>                                                               
>                                                      
>                     garyp@apache.                             
>                                                      
>                     org                  To:     
> [EMAIL PROTECTED]                                          
>                                          cc:     (bcc: Scott 
> Boag/CAM/Lotus)                                       
>                     03/13/2001           Subject:     cvs 
> commit: xml-xalan/java/src/org/apache/xalan/xslt         
>                     05:02 PM             Process.java         
>                                                      
>                     Please                                    
>                                                      
>                     respond to                                
>                                                      
>                     xalan-dev                                 
>                                                      
>                                                               
>                                                      
>                                                               
>                                                      
> 
> 
> 
> 
> garyp       01/03/13 14:02:10
> 
>   Modified:    java/src/org/apache/xalan/lib Redirect.java
>                java/src/org/apache/xalan/transformer 
> TransformerImpl.java
>                java/src/org/apache/xalan/xslt Process.java
>   Log:
>   Remember the Result that was used to trigger the transform. 
>  Access that
> result from the Redirect extension to make file references in Redirect
> relative to the original result URI.
>   If this is not available, references are relative to the source URI.
> 
>   Revision  Changes    Path
>   1.12      +23 -4
> 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.11
>   retrieving revision 1.12
>   diff -u -r1.11 -r1.12
>   --- Redirect.java       2001/01/26 01:26:57            1.11
>   +++ Redirect.java       2001/03/13 22:01:51            1.12
>   @@ -72,13 +72,14 @@
>    import org.apache.xpath.XPath;
> 
>    import javax.xml.transform.stream.StreamResult;
>   +import javax.xml.transform.Result;
>    import javax.xml.transform.TransformerException;
> 
>    /**
>     * Implements three extension elements to allow an XSLT 
> transformation
> to
>     * redirect its output to multiple output files.
>     * You must declare the Xalan namespace (xmlns:lxslt="
> http://xml.apache.org/xslt";),
>   - * a namespace for the extension prefix (such as xmlns:redirect
> ="org.apache.xalan.xslt.extensions.Redirect"),
>   + * a namespace for the extension prefix (such as xmlns:redirect
> ="org.apache.xalan.lib.Redirect"),
>     * and declare the extension namespace as an extension
> (extension-element-prefixes="redirect").
>     * You can either just use redirect:write, in which case 
> the file will
> be
>     * opened and immediately closed after the write, or you 
> can bracket the
>   @@ -90,8 +91,10 @@
>     * that indicates the filename.  If the string evaluates 
> to empty, it
> will
>     * attempt to use the 'file' attribute as a default.  
> Filenames can be
> relative
>     * or absolute.  If they are relative, the base directory 
> will be the
> same as
>   - * the base directory for the output document
> (setOutputFileName(outFileName) must
>   - * be called first on the processor when using the API).
>   + * the base directory for the output document.  This is obtained by
> calling
>   + * getOutputTarget() on the TransformerImpl.  You can set this base
> directory
>   + * by calling TransformerImpl.setOutputTarget() or it is 
> automatically
> set
>   + * when using the two argument form of transform() or 
> transformNode().
>     *
>     * <p>Example:</p>
>     * <PRE>
>   @@ -351,10 +354,26 @@
>      {
>        File file = new File(fileName);
>        TransformerImpl transformer = context.getTransformer();
>   +    String base;          // Base URI to use for relative paths
> 
>        if(!file.isAbsolute())
>        {
>   -      String base = 
> urlToFileName(elem.getStylesheet().getSystemId());
>   +      // This code is attributed to Jon Grov <[EMAIL PROTECTED]>.  A
> relative file name
>   +      // is relative to the Result used to kick off the 
> transform.  If
> no such
>   +      // Result was supplied, the filename is relative to 
> the source
> document.
>   +      // When transforming with a SAXResult or DOMResult, call
>   +      // 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
>   +      {
>   +        base = urlToFileName(transformer.getBaseURLOfSource());
>   +      }
>   +
>          if(null != base)
>          {
>            File baseFile = new File(base);
> 
> 
> 
>   1.89      +27 -0
> xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
> 
>   Index: TransformerImpl.java
>   ===================================================================
>   RCS file:
> /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/Tran
> sformerImpl.java,v
> 
>   retrieving revision 1.88
>   retrieving revision 1.89
>   diff -u -r1.88 -r1.89
>   --- TransformerImpl.java          2001/03/11 21:51:56       
>      1.88
>   +++ TransformerImpl.java          2001/03/13 22:01:58       
>      1.89
>   @@ -192,6 +192,9 @@
>      /** The base URL of the source tree.          */
>      private String m_urlOfSource = null;
> 
>   +  /** The Result object at the start of the transform, if 
> any.    */
>   +  private Result m_outputTarget = null;
>   +
>      /**
>       * The output format object set by the user.  May be null.
>       */
>   @@ -402,6 +405,7 @@
>          m_currentMatchTemplates.removeAllElements();
> 
>          m_resultTreeHandler = null;
>   +      m_outputTarget = null;
>          m_keyManager = new KeyManager();
>          m_attrSetStack = null;
>          m_countersTable = null;
>   @@ -698,6 +702,27 @@
>      }
> 
>      /**
>   +   * Get the original output target.
>   +   *
>   +   * @return The Result object used to kick of the 
> transform or null.
>   +   */
>   +  public Result getOutputTarget()
>   +  {
>   +    return m_outputTarget;
>   +  }
>   +
>   +  /**
>   +   * Set the original output target.  This is useful when 
> using a SAX
> transform and
>   +   * supplying a ContentHandler or when the URI of the 
> output target
> should
>   +   * not be the same as the systemID of the original output target.
>   +   *
>   +   */
>   +  public void setOutputTarget(Result outputTarget)
>   +  {
>   +    m_outputTarget = outputTarget;
>   +  }
>   +
>   +  /**
>       * Get an output property that is in effect for the
>       * transformation.  The property specified may be a property
>       * that was set with setOutputProperty, or it may be a
>   @@ -1116,6 +1141,7 @@
>        synchronized(m_reentryGuard)
>        {
>          ContentHandler handler = 
> createResultContentHandler(outputTarget);
>   +      m_outputTarget = outputTarget;
> 
>          this.setContentHandler(handler);
>          transform(xmlSource);
>   @@ -1136,6 +1162,7 @@
>      {
> 
>        ContentHandler handler = 
> createResultContentHandler(outputTarget);
>   +    m_outputTarget = outputTarget;
> 
>        this.setContentHandler(handler);
>        transformNode(node);
> 
> 
> 
>   1.30      +15 -10
> xml-xalan/java/src/org/apache/xalan/xslt/Process.java
> 
>   Index: Process.java
>   ===================================================================
>   RCS file:
> /home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/Process.java,v
>   retrieving revision 1.29
>   retrieving revision 1.30
>   diff -u -r1.29 -r1.30
>   --- Process.java        2001/03/13 17:28:42            1.29
>   +++ Process.java        2001/03/13 22:02:05            1.30
>   @@ -56,6 +56,7 @@
>     */
>    package org.apache.xalan.xslt;
> 
>   +import java.io.File;
>    import java.io.FileInputStream;
>    import java.io.FileOutputStream;
>    import java.io.FileWriter;
>   @@ -562,9 +563,16 @@
>            }
> 
>            PrintWriter resultWriter;
>   -        OutputStream outputStream = (null != outFileName)
>   -                                    ? new 
> FileOutputStream(outFileName)
>   -                                    : (OutputStream) System.out;
>   +        StreamResult strResult;
>   +        if (null != outFileName)
>   +        {
>   +          strResult = new StreamResult(new File(outFileName));
>   +        }
>   +        else
>   +        {
>   +          strResult = new StreamResult(System.out);
>   +        }
>   +
> 
>            SAXTransformerFactory stf = 
> (SAXTransformerFactory)tfactory;
> 
>   @@ -651,8 +659,7 @@
> 
>       serializer.transform(new DOMSource(outNode), result);
>                                                               
>           }
> 
> else
>   -
>       serializer.transform(new DOMSource(outNode),
>   -                                   new StreamResult(outputStream));
>   +
>       serializer.transform(new DOMSource(outNode), strResult);
>               }
>                else
>                {
>   @@ -669,7 +676,7 @@
> 
>       else
> 
>       {
> 
>                 transformer.transform(new SAXSource(reader, new
> InputSource(inFileName)),
>   -
> 
>                                           new 
> StreamResult(outputStream));
>   +
> 
>                                           strResult);
> 
>       }
>                                                               
>           }
> 
> else if (contentHandler != null)
>   @@ -679,8 +686,7 @@
> 
> 
>                                           result);
>                                                               
>           }
> 
> else
>   -
>       transformer.transform(new StreamSource(inFileName),
>   -
> 
>                                           new 
> StreamResult(outputStream));
>   +
>       transformer.transform(new StreamSource(inFileName), strResult);
>                }
>              }
>              else
>   @@ -688,8 +694,7 @@
>                StringReader reader =
>                  new StringReader("<?xml version=\"1.0\"?> <doc/>");
> 
>   -            transformer.transform(new StreamSource(reader),
>   -                                  new StreamResult(outputStream));
>   +            transformer.transform(new 
> StreamSource(reader), strResult);
>              }
>            }
>            else
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to