sboag       99/12/15 22:10:46

  Modified:    samples/pipe pipe.vjp transform.java
               src/org/apache/xalan/xpath XPath.java XPathEnvSupport.java
                        XPathSupport.java XPathSupportDefault.java
               src/org/apache/xalan/xpath/dtm DTMLiaison.java
               src/org/apache/xalan/xpath/xml XMLParserLiaisonDefault.java
               src/org/apache/xalan/xslt StylesheetRoot.java
                        XSLTEngineImpl.java XSLTProcessor.java
  Log:
  Pipe test now works properly.
  
  Revision  Changes    Path
  1.2       +4 -2      xml-xalan/samples/pipe/pipe.vjp
  
        <<Binary file>>
  
  
  1.5       +17 -20    xml-xalan/samples/pipe/transform.java
  
  Index: transform.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/samples/pipe/transform.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- transform.java    1999/12/15 22:37:28     1.4
  +++ transform.java    1999/12/16 06:10:44     1.5
  @@ -60,24 +60,7 @@
   import org.apache.xalan.xslt.XSLTResultTarget;
   import org.apache.xalan.xslt.XSLTProcessorFactory;
   import org.apache.xalan.xslt.StylesheetRoot;
  -import org.apache.xalan.xslt.StylesheetHandler;
  -import org.apache.xalan.xslt.XSLTEngineImpl;
  -import org.apache.xalan.xslt.Constants;
  -import org.apache.xalan.xpath.xml.XMLParserLiaison;
  -import org.apache.xalan.xpath.xml.XSLMessages;
  -import org.apache.xalan.xslt.res.XSLTErrorResources;
   
  -import org.apache.xerces.parsers.SAXParser;
  -
  -import java.io.PrintWriter;
  -import java.io.FileWriter;
  -import java.io.BufferedReader;
  -import java.io.FileReader;
  -import java.io.Reader;
  -import java.io.FileOutputStream;
  -import java.lang.reflect.Constructor;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.Node;
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
  @@ -91,13 +74,27 @@
       throws java.io.IOException, 
              java.net.MalformedURLException, 
              org.xml.sax.SAXException
  -     {    
  +     { 
  +    // Use the XSLTProcessorFactory to create a processor.  
  +    // Hopefully some sort of factory interface and XSLTProcessor 
  +    // interface will be standard someday.
       XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
  +    
  +    // Build the first stylesheet.
       StylesheetRoot stylesheet = processor.processStylesheet("foo.xsl");
  +    
  +    // Build the second stylesheet.
       StylesheetRoot stylesheet2 = processor.processStylesheet("foo2.xsl");
  -       
  -    processor.setOutputStream(System.out);
  +
  +    // Don't really need to set the stylesheet, since it's still set 
  +    // from processStylesheet, but it's good form...
  +    processor.setStylesheet(stylesheet2); 
  +    
  +    // Get and set a proper serializer for final output.
  +    processor.setDocumentHandler(stylesheet2.getSAXSerializer(System.err));
       
  +    // Pipe the output from the first transform into the input for the 
  +    // second transform, and then put the final result to System.out.
       stylesheet.process(new XSLTInputSource("foo.xml"), 
                          new XSLTResultTarget(processor));
        }
  
  
  
  1.11      +14 -21    xml-xalan/src/org/apache/xalan/xpath/XPath.java
  
  Index: XPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/XPath.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XPath.java        1999/12/16 03:50:33     1.10
  +++ XPath.java        1999/12/16 06:10:44     1.11
  @@ -88,11 +88,6 @@
     public static XBoolean m_false = new XBooleanStatic(false);
     
     /**
  -   * The default XLocator.
  -   */
  -  public XLocator m_defaultXLocator= null;
  -      
  -  /**
      * The current pattern string, for diagnostics purposes
      */
     public String m_currentPattern;
  @@ -155,28 +150,18 @@
     public XPath(XPathSupport callbacks, ProblemListener problemListener)
     {
       m_problemListener = problemListener;
  -    m_defaultXLocator = createXLocatorHandler(this);
     }
   
     public XPath(ProblemListener problemListener)
     {
       m_problemListener = problemListener;
  -    m_defaultXLocator = createXLocatorHandler(this);
     }
   
     public XPath()
     {
       m_problemListener = new 
org.apache.xalan.xpath.xml.ProblemListenerDefault();
  -    m_defaultXLocator = createXLocatorHandler(this);
     }
   
  -  protected XPath(XPathSupport callbacks, boolean createDefaultLocator, 
ProblemListener problemListener)
  -  {
  -    m_problemListener = problemListener;
  -    if(createDefaultLocator)
  -      m_defaultXLocator = createXLocatorHandler(this);
  -  }
  -  
     /**
      * Set the problem listener property.
      * This class can have a single listener that can be informed 
  @@ -210,7 +195,15 @@
     {
       return new SimpleNodeLocator();
     }
  -  
  +
  +  /**
  +   * getXLocatorHandler.
  +   */
  +  public XLocator createXLocatorHandler(XPathSupport callbacks)
  +  {
  +    return callbacks.createXLocatorHandler();
  +  }
  +
     private void readObject(ObjectInputStream stream)
       throws IOException
     {
  @@ -271,7 +264,7 @@
         XLocator locator = execContext.getXLocatorFromNode(context);
         
         if(null == locator)
  -        locator = m_defaultXLocator;
  +        locator = execContext.createXLocatorHandler();
   
         while(m_opMap[opPos] == OP_LOCATIONPATHPATTERN)
         {
  @@ -312,7 +305,7 @@
         XLocator locator = execContext.getXLocatorFromNode(dtm.getDocument());
         
         if(null == locator)
  -        locator = m_defaultXLocator;
  +        locator = execContext.createXLocatorHandler();
         
         org.apache.xalan.xpath.dtm.DTMNodeLocator dtmLocator 
           = (org.apache.xalan.xpath.dtm.DTMNodeLocator)locator;
  @@ -814,7 +807,7 @@
       XLocator xlocator = execContext.getXLocatorFromNode(context);
       
       if(null == xlocator)
  -      xlocator = m_defaultXLocator;
  +        xlocator = execContext.createXLocatorHandler();
         
       XNodeSet results = xlocator.union(this, execContext, context, opPos);
       
  @@ -934,7 +927,7 @@
       XLocator xlocator = execContext.getXLocatorFromNode(context);
       
       if(null == xlocator)
  -      xlocator = m_defaultXLocator;
  +        xlocator = execContext.createXLocatorHandler();
         
       XNodeSet results = xlocator.locationPath(this, execContext, context, 
opPos);
       
  @@ -1126,7 +1119,7 @@
       XLocator locator = execContext.getXLocatorFromNode(context);
       
       if(null == locator)
  -      locator = m_defaultXLocator;
  +        locator = execContext.createXLocatorHandler();
         
       double results = locator.locationPathPattern(this, execContext, context, 
opPos);
       
  
  
  
  1.3       +1 -1      xml-xalan/src/org/apache/xalan/xpath/XPathEnvSupport.java
  
  Index: XPathEnvSupport.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/XPathEnvSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XPathEnvSupport.java      1999/11/28 04:25:08     1.2
  +++ XPathEnvSupport.java      1999/12/16 06:10:44     1.3
  @@ -131,5 +131,5 @@
      */
     public boolean shouldStripSourceNode(Node textNode)
       throws org.xml.sax.SAXException;
  -  
  +    
   }
  
  
  
  1.6       +10 -0     xml-xalan/src/org/apache/xalan/xpath/XPathSupport.java
  
  Index: XPathSupport.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/XPathSupport.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPathSupport.java 1999/12/16 03:50:33     1.5
  +++ XPathSupport.java 1999/12/16 06:10:44     1.6
  @@ -224,6 +224,16 @@
      * is used internally by the XPath engine.
      */
     public void setThrowFoundIndex(boolean b);
  +  
  +  /**
  +   * Get the current error handler, if there is one.
  +   */
  +  public org.xml.sax.ErrorHandler getErrorHandler();
  +  
  +  /**
  +   * getXLocatorHandler.
  +   */
  +  public XLocator createXLocatorHandler();
   
     
     /**
  
  
  
  1.7       +16 -0     
xml-xalan/src/org/apache/xalan/xpath/XPathSupportDefault.java
  
  Index: XPathSupportDefault.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/XPathSupportDefault.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XPathSupportDefault.java  1999/12/16 03:50:33     1.6
  +++ XPathSupportDefault.java  1999/12/16 06:10:44     1.7
  @@ -436,5 +436,21 @@
     {
       return m_callbackInfo;
     }
  +  
  +  /**
  +   * Get the current error handler, if there is one.
  +   */
  +  public org.xml.sax.ErrorHandler getErrorHandler()
  +  {
  +    return null;
  +  }
  +  
  +  /**
  +   * getXLocatorHandler.
  +   */
  +  public XLocator createXLocatorHandler()
  +  {
  +    return new SimpleNodeLocator();
  +  }
   
   }
  
  
  
  1.7       +8 -1      xml-xalan/src/org/apache/xalan/xpath/dtm/DTMLiaison.java
  
  Index: DTMLiaison.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/dtm/DTMLiaison.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DTMLiaison.java   1999/12/14 22:25:09     1.6
  +++ DTMLiaison.java   1999/12/16 06:10:45     1.7
  @@ -391,6 +391,13 @@
     {
       return DTMNodeLocator.getDefaultLocator();
     }
  -
  +  
  +  /**
  +   * getXLocatorHandler.
  +   */
  +  public XLocator createXLocatorHandler()
  +  {
  +    return DTMNodeLocator.getDefaultLocator();
  +  }
   
   }
  
  
  
  1.15      +16 -0     
xml-xalan/src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java
  
  Index: XMLParserLiaisonDefault.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- XMLParserLiaisonDefault.java      1999/12/16 03:50:34     1.14
  +++ XMLParserLiaisonDefault.java      1999/12/16 06:10:45     1.15
  @@ -1962,6 +1962,14 @@
         m_dataProviders.addElement(new DataProviderAssociation(root, 
xlocator));
       }
     }
  +  
  +  /**
  +   * getXLocatorHandler.
  +   */
  +  public XLocator createXLocatorHandler()
  +  {
  +    return new SimpleNodeLocator();
  +  }
   
     /**
      * Get an XLocator provider keyed by node.  This get's
  @@ -2012,6 +2020,14 @@
     public void setThrowFoundIndex(boolean b)
     {
       m_throwFoundIndex = b;
  +  }
  +  
  +  /**
  +   * Get the current error handler, if there is one.
  +   */
  +  public org.xml.sax.ErrorHandler getErrorHandler()
  +  {
  +    return m_errorHandler;
     }
   
   }
  
  
  
  1.15      +20 -6     xml-xalan/src/org/apache/xalan/xslt/StylesheetRoot.java
  
  Index: StylesheetRoot.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/StylesheetRoot.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StylesheetRoot.java       1999/12/16 03:50:35     1.14
  +++ StylesheetRoot.java       1999/12/16 06:10:45     1.15
  @@ -210,7 +210,7 @@
     /**
      * Get a new OutputFormat object according to the attributes of xsl:output.
      */
  -  public OutputFormat getNewOutputFormat()
  +  public OutputFormat getOutputFormat()
     {
       OutputFormat formatter = new OutputFormat(this.getOutputMethod(),
                                                 this.getOutputEncoding(),
  @@ -330,19 +330,19 @@
           }
           else if(null != outputTarget.getByteStream())
           {
  -          OutputFormat formatter = getNewOutputFormat();
  +          OutputFormat formatter = getOutputFormat();
             processor.m_flistener = 
makeSAXSerializer(outputTarget.getByteStream(),
                                                                  formatter);
           }
           else if(null != outputTarget.getCharacterStream())
           {
  -          OutputFormat formatter = getNewOutputFormat();
  +          OutputFormat formatter = getOutputFormat();
             processor.m_flistener = 
makeSAXSerializer(outputTarget.getCharacterStream(),
                                                                  formatter);
           }
           else if(null != outputTarget.getFileName())
           {
  -          OutputFormat formatter = getNewOutputFormat();
  +          OutputFormat formatter = getOutputFormat();
             ostream = new FileOutputStream(outputTarget.getFileName());
             processor.m_flistener = makeSAXSerializer(ostream, formatter);
           }
  @@ -478,11 +478,25 @@
     }
     
     /**
  -   * Creates a compatible SAX serializer for the specified writer
  +   * Creates a compatible SAX serializer for the specified output stream
      * and output format. If the output format is missing, the default
      * is an XML format with UTF8 encoding.
      *
  -   * @param writer The writer
  +   * @param ostream The output stream.
  +   * @return A compatible SAX serializer
  +   */
  +  public DocumentHandler getSAXSerializer( OutputStream ostream )
  +    throws UnsupportedEncodingException
  +  {
  +    return makeSAXSerializer(ostream, getOutputFormat());
  +  }
  +  
  +  /**
  +   * Creates a compatible SAX serializer for the specified output stream
  +   * and output format. If the output format is missing, the default
  +   * is an XML format with UTF8 encoding.
  +   *
  +   * @param ostream The output stream.
      * @param format The output format
      * @return A compatible SAX serializer
      */
  
  
  
  1.24      +11 -6     xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java
  
  Index: XSLTEngineImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XSLTEngineImpl.java       1999/12/16 03:50:35     1.23
  +++ XSLTEngineImpl.java       1999/12/16 06:10:45     1.24
  @@ -694,9 +694,11 @@
     }
   
     /**
  -   * Set the stylesheet root.  If this is set, then the
  +   * Set the stylesheet for this processor.  If this is set, then the
      * process calls that take only the input .xml will use
  -   * this instead of looking for a stylesheet PI.
  +   * this instead of looking for a stylesheet PI.  Also, 
  +   * setting the stylesheet is needed if you are going 
  +   * to use the processor as a SAX DocumentHandler.
      */
     public void setStylesheet(StylesheetRoot stylesheetRoot)
     {
  @@ -704,9 +706,7 @@
     }
   
     /**
  -   * Set the stylesheet root.  If this is set, then the
  -   * process calls that take only the input .xml will use
  -   * this instead of looking for a stylesheet PI.
  +   * Get the current stylesheet for this processor.
      */
     public StylesheetRoot getStylesheet()
     {
  @@ -3292,6 +3292,11 @@
       throws SAXException
     {
       m_sourceTreeHandler = new 
FormatterToDOM(m_parserLiaison.createDocument());
  +    ErrorHandler errHandler = m_parserLiaison.getErrorHandler();
  +    m_parserLiaison = new 
org.apache.xalan.xpath.xdom.XercesLiaison(errHandler);
  +    StylesheetRoot stylesheet = m_stylesheetRoot;
  +    reset();
  +    m_stylesheetRoot = stylesheet;
       m_sourceTreeHandler.startDocument();
     }
   
  @@ -3308,7 +3313,7 @@
         XSLTResultTarget result = (null == m_outputStream) ?
                                   new XSLTResultTarget(m_flistener) :
                                   new XSLTResultTarget(m_outputStream);
  -
  +      
         m_stylesheetRoot.process(this, m_sourceTreeHandler.getRootNode(),
                                  result);
       }
  
  
  
  1.6       +17 -0     xml-xalan/src/org/apache/xalan/xslt/XSLTProcessor.java
  
  Index: XSLTProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTProcessor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XSLTProcessor.java        1999/12/02 06:04:08     1.5
  +++ XSLTProcessor.java        1999/12/16 06:10:45     1.6
  @@ -71,6 +71,9 @@
   import org.w3c.dom.Node;
   import org.xml.sax.DocumentHandler;
   import org.xml.sax.SAXException;
  +import java.io.OutputStream;
  +import java.io.UnsupportedEncodingException;
  +import org.apache.xml.serialize.OutputFormat;
   
   /**
    * This is an interface for an XSLT Processor engine.
  @@ -148,6 +151,20 @@
      */
     public Node getSourceTreeFromInput(XSLTInputSource inputSource)
       throws org.xml.sax.SAXException;
  +  
  +  /**
  +   * Set the stylesheet for this processor.  If this is set, then the
  +   * process calls that take only the input .xml will use
  +   * this instead of looking for a stylesheet PI.  Also, 
  +   * setting the stylesheet is needed if you are going 
  +   * to use the processor as a SAX DocumentHandler.
  +   */
  +  public void setStylesheet(StylesheetRoot stylesheetRoot);
  +  
  +  /**
  +   * Get the current stylesheet for this processor.
  +   */
  +  public StylesheetRoot getStylesheet();
     
     /**
      * Get the XML Parser Liaison that this processor uses.
  
  
  

Reply via email to