garyp       01/01/11 02:05:29

  Modified:    java/src/org/apache/xalan/templates ElemExtensionCall.java
                        ElemFallback.java
  Log:
  Remove isAvailable field that was being changed at execution time which is 
not allowed since Stylesheets must be immutable at execution time so they can 
be shared between threads.
  Make the default execute(..) method for ElemFallback do nothing.
  Add an execute(..) method to ElemFallback that must be explicity invoked for 
fallback execution.
  
  Revision  Changes    Path
  1.20      +1 -25     
xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionCall.java
  
  Index: ElemExtensionCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionCall.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ElemExtensionCall.java    2001/01/07 04:10:35     1.19
  +++ ElemExtensionCall.java    2001/01/11 10:04:56     1.20
  @@ -95,12 +95,6 @@
      *  @serial          */
     String m_extns;
   
  -  // String m_extHandlerLookup;
  -
  -  // YOU CAN'T DO THIS HERE, AS STYLESHEETS MUST BE IMMUTABLE DURING 
RUNTIME. -sb
  -  /* Flag indicating if the extension is available for execution    */
  -  transient boolean isAvailable = false;
  -
     /** Language used by extension.
      *  @serial          */
     String m_lang;
  @@ -141,15 +135,6 @@
     // }
   
     /**
  -   * Tell if this extension element is available for execution.
  -   */
  -  public boolean elementIsAvailable()
  -  {
  -    return isAvailable;
  -    // This needs to ask the execution context...
  -  }
  -
  -  /**
      * This function is called after everything else has been
      * recomposed, and allows the template to set remaining
      * values that may be based on some other property that
  @@ -263,7 +248,7 @@
           try
           {
             transformer.pushElemTemplateElement(child);
  -          child.execute(transformer, sourceNode, mode);
  +          ((ElemFallback) child).execute(transformer, sourceNode, mode, 
true);
           }
           finally
           {
  @@ -316,12 +301,6 @@
   
         try
         {
  -
  -        // We set isAvailable to true so that if the extension element 
processes its
  -        // children, and one of those children is an <xsl:fallback>, it 
won't get invoked.
  -
  -        // YOU CAN'T DO THIS HERE, AS STYLESHEETS MUST BE IMMUTABLE DURING 
RUNTIME. -sb
  -        isAvailable = true;
           nsh.processElement(this.getLocalName(), this, transformer,
                              getStylesheet(), sourceNode.getOwnerDocument(),
                              sourceNode, mode, this);
  @@ -350,9 +329,6 @@
           }
   
           // transformer.message(msg);
  -        
  -        // YOU CAN'T DO THIS HERE, AS STYLESHEETS MUST BE IMMUTABLE DURING 
RUNTIME. -sb
  -        isAvailable = false;
           
           executeFallbacks(
             transformer, sourceNode, mode);
  
  
  
  1.8       +29 -13    
xml-xalan/java/src/org/apache/xalan/templates/ElemFallback.java
  
  Index: ElemFallback.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemFallback.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ElemFallback.java 2000/12/05 22:29:27     1.7
  +++ ElemFallback.java 2001/01/11 10:05:11     1.8
  @@ -60,7 +60,7 @@
   
   import org.xml.sax.*;
   
  -import org.apache.xpath.*;
  +// import org.apache.xpath.*;
   import org.apache.xalan.trace.SelectionEvent;
   import org.apache.xml.utils.QName;
   import org.apache.xalan.res.XSLTErrorResources;
  @@ -102,7 +102,25 @@
     }
   
     /**
  -   * Execute the fallback elements.
  +   * This is the normal call when xsl:fallback is instantiated.
  +   * In accordance with the XSLT 1.0 Recommendation, chapter 15,
  +   * "Normally, instantiating an xsl:fallback element does nothing."
  +   *
  +   * @param transformer non-null reference to the the current transform-time 
state.
  +   * @param sourceNode non-null reference to the <a 
href="http://www.w3.org/TR/xslt#dt-current-node";>current source node</a>.
  +   * @param mode reference, which may be null, to the <a 
href="http://www.w3.org/TR/xslt#modes";>current mode</a>.
  +   *
  +   * @throws TransformerException
  +   */
  +  public void execute(
  +          TransformerImpl transformer, Node sourceNode, QName mode)
  +            throws TransformerException
  +  {
  +  }
  +
  +  /**
  +   * Execute the fallback elements.  This must be explicitly called to
  +   * instantiate the content of an xsl:fallback element.
      * When an XSLT transformer performs fallback for an instruction
      * element, if the instruction element has one or more xsl:fallback
      * children, then the content of each of the xsl:fallback children
  @@ -112,27 +130,25 @@
      * @param transformer non-null reference to the the current transform-time 
state.
      * @param sourceNode non-null reference to the <a 
href="http://www.w3.org/TR/xslt#dt-current-node";>current source node</a>.
      * @param mode reference, which may be null, to the <a 
href="http://www.w3.org/TR/xslt#modes";>current mode</a>.
  +   * @param dummyArg used to indicate that this method, rather than the 
three argument method
  +   *        is to be executed resulting in processing of the fallback 
elements.
      *
      * @throws TransformerException
      */
     public void execute(
  -          TransformerImpl transformer, Node sourceNode, QName mode)
  +          TransformerImpl transformer, Node sourceNode, QName mode, boolean 
dummyArg)
               throws TransformerException
     {
   
       if (Constants.ELEMNAME_EXTENSIONCALL == m_parentNode.getXSLToken())
       {
  -      ElemExtensionCall parent = (ElemExtensionCall) m_parentNode;
  +
  +      if (TransformerImpl.S_DEBUG)
  +        transformer.getTraceManager().fireTraceEvent(sourceNode, mode,
  +                this);
  +
  +      transformer.executeChildTemplates(this, sourceNode, mode);
   
  -      if (!parent.elementIsAvailable())
  -      {
  -        if (TransformerImpl.S_DEBUG)
  -          transformer.getTraceManager().fireTraceEvent(sourceNode, mode,
  -                  this);
  -
  -        // XPathContext xctxt = transformer.getXPathContext();
  -        transformer.executeChildTemplates(this, sourceNode, mode);
  -      }
       }
       else
       {
  
  
  

Reply via email to