You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/08/01 06:43:01 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/transformer TransformerImpl.java

sboag       00/07/31 21:43:01

  Modified:    java/src/org/apache/xalan/transformer TransformerImpl.java
  Log:
  Add getOutputFormat, add executeChildTemplates varient that accepts a ContentHandler, for extension support.
  
  Revision  Changes    Path
  1.10      +54 -8     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/TransformerImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TransformerImpl.java	2000/07/31 20:32:58	1.9
  +++ TransformerImpl.java	2000/08/01 04:43:01	1.10
  @@ -434,10 +434,19 @@
       return doc;
     }
     
  +    /**
  +   * Create a ContentHandler from a Result object.
  +   */
  +  public ContentHandler createResultContentHandler(Result outputTarget)
  +    throws TransformException
  +  {
  +    return createResultContentHandler(outputTarget, getOutputFormat());
  +  }
  +  
     /**
      * Create a ContentHandler from a Result object.
      */
  -  ContentHandler createResultContentHandler(Result outputTarget)
  +  public ContentHandler createResultContentHandler(Result outputTarget, OutputFormat format)
       throws TransformException
     {
       ContentHandler handler;
  @@ -460,12 +469,6 @@
       // result tree to either a stream or a writer.
       else
       {      
  -      // Get the output format that was set by the user, otherwise get the 
  -      // output format from the stylesheet.
  -      OutputFormat format = (null == m_outputFormat) 
  -                            ? getStylesheet().getOutputComposed() :
  -                              m_outputFormat;
  -      
         String method = format.getMethod();
         if(null == method)
           method = Method.XML;
  @@ -614,8 +617,23 @@
     {
       m_outputFormat = oformat;
     }
  -    
  +
     /**
  +   * Get the output properties used for the transformation.
  +   * 
  +   * @see org.xml.serialize.OutputFormat
  +   */
  +  public OutputFormat getOutputFormat()
  +  {
  +    // Get the output format that was set by the user, otherwise get the 
  +    // output format from the stylesheet.
  +    OutputFormat format = (null == m_outputFormat) 
  +                          ? getStylesheet().getOutputComposed() :
  +                            m_outputFormat;
  +    return format;
  +  }
  +
  +  /**
      * Set a parameter for the templates.
      * @param name The name of the parameter.
      * @param namespace The namespace of the parameter.
  @@ -1074,6 +1092,34 @@
         m_currentMatchNodes.pop();
       }
       return true;
  +  }
  +  
  +  /** 
  +   * <meta name="usage" content="advanced"/>
  +   * Execute each of the children of a template element.
  +   * 
  +   * @param transformer The XSLT transformer instance.
  +   * @param sourceNode The current context node.
  +   * @param mode The current mode.
  +   * @exception SAXException Might be thrown from the  document() function, or
  +   *      from xsl:include or xsl:import.
  +   */
  +  public void executeChildTemplates(ElemTemplateElement elem, 
  +                              Node sourceNode,
  +                              QName mode, ContentHandler handler)
  +    throws SAXException
  +  { 
  +    ContentHandler savedHandler = this.getContentHandler();
  +    try
  +    {
  +      getResultTreeHandler().flushPending();
  +      this.setContentHandler(handler);
  +      executeChildTemplates(elem, sourceNode, mode);
  +    }
  +    finally
  +    {
  +      this.setContentHandler(savedHandler);
  +    }
     }
   
     /**