sboag       01/05/30 13:31:28

  Modified:    java/src/org/apache/xalan/templates Tag: DTM_EXP
                        ElemForEach.java ElemTextLiteral.java
                        StylesheetRoot.java TemplateList.java
               java/src/org/apache/xalan/transformer Tag: DTM_EXP
                        TransformerImpl.java
               java/src/org/apache/xml/dtm Tag: DTM_EXP DTMWSFilter.java
               java/src/org/apache/xml/dtm/ref Tag: DTM_EXP
                        DTMDefaultBase.java DTMDefaultBaseTraversers.java
                        DTMManagerDefault.java
               java/src/org/apache/xml/dtm/ref/dom2dtm Tag: DTM_EXP
                        DOM2DTM.java
               java/src/org/apache/xml/dtm/ref/sax2dtm Tag: DTM_EXP
                        SAX2DTM.java
               java/src/org/apache/xml/utils Tag: DTM_EXP NodeVector.java
               java/src/org/apache/xpath Tag: DTM_EXP Expression.java
                        NodeSet.java
               java/src/org/apache/xpath/axes Tag: DTM_EXP
                        WalkerFactory.java WalkingIterator.java
               java/src/org/apache/xpath/compiler Tag: DTM_EXP
                        Compiler.java
               java/src/org/apache/xpath/patterns Tag: DTM_EXP
                        FunctionPattern.java StepPattern.java
  Added:       java/src/org/apache/xpath/axes Tag: DTM_EXP
                        WalkingIteratorSorted.java
  Log:
  Minor performance tweaks for getNodeType.
  Minor tweaks for StepPattern#execute.
  For the moment don't use MatchIterator, but use WalkerIteratorSorted instead.
  Minor tweaks for DTMWSFilter to pass DTM.
  Direct call to get string characters for templates if only child is
  a text literal.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.20.2.6  +1 -1      
xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java
  
  Index: ElemForEach.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java,v
  retrieving revision 1.20.2.5
  retrieving revision 1.20.2.6
  diff -u -r1.20.2.5 -r1.20.2.6
  --- ElemForEach.java  2001/05/29 14:30:59     1.20.2.5
  +++ ElemForEach.java  2001/05/30 20:30:46     1.20.2.6
  @@ -408,7 +408,7 @@
             {
               QName mode = transformer.getMode();
               
  -            template = tl.getTemplate(xctxt, child, mode, -1, quiet);
  +            template = tl.getTemplate(xctxt, child, mode, -1, quiet, dtm);
   
               // If that didn't locate a node, fall back to a default template 
rule.
               // See http://www.w3.org/TR/xslt#built-in-rule.
  
  
  
  1.8.2.2   +23 -0     
xml-xalan/java/src/org/apache/xalan/templates/ElemTextLiteral.java
  
  Index: ElemTextLiteral.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemTextLiteral.java,v
  retrieving revision 1.8.2.1
  retrieving revision 1.8.2.2
  diff -u -r1.8.2.1 -r1.8.2.2
  --- ElemTextLiteral.java      2001/04/10 18:44:49     1.8.2.1
  +++ ElemTextLiteral.java      2001/05/30 20:30:47     1.8.2.2
  @@ -107,6 +107,12 @@
      * @serial
      */
     private char m_ch[];
  +  
  +  /**
  +   * The character array as a string.
  +   * @serial
  +   */
  +  private String m_str;
   
     /**
      * Set the characters that will be output to the result tree..
  @@ -127,6 +133,23 @@
     {
       return m_ch;
     }
  +  
  +  /**
  +   * Get the value of the node as a string.
  +   *
  +   * @return null
  +   */
  +  public synchronized String getNodeValue()
  +  {
  +
  +    if(null == m_str)
  +    {
  +      m_str = new String(m_ch);
  +    }
  +
  +    return m_str;
  +  }
  +
   
     /**
      * Tells if this element should disable escaping.
  
  
  
  1.40.2.2  +10 -7     
xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java
  
  Index: StylesheetRoot.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/StylesheetRoot.java,v
  retrieving revision 1.40.2.1
  retrieving revision 1.40.2.2
  diff -u -r1.40.2.1 -r1.40.2.2
  --- StylesheetRoot.java       2001/04/10 18:44:52     1.40.2.1
  +++ StylesheetRoot.java       2001/05/30 20:30:48     1.40.2.2
  @@ -702,11 +702,14 @@
                                             int targetNode,
                                             QName mode,
                                             int maxImportLevel,
  -                                          boolean quietConflictWarnings)
  +                                          boolean quietConflictWarnings,
  +                                          DTM dtm)
               throws TransformerException
     {
  -    return m_templateList.getTemplate(xctxt, targetNode, mode, 
maxImportLevel,
  -                                                                
quietConflictWarnings);
  +    return m_templateList.getTemplate(xctxt, targetNode, mode, 
  +                                      maxImportLevel,
  +                                      quietConflictWarnings,
  +                                      dtm);
     }
   
     /**
  @@ -821,12 +824,12 @@
      * @throws TransformerException
      */
     public WhiteSpaceInfo getWhiteSpaceInfo(
  -          XPathContext support, int targetElement) throws 
TransformerException
  +          XPathContext support, int targetElement, DTM dtm) throws 
TransformerException
     {
   
       if (null != m_whiteSpaceInfoList)
         return (WhiteSpaceInfo) m_whiteSpaceInfoList.getTemplate(support,
  -              targetElement, null, -1, false);
  +              targetElement, null, -1, false, dtm);
       else
         return null;
     }
  @@ -849,12 +852,12 @@
       {
         while(DTM.NULL != targetElement)
         {
  +        DTM dtm = support.getDTM(targetElement);
           WhiteSpaceInfo info = (WhiteSpaceInfo) 
m_whiteSpaceInfoList.getTemplate(support,
  -                targetElement, null, -1, false);
  +                targetElement, null, -1, false, dtm);
           if(null != info)
             return info.getShouldStripSpace();
           
  -        DTM dtm = support.getDTM(targetElement);
           int parent = dtm.getParent(targetElement);
           if(DTM.NULL != parent && DTM.ELEMENT_NODE == dtm.getNodeType(parent))
             targetElement = parent;
  
  
  
  1.30.2.2  +7 -6      
xml-xalan/java/src/org/apache/xalan/templates/TemplateList.java
  
  Index: TemplateList.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/TemplateList.java,v
  retrieving revision 1.30.2.1
  retrieving revision 1.30.2.2
  diff -u -r1.30.2.1 -r1.30.2.2
  --- TemplateList.java 2001/04/10 18:44:53     1.30.2.1
  +++ TemplateList.java 2001/05/30 20:30:49     1.30.2.2
  @@ -454,14 +454,14 @@
      *
      * @param xctxt The XPath runtime context.
      * @param targetNode The target node that will be checked for a match.
  +   * @param dtm The dtm owner for the target node.
      *
      * @return The head of a linked list that contains all possible match 
pattern to 
      * template associations.
      */
  -  public TemplateSubPatternAssociation getHead(XPathContext xctxt, int 
targetNode)
  +  public TemplateSubPatternAssociation getHead(XPathContext xctxt, 
  +                                               int targetNode, DTM dtm)
     {
  -
  -    DTM dtm = xctxt.getDTM(targetNode);
       short targetNodeType = dtm.getNodeType(targetNode);
       TemplateSubPatternAssociation head;
   
  @@ -523,11 +523,12 @@
                                   int targetNode,
                                   QName mode,
                                   int maxImportLevel,
  -                                boolean quietConflictWarnings)
  +                                boolean quietConflictWarnings,
  +                                DTM dtm)
               throws TransformerException
     {
   
  -    TemplateSubPatternAssociation head = getHead(xctxt, targetNode);
  +    TemplateSubPatternAssociation head = getHead(xctxt, targetNode, dtm);
   
       if (null != head)
       {
  @@ -548,7 +549,7 @@
             ElemTemplate template = head.getTemplate();        
             xctxt.setNamespaceContext(template);
             
  -          if ((head.m_stepPattern.execute(xctxt) != NodeTest.SCORE_NONE)
  +          if ((head.m_stepPattern.execute(xctxt, targetNode) != 
NodeTest.SCORE_NONE)
                     && head.matchMode(mode))
             {
               if (quietConflictWarnings)
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.90.2.16 +924 -689  
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.90.2.15
  retrieving revision 1.90.2.16
  diff -u -r1.90.2.15 -r1.90.2.16
  --- TransformerImpl.java      2001/05/29 14:31:05     1.90.2.15
  +++ TransformerImpl.java      2001/05/30 20:30:54     1.90.2.16
  @@ -84,6 +84,7 @@
   import org.apache.xalan.templates.ElemParam;
   import org.apache.xalan.templates.ElemCallTemplate;
   import org.apache.xalan.templates.ElemTemplate;
  +import org.apache.xalan.templates.ElemTextLiteral;
   import org.apache.xalan.templates.TemplateList;
   import org.apache.xalan.templates.XUnresolvedVariable;
   import org.apache.xalan.templates.OutputProperties;
  @@ -113,7 +114,6 @@
   import org.apache.xalan.serialize.Serializer;
   import org.apache.xalan.serialize.SerializerFactory;
   import org.apache.xalan.serialize.Method;
  -
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
   import org.apache.xml.dtm.DTMManager;
  @@ -123,7 +123,9 @@
   import org.xml.sax.ContentHandler;
   import org.xml.sax.helpers.XMLFilterImpl;
   import org.xml.sax.InputSource;
  +
   import javax.xml.transform.TransformerException;
  +
   import org.xml.sax.XMLReader;
   import org.xml.sax.SAXException;
   import org.xml.sax.XMLFilter;
  @@ -133,8 +135,8 @@
   import org.xml.sax.ext.LexicalHandler;
   import org.xml.sax.SAXNotRecognizedException;
   import org.xml.sax.SAXNotSupportedException;
  -import javax.xml.transform.ErrorListener;
   
  +import javax.xml.transform.ErrorListener;
   
   // TRaX Imports
   import javax.xml.transform.Source;
  @@ -158,112 +160,126 @@
   
   /**
    * <meta name="usage" content="advanced"/>
  - * This class implements the 
  - * [EMAIL PROTECTED] javax.xml.transform.Transformer} interface, and is the 
core 
  + * This class implements the
  + * [EMAIL PROTECTED] javax.xml.transform.Transformer} interface, and is the 
core
    * representation of the transformation execution.</p>
    */
   public class TransformerImpl extends Transformer
           implements Runnable, DTMWSFilter
   {
  +
     // Synch object to gaurd against setting values from the TrAX interface 
     // or reentry while the transform is going on.
  +
  +  /** NEEDSDOC Field m_reentryGuard          */
     private Boolean m_reentryGuard = new Boolean(true);
  -  
  +
     /**
      * This is null unless we own the stream.
      */
     private java.io.FileOutputStream m_outputStream = null;
  -  
  +
     /**
      * True if the parser events should be on the main thread,
      * false if not.  Experemental.  Can not be set right now.
      */
     private boolean m_parserEventsOnMain = true;
   
  -  /** The thread that the transformer is running on.          */
  +  /** The thread that the transformer is running on. */
     private Thread m_transformThread;
   
  -  /** The base URL of the source tree.          */
  +  /** The base URL of the source tree. */
     private String m_urlOfSource = null;
   
  -  /** The Result object at the start of the transform, if any.    */
  +  /** 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.
      */
     private OutputProperties m_outputFormat;
  -  
  -  /** The output serializer         */
  +
  +  /** The output serializer */
     private Serializer m_serializer;
  -  
  +
     /**
      * The content handler for the source input tree.
      */
     ContentHandler m_inputContentHandler;
  -  
  +
     /**
      * The content handler for the result tree.
      */
     private ContentHandler m_outputContentHandler = null;
   
  -//  /*
  -//   * Use member variable to store param variables as they're
  -//   * being created, use member variable so we don't
  -//   * have to create a new vector every time.
  -//   */
  -//  private Vector m_newVars = new Vector();
  +  //  /*
  +  //   * Use member variable to store param variables as they're
  +  //   * being created, use member variable so we don't
  +  //   * have to create a new vector every time.
  +  //   */
  +  //  private Vector m_newVars = new Vector();
   
     /** The JAXP Document Builder, mainly to create Result Tree Fragments. */
     DocumentBuilder m_docBuilder = null;
   
  -  /** A pool of ResultTreeHandlers, for serialization of a subtree to text.
  -   *  Please note that each of these also holds onto a Text Serializer.  */
  +  /**
  +   * A pool of ResultTreeHandlers, for serialization of a subtree to text.
  +   *  Please note that each of these also holds onto a Text Serializer.  
  +   */
     private ObjectPool m_textResultHandlerObjectPool =
       new ObjectPool("org.apache.xalan.transformer.ResultTreeHandler");
   
  -  /** Related to m_textResultHandlerObjectPool, this is a pool of 
  +  /**
  +   * Related to m_textResultHandlerObjectPool, this is a pool of
      * StringWriters, which are passed to the Text Serializers.
  -   * (I'm not sure if this is really needed any more.  -sb)      */
  +   * (I'm not sure if this is really needed any more.  -sb)      
  +   */
     private ObjectPool m_stringWriterObjectPool =
       new ObjectPool("java.io.StringWriter");
   
  -  /** A static text format object, which can be used over and 
  -   * over to create the text serializers.    */
  +  /**
  +   * A static text format object, which can be used over and
  +   * over to create the text serializers.    
  +   */
     private OutputProperties m_textformat = new OutputProperties(Method.Text);
   
     // Commenteded out in response to problem reported by 
     // Nicola Brown <[EMAIL PROTECTED]>
  -//  /**
  -//   * Flag to let us know if an exception should be reported inside the 
  -//   * postExceptionFromThread method.  This is needed if the transform is 
  -//   * being generated from SAX events, and thus there is no central place 
  -//   * to report the exception from.  (An exception is usually picked up in 
  -//   * the main thread from the transform thread in [EMAIL PROTECTED] 
#transform(Source source)} 
  -//   * from [EMAIL PROTECTED] #getExceptionThrown()}. )
  -//   */
  -//  private boolean m_reportInPostExceptionFromThread = false;
  -  
  -  /** A node vector used as a stack to track the current 
  -   * ElemTemplateElement.  Needed for the 
  -   * org.apache.xalan.transformer.TransformState interface,  
  -   * so a tool can discover the calling template. */
  +  //  /**
  +  //   * Flag to let us know if an exception should be reported inside the 
  +  //   * postExceptionFromThread method.  This is needed if the transform is 
  +  //   * being generated from SAX events, and thus there is no central place 
  +  //   * to report the exception from.  (An exception is usually picked up 
in 
  +  //   * the main thread from the transform thread in [EMAIL PROTECTED] 
#transform(Source source)} 
  +  //   * from [EMAIL PROTECTED] #getExceptionThrown()}. )
  +  //   */
  +  //  private boolean m_reportInPostExceptionFromThread = false;
  +
  +  /**
  +   * A node vector used as a stack to track the current
  +   * ElemTemplateElement.  Needed for the
  +   * org.apache.xalan.transformer.TransformState interface,
  +   * so a tool can discover the calling template. 
  +   */
     Stack m_currentTemplateElements = new Stack();
   
  -  /** A node vector used as a stack to track the current 
  +  /**
  +   * A node vector used as a stack to track the current
      * ElemTemplate that was matched.
  -   * Needed for the 
  -   * org.apache.xalan.transformer.TransformState interface,  
  +   * Needed for the
  +   * org.apache.xalan.transformer.TransformState interface,
      * so a tool can discover the matched template
      */
     Stack m_currentMatchTemplates = new Stack();
  -  
  -  /** A node vector used as a stack to track the current 
  +
  +  /**
  +   * A node vector used as a stack to track the current
      * node that was matched.
  -   * Needed for the 
  -   * org.apache.xalan.transformer.TransformState interface,  
  -   * so a tool can discover the matched 
  -   * node. */
  +   * Needed for the
  +   * org.apache.xalan.transformer.TransformState interface,
  +   * so a tool can discover the matched
  +   * node. 
  +   */
     NodeVector m_currentMatchedNodes = new NodeVector();
   
     /**
  @@ -295,7 +311,7 @@
      */
     private ResultTreeHandler m_resultTreeHandler;
   
  -  /** The key manager, which manages xsl:keys.   */
  +  /** The key manager, which manages xsl:keys. */
     private KeyManager m_keyManager = new KeyManager();
   
     /**
  @@ -315,8 +331,10 @@
      */
     BoolStack m_currentTemplateRuleIsNull = new BoolStack();
   
  -  /** The message manager, which manages error messages, warning 
  -   * messages, and other types of message events.   */
  +  /**
  +   * The message manager, which manages error messages, warning
  +   * messages, and other types of message events.   
  +   */
     private MsgMgr m_msgMgr;
   
     /**
  @@ -324,31 +342,38 @@
      * of trace listeners. Set this to false for optimization purposes.
      */
     public static boolean S_DEBUG = false;
  -  
  +
     /**
      * The SAX error handler, where errors and warnings are sent.
      */
  -  private ErrorListener m_errorHandler = new 
org.apache.xml.utils.DefaultErrorHandler();
  +  private ErrorListener m_errorHandler =
  +    new org.apache.xml.utils.DefaultErrorHandler();
   
     /**
      * The trace manager.
      */
     private TraceManager m_traceManager = new TraceManager(this);
   
  -  /** If the transform thread throws an exception, the exception needs to 
  -   * be stashed away so that the main thread can pass it on to the 
  -   * client. */
  +  /**
  +   * If the transform thread throws an exception, the exception needs to
  +   * be stashed away so that the main thread can pass it on to the
  +   * client. 
  +   */
     private Exception m_exceptionThrown = null;
   
  -  /** The InputSource for the source tree, which is needed if the 
  -   * parse thread is not the main thread, in order for the parse 
  -   * thread's run method to get to the input source.   
  -   * (Delete this if reversing threads is outlawed. -sb)    */
  +  /**
  +   * The InputSource for the source tree, which is needed if the
  +   * parse thread is not the main thread, in order for the parse
  +   * thread's run method to get to the input source.
  +   * (Delete this if reversing threads is outlawed. -sb)    
  +   */
     private Source m_xmlSource;
   
  -  /** This is needed for support of setSourceTreeDocForThread(Node doc),
  -   * which must be called in order for the transform thread's run 
  -   * method to obtain the root of the source tree to be transformed.     */
  +  /**
  +   * This is needed for support of setSourceTreeDocForThread(Node doc),
  +   * which must be called in order for the transform thread's run
  +   * method to obtain the root of the source tree to be transformed.     
  +   */
     private int m_doc;
   
     /**
  @@ -356,22 +381,29 @@
      * need to know when it is done, so we can return.
      */
     private boolean m_isTransformDone = false;
  -  
  +
     /** Flag to to tell if the tranformer needs to be reset. */
     private boolean m_hasBeenReset = false;
  -        
  -        private boolean m_shouldReset = true;
   
  -        public void setShouldReset(boolean shouldReset)
  -        {
  -                m_shouldReset = shouldReset;
  -        }
  -  
  +  /** NEEDSDOC Field m_shouldReset          */
  +  private boolean m_shouldReset = true;
  +
  +  /**
  +   * NEEDSDOC Method setShouldReset 
  +   *
  +   *
  +   * NEEDSDOC @param shouldReset
  +   */
  +  public void setShouldReset(boolean shouldReset)
  +  {
  +    m_shouldReset = shouldReset;
  +  }
  +
     /**
      * A stack of current template modes.
      */
     private Stack m_modes = new Stack();
  -  
  +
     //==========================================================
     // SECTION: Constructors
     //==========================================================
  @@ -395,31 +427,33 @@
      */
     public void reset()
     {
  -    if(!m_hasBeenReset && m_shouldReset)
  +
  +    if (!m_hasBeenReset && m_shouldReset)
       {
         m_hasBeenReset = true;
  -      
  -      if(this.m_outputStream != null)
  +
  +      if (this.m_outputStream != null)
         {
           try
           {
             m_outputStream.close();
           }
  -        catch(java.io.IOException ioe){}
  +        catch (java.io.IOException ioe){}
         }
  +
         m_outputStream = null;
  -  
  +
         // I need to look more carefully at which of these really
         // needs to be reset.
         m_countersTable = null;
         m_stackGuard = new StackGuard();
  -  
  +
         getXPathContext().reset();
         getXPathContext().getVarStack().setSize(1);
         m_currentTemplateElements.removeAllElements();
         m_currentMatchTemplates.removeAllElements();
         m_currentMatchedNodes.removeAllElements();
  -  
  +
         m_resultTreeHandler = null;
         m_outputTarget = null;
         m_keyManager = new KeyManager();
  @@ -429,13 +463,13 @@
         m_xmlSource = null;
         m_doc = DTM.NULL;
         m_isTransformDone = false;
  +
         // m_inputContentHandler = null;
  -      
         // For now, reset the document cache each time.
         getXPathContext().getSourceTreeManager().reset();
       }
  -    
  -//    m_reportInPostExceptionFromThread = false;
  +
  +    //    m_reportInPostExceptionFromThread = false;
     }
   
     // ========= Transformer Interface Implementation ==========
  @@ -474,12 +508,15 @@
     {
       m_transformThread = t;
     }
  -  
  +
  +  /** NEEDSDOC Field m_hasTransformThreadErrorCatcher          */
     private boolean m_hasTransformThreadErrorCatcher = false;
  -  
  +
     /**
  -   * Return true if the transform was initiated from the transform method, 
  +   * Return true if the transform was initiated from the transform method,
      * otherwise it was probably done from a pure parse events.
  +   *
  +   * NEEDSDOC ($objectName$) @return
      */
     public boolean hasTransformThreadErrorCatcher()
     {
  @@ -492,15 +529,15 @@
      *
      * @throws TransformerException
      */
  -  public void transform(Source source) 
  -    throws TransformerException
  +  public void transform(Source source) throws TransformerException
     {
  +
       try
       {
         DTMManager mgr = this.getXPathContext().getDTMManager();
         DTM dtm = mgr.getDTM(source, false, this, true, true);
  -      
         boolean hardDelete = true;  // %REVIEW% I have to think about this. -sb
  +
         try
         {
           this.transformNode(dtm.getDocument());
  @@ -519,14 +556,15 @@
   
         if (null != e)
         {
  -        if (e instanceof javax.xml.transform.TransformerException) 
  +        if (e instanceof javax.xml.transform.TransformerException)
           {
             throw (javax.xml.transform.TransformerException) e;
           }
  -        else if (e instanceof org.apache.xml.utils.WrappedRuntimeException) 
  +        else if (e instanceof org.apache.xml.utils.WrappedRuntimeException)
           {
  -          m_errorHandler.fatalError( new 
javax.xml.transform.TransformerException(
  -            ((org.apache.xml.utils.WrappedRuntimeException) 
e).getException()) );
  +          m_errorHandler.fatalError(
  +            new javax.xml.transform.TransformerException(
  +              ((org.apache.xml.utils.WrappedRuntimeException) 
e).getException()));
           }
           else
           {
  @@ -541,6 +579,7 @@
       catch (org.apache.xml.utils.WrappedRuntimeException wre)
       {
         Throwable throwable = wre.getException();
  +
         while (throwable
                instanceof org.apache.xml.utils.WrappedRuntimeException)
         {
  @@ -548,24 +587,26 @@
             ((org.apache.xml.utils.WrappedRuntimeException) 
throwable).getException();
         }
   
  -      m_errorHandler.fatalError( new 
TransformerException(wre.getException()) );
  +      m_errorHandler.fatalError(new 
TransformerException(wre.getException()));
       }
  +
       // Patch attributed to David Eisenberg <[EMAIL PROTECTED]>
       catch (org.xml.sax.SAXParseException spe)
       {
         String msg = spe.getMessage();
         SAXSourceLocator loc = new SAXSourceLocator(spe);
  -      
  +
         //m_errorHandler.fatalError(new TransformerException( msg, loc ));
  -                        m_errorHandler.fatalError(new TransformerException( 
spe ));
  +      m_errorHandler.fatalError(new TransformerException(spe));
       }
  -    catch(org.xml.sax.SAXException se)
  +    catch (org.xml.sax.SAXException se)
       {
  -      m_errorHandler.fatalError(new TransformerException( se ));
  +      m_errorHandler.fatalError(new TransformerException(se));
       }
       finally
       {
         m_hasTransformThreadErrorCatcher = false;
  +
         // This looks to be redundent to the one done in TransformNode.
         reset();
       }
  @@ -574,17 +615,19 @@
     /**
      * Get the base URL of the source.
      *
  -   * @return The base URL of the source tree, or null. 
  +   * @return The base URL of the source tree, or null.
      */
     public String getBaseURLOfSource()
     {
       return m_urlOfSource;
     }
  -  
  +
     /**
      * Get the base URL of the source.
      *
  -   * @return The base URL of the source tree, or null. 
  +   *
  +   * NEEDSDOC @param base
  +   * @return The base URL of the source tree, or null.
      */
     public void setBaseURLOfSource(String base)
     {
  @@ -600,12 +643,14 @@
     {
       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.
      *
  +   *
  +   * NEEDSDOC @param outputTarget
      */
     public void setOutputTarget(Result outputTarget)
     {
  @@ -621,6 +666,8 @@
      * @param name A non-null String that specifies an output
      * property name, which may be namespace qualified.
      *
  +   * NEEDSDOC @param qnameString
  +   *
      * @return The string value of the output property, or null
      * if no property was found.
      *
  @@ -629,51 +676,57 @@
      * @see javax.xml.transform.OutputKeys
      */
     public String getOutputProperty(String qnameString)
  -    throws IllegalArgumentException
  -  {    
  +          throws IllegalArgumentException
  +  {
  +
       String value = null;
  -    
  -    OutputProperties props = getOutputFormat();    
  -    
  +    OutputProperties props = getOutputFormat();
  +
       value = props.getProperty(qnameString);
  -    
  -    if(null == value)
  +
  +    if (null == value)
       {
  -      if(!props.isLegalPropertyKey(qnameString))
  -        throw new IllegalArgumentException("output property not recognized: 
"+qnameString);
  +      if (!props.isLegalPropertyKey(qnameString))
  +        throw new IllegalArgumentException("output property not recognized: "
  +                                           + qnameString);
       }
  +
       return value;
     }
  -  
  +
     /**
  -   * Get the value of a property, without using the default properties.  
This 
  -   * can be used to test if a property has been explicitly set by the 
stylesheet 
  +   * Get the value of a property, without using the default properties.  This
  +   * can be used to test if a property has been explicitly set by the 
stylesheet
      * or user.
      *
      * @param name The property name, which is a fully-qualified URI.
      *
  +   * NEEDSDOC @param qnameString
  +   *
      * @return The value of the property, or null if not found.
      *
  -   * @throws IllegalArgumentException If the property is not supported, 
  +   * @throws IllegalArgumentException If the property is not supported,
      * and is not namespaced.
      */
     public String getOutputPropertyNoDefault(String qnameString)
  -    throws IllegalArgumentException
  -  {    
  +          throws IllegalArgumentException
  +  {
  +
       String value = null;
  -    
  -    OutputProperties props = getOutputFormat();    
  -    
  -    value = (String)props.getProperties().get(qnameString);
  -    
  -    if(null == value)
  +    OutputProperties props = getOutputFormat();
  +
  +    value = (String) props.getProperties().get(qnameString);
  +
  +    if (null == value)
       {
  -      if(!props.isLegalPropertyKey(qnameString))
  -        throw new IllegalArgumentException("output property not recognized: 
"+qnameString);
  +      if (!props.isLegalPropertyKey(qnameString))
  +        throw new IllegalArgumentException("output property not recognized: "
  +                                           + qnameString);
       }
  +
       return value;
     }
  -  
  +
     /**
      * Set the value of a property.  Recognized properties are:
      *
  @@ -686,24 +739,28 @@
      * @throws IllegalArgumentException if the property name is not legal.
      */
     public void setOutputProperty(String name, String value)
  -    throws IllegalArgumentException
  -  {    
  -    synchronized(m_reentryGuard) 
  +          throws IllegalArgumentException
  +  {
  +
  +    synchronized (m_reentryGuard)
       {
  +
         // Get the output format that was set by the user, otherwise get the 
         // output format from the stylesheet.
  -      if(null == m_outputFormat)
  +      if (null == m_outputFormat)
         {
  -        m_outputFormat = 
(OutputProperties)getStylesheet().getOutputComposed().clone();
  +        m_outputFormat =
  +          (OutputProperties) getStylesheet().getOutputComposed().clone();
         }
  -  
  -      if(!m_outputFormat.isLegalPropertyKey(name))
  -        throw new IllegalArgumentException("output property not recognized: 
"+name);
  -      
  +
  +      if (!m_outputFormat.isLegalPropertyKey(name))
  +        throw new IllegalArgumentException("output property not recognized: "
  +                                           + name);
  +
         m_outputFormat.setProperty(name, value);
       }
     }
  -  
  +
     /**
      * Set the output properties for the transformation.  These
      * properties will override properties set in the templates
  @@ -718,197 +775,203 @@
      */
     public void setOutputProperties(Properties oformat)
     {
  -    synchronized(m_reentryGuard) 
  +
  +    synchronized (m_reentryGuard)
       {
  -      if(null != oformat)
  +      if (null != oformat)
         {
  +
           // See if an *explicit* method was set.
  -        String method = (String)oformat.get(OutputKeys.METHOD);
  -        if(null != method)
  +        String method = (String) oformat.get(OutputKeys.METHOD);
  +
  +        if (null != method)
             m_outputFormat = new OutputProperties(method);
           else
             m_outputFormat = new OutputProperties();
         }
  -      
  -      if(null != oformat)
  +
  +      if (null != oformat)
         {
           m_outputFormat.copyFrom(oformat);
         }
  +
         // copyFrom does not set properties that have been already set, so 
         // this must be called after, which is a bit in the reverse from 
         // what one might think.
         m_outputFormat.copyFrom(m_stylesheetRoot.getOutputProperties());
       }
     }
  -  
  +
     /**
      * Get a copy of the output properties for the transformation.  These
      * properties will override properties set in the templates
      * with xsl:output.
  -   * 
  -   * <p>Note that mutation of the Properties object returned will not 
  +   *
  +   * <p>Note that mutation of the Properties object returned will not
      * effect the properties that the transformation contains.</p>
      *
      * @returns A copy of the set of output properties in effect
      * for the next transformation.
  +   *
  +   * NEEDSDOC ($objectName$) @return
      */
     public Properties getOutputProperties()
  -  {    
  -    return (Properties)getOutputFormat().getProperties().clone();  
  +  {
  +    return (Properties) getOutputFormat().getProperties().clone();
     }
   
     // %REVIEW% OK to delete?  Who needs this?
  -//  /**
  -//   * <meta name="usage" content="internal"/>
  -//   * Process the an input source to a DOM node.  FOR INTERNAL USE ONLY.
  -//   * 
  -//   * @param xmlSource  The input for the source tree.
  -//   *
  -//   * @return The Node result of the parse, never null.
  -//   *
  -//   * @throws TransformerException
  -//   */
  -//  public Node parseToNode(Source source) throws TransformerException
  -//  {
  -//    if(source instanceof DOMSource)
  -//      return ((DOMSource)source).getNode();
  -//    
  -//    InputSource xmlSource = SAXSource.sourceToInputSource(source);
  -//    if(null == xmlSource)
  -//    {
  -//      throw new TransformerException("Can't transform a Source of type "+
  -//        source.getClass().getName()+"!");
  -//    }
  -//
  -//    // Duplicate code from above... but slightly different.  
  -//    // TODO: Work on this...
  -//    if (null != xmlSource.getSystemId())
  -//      m_urlOfSource = xmlSource.getSystemId();
  -//
  -//    Node doc = null;
  -//    try
  -//    {
  -//      // Get an already set XMLReader, or create one.
  -//      XMLReader reader = null;
  -//      if(source instanceof SAXSource)
  -//        reader = ((SAXSource)source).getXMLReader();
  -//
  -//      if (null == reader)
  -//      {
  -//        // Use JAXP1.1 ( if possible )
  -//        try {
  -//          javax.xml.parsers.SAXParserFactory factory=
  -//                                                     
javax.xml.parsers.SAXParserFactory.newInstance();
  -//          factory.setNamespaceAware( true );
  -//          javax.xml.parsers.SAXParser jaxpParser=
  -//                                                 factory.newSAXParser();
  -//          reader=jaxpParser.getXMLReader();
  -//          
  -//        } catch( javax.xml.parsers.ParserConfigurationException ex ) {
  -//          throw new org.xml.sax.SAXException( ex );
  -//        } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
  -//            throw new org.xml.sax.SAXException( ex1.toString() );
  -//        } catch( NoSuchMethodError ex2 ) {
  -//        }
  -//        catch (AbstractMethodError ame){}
  -//      }
  -//
  -//      if (null == reader)
  -//      {
  -//        reader = XMLReaderFactory.createXMLReader();
  -//      }
  -//
  -//      try
  -//      {
  -//        reader.setFeature("http://xml.org/sax/features/namespace-prefixes";,
  -//                          true);
  -//        reader.setFeature(
  -//                          
"http://apache.org/xml/features/validation/dynamic";, true);
  -//      }
  -//      catch (org.xml.sax.SAXException se)
  -//      {
  -//
  -//        // What can we do?
  -//        // TODO: User diagnostics.
  -//      }
  -//
  -//      // TODO: Handle Xerces DOM parser.
  -//      // Get the input content handler, which will handle the 
  -//      // parse events and create the source tree.
  -//      ContentHandler inputHandler = getInputContentHandler();
  -//      Class inputHandlerClass = ((Object) inputHandler).getClass();
  -//
  -//      inputHandler = (ContentHandler) inputHandlerClass.newInstance();
  -//
  -//      reader.setContentHandler(inputHandler);
  -//      if(inputHandler instanceof org.xml.sax.DTDHandler)
  -//        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
  -//      try
  -//      {
  -//        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  -//          
reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
  -//                             inputHandler);
  -//        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  -//          
reader.setProperty("http://xml.org/sax/properties/declaration-handler";,
  -//                             inputHandler);
  -//      }
  -//      catch(SAXNotRecognizedException snre){}
  -//      try
  -//      {
  -//        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  -//          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler";,
  -//                             inputHandler);
  -//        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  -//          reader.setProperty("http://xml.org/sax/handlers/DeclHandler";,
  -//                             inputHandler);
  -//      }
  -//      catch(org.xml.sax.SAXNotRecognizedException snre)
  -//      {
  -//      }
  -//      getXPathContext().setPrimaryReader(reader);
  -//
  -//      // ...and of course I need a standard way to get a node...
  -//      if (inputHandler instanceof org.apache.xalan.stree.SourceTreeHandler)
  -//      {
  -//
  -//        // Kick off the parse.  When the ContentHandler gets 
  -//        // the startDocument event, it will call transformNode( node ).
  -//        reader.parse(xmlSource);
  -//
  -//        doc =
  -//             ((org.apache.xalan.stree.SourceTreeHandler) 
inputHandler).getRoot();
  -//      }
  -//
  -//    }
  -//    catch (java.lang.IllegalAccessException iae)
  -//    {
  -//      throw new TransformerException(iae);
  -//    }
  -//    catch (InstantiationException ie)
  -//    {
  -//      throw new TransformerException(ie);
  -//    }
  -//    catch(org.xml.sax.SAXException se)
  -//    {
  -//      throw new TransformerException(se);
  -//    }
  -//    catch (IOException ioe)
  -//    {
  -//      throw new TransformerException(ioe);
  -//    }
  -//
  -//
  -//    return doc;
  -//  }
  +  //  /**
  +  //   * <meta name="usage" content="internal"/>
  +  //   * Process the an input source to a DOM node.  FOR INTERNAL USE ONLY.
  +  //   * 
  +  //   * @param xmlSource  The input for the source tree.
  +  //   *
  +  //   * @return The Node result of the parse, never null.
  +  //   *
  +  //   * @throws TransformerException
  +  //   */
  +  //  public Node parseToNode(Source source) throws TransformerException
  +  //  {
  +  //    if(source instanceof DOMSource)
  +  //      return ((DOMSource)source).getNode();
  +  //    
  +  //    InputSource xmlSource = SAXSource.sourceToInputSource(source);
  +  //    if(null == xmlSource)
  +  //    {
  +  //      throw new TransformerException("Can't transform a Source of type "+
  +  //        source.getClass().getName()+"!");
  +  //    }
  +  //
  +  //    // Duplicate code from above... but slightly different.  
  +  //    // TODO: Work on this...
  +  //    if (null != xmlSource.getSystemId())
  +  //      m_urlOfSource = xmlSource.getSystemId();
  +  //
  +  //    Node doc = null;
  +  //    try
  +  //    {
  +  //      // Get an already set XMLReader, or create one.
  +  //      XMLReader reader = null;
  +  //      if(source instanceof SAXSource)
  +  //        reader = ((SAXSource)source).getXMLReader();
  +  //
  +  //      if (null == reader)
  +  //      {
  +  //        // Use JAXP1.1 ( if possible )
  +  //        try {
  +  //          javax.xml.parsers.SAXParserFactory factory=
  +  //                                                     
javax.xml.parsers.SAXParserFactory.newInstance();
  +  //          factory.setNamespaceAware( true );
  +  //          javax.xml.parsers.SAXParser jaxpParser=
  +  //                                                 factory.newSAXParser();
  +  //          reader=jaxpParser.getXMLReader();
  +  //          
  +  //        } catch( javax.xml.parsers.ParserConfigurationException ex ) {
  +  //          throw new org.xml.sax.SAXException( ex );
  +  //        } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) {
  +  //            throw new org.xml.sax.SAXException( ex1.toString() );
  +  //        } catch( NoSuchMethodError ex2 ) {
  +  //        }
  +  //        catch (AbstractMethodError ame){}
  +  //      }
  +  //
  +  //      if (null == reader)
  +  //      {
  +  //        reader = XMLReaderFactory.createXMLReader();
  +  //      }
  +  //
  +  //      try
  +  //      {
  +  //        
reader.setFeature("http://xml.org/sax/features/namespace-prefixes";,
  +  //                          true);
  +  //        reader.setFeature(
  +  //                          
"http://apache.org/xml/features/validation/dynamic";, true);
  +  //      }
  +  //      catch (org.xml.sax.SAXException se)
  +  //      {
  +  //
  +  //        // What can we do?
  +  //        // TODO: User diagnostics.
  +  //      }
  +  //
  +  //      // TODO: Handle Xerces DOM parser.
  +  //      // Get the input content handler, which will handle the 
  +  //      // parse events and create the source tree.
  +  //      ContentHandler inputHandler = getInputContentHandler();
  +  //      Class inputHandlerClass = ((Object) inputHandler).getClass();
  +  //
  +  //      inputHandler = (ContentHandler) inputHandlerClass.newInstance();
  +  //
  +  //      reader.setContentHandler(inputHandler);
  +  //      if(inputHandler instanceof org.xml.sax.DTDHandler)
  +  //        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
  +  //      try
  +  //      {
  +  //        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  +  //          
reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
  +  //                             inputHandler);
  +  //        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  +  //          
reader.setProperty("http://xml.org/sax/properties/declaration-handler";,
  +  //                             inputHandler);
  +  //      }
  +  //      catch(SAXNotRecognizedException snre){}
  +  //      try
  +  //      {
  +  //        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  +  //          
reader.setProperty("http://xml.org/sax/handlers/LexicalHandler";,
  +  //                             inputHandler);
  +  //        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  +  //          reader.setProperty("http://xml.org/sax/handlers/DeclHandler";,
  +  //                             inputHandler);
  +  //      }
  +  //      catch(org.xml.sax.SAXNotRecognizedException snre)
  +  //      {
  +  //      }
  +  //      getXPathContext().setPrimaryReader(reader);
  +  //
  +  //      // ...and of course I need a standard way to get a node...
  +  //      if (inputHandler instanceof 
org.apache.xalan.stree.SourceTreeHandler)
  +  //      {
  +  //
  +  //        // Kick off the parse.  When the ContentHandler gets 
  +  //        // the startDocument event, it will call transformNode( node ).
  +  //        reader.parse(xmlSource);
  +  //
  +  //        doc =
  +  //             ((org.apache.xalan.stree.SourceTreeHandler) 
inputHandler).getRoot();
  +  //      }
  +  //
  +  //    }
  +  //    catch (java.lang.IllegalAccessException iae)
  +  //    {
  +  //      throw new TransformerException(iae);
  +  //    }
  +  //    catch (InstantiationException ie)
  +  //    {
  +  //      throw new TransformerException(ie);
  +  //    }
  +  //    catch(org.xml.sax.SAXException se)
  +  //    {
  +  //      throw new TransformerException(se);
  +  //    }
  +  //    catch (IOException ioe)
  +  //    {
  +  //      throw new TransformerException(ioe);
  +  //    }
  +  //
  +  //
  +  //    return doc;
  +  //  }
   
     /**
  -   * Create a result ContentHandler from a Result object, based 
  +   * Create a result ContentHandler from a Result object, based
      * on the current OutputProperties.
      *
  -   * @param outputTarget Where the transform result should go, 
  +   * @param outputTarget Where the transform result should go,
      * should not be null.
      *
  -   * @return A valid ContentHandler that will create the 
  +   * @return A valid ContentHandler that will create the
      * result tree when it is fed SAX events.
      *
      * @throws TransformerException
  @@ -918,85 +981,99 @@
     {
       return createResultContentHandler(outputTarget, getOutputFormat());
     }
  -    
  +
     /**
      * Create a ContentHandler from a Result object and an OutputProperties.
      *
  -   * @param outputTarget Where the transform result should go, 
  +   * @param outputTarget Where the transform result should go,
      * should not be null.
  -   * @param format The OutputProperties object that will contain 
  +   * @param format The OutputProperties object that will contain
      * instructions on how to serialize the output.
      *
  -   * @return A valid ContentHandler that will create the 
  +   * @return A valid ContentHandler that will create the
      * result tree when it is fed SAX events.
      *
      * @throws TransformerException
      */
     public ContentHandler createResultContentHandler(
  -          Result outputTarget, OutputProperties format) throws 
TransformerException
  -  {    
  +          Result outputTarget, OutputProperties format)
  +            throws TransformerException
  +  {
  +
       ContentHandler handler = null;
  -    
  +
       // If the Result object contains a Node, then create 
       // a ContentHandler that will add nodes to the input node.
       org.w3c.dom.Node outputNode = null;
  -    if(outputTarget instanceof DOMResult)
  +
  +    if (outputTarget instanceof DOMResult)
       {
  -      outputNode = ((DOMResult)outputTarget).getNode();
  +      outputNode = ((DOMResult) outputTarget).getNode();
   
         org.w3c.dom.Document doc;
         short type;
  +
         if (null != outputNode)
         {
           type = outputNode.getNodeType();
           doc = (org.w3c.dom.Node.DOCUMENT_NODE == type)
  -                       ? (org.w3c.dom.Document) outputNode 
  -                       : outputNode.getOwnerDocument();
  +              ? (org.w3c.dom.Document) outputNode
  +              : outputNode.getOwnerDocument();
         }
         else
         {
           doc = org.apache.xpath.DOMHelper.createDocument();
           outputNode = doc;
           type = outputNode.getNodeType();
  -        ((DOMResult)outputTarget).setNode(outputNode);
  +
  +        ((DOMResult) outputTarget).setNode(outputNode);
         }
  -      
  -      handler = (org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE == type)
  -                ? new DOMBuilder(doc, (org.w3c.dom.DocumentFragment) 
outputNode)
  -                  : new DOMBuilder(doc, outputNode);
  -    }
  -    else if(outputTarget instanceof SAXResult)
  -    {
  -      handler = ((SAXResult)outputTarget).getHandler();
  -      if(null == handler)
  -        throw new IllegalArgumentException("handler can not be null for a 
SAXResult");
  +
  +      handler =
  +        (org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE == type)
  +        ? new DOMBuilder(doc, (org.w3c.dom.DocumentFragment) outputNode)
  +        : new DOMBuilder(doc, outputNode);
  +    }
  +    else if (outputTarget instanceof SAXResult)
  +    {
  +      handler = ((SAXResult) outputTarget).getHandler();
  +
  +      if (null == handler)
  +        throw new IllegalArgumentException(
  +          "handler can not be null for a SAXResult");
       }
  +
       // Otherwise, create a ContentHandler that will serialize the 
       // result tree to either a stream or a writer.
  -    else if(outputTarget instanceof StreamResult)
  +    else if (outputTarget instanceof StreamResult)
       {
  -      StreamResult sresult = (StreamResult)outputTarget;
  +      StreamResult sresult = (StreamResult) outputTarget;
         String method = format.getProperty(OutputKeys.METHOD);
   
         try
         {
  -        Serializer serializer = 
SerializerFactory.getSerializer(format.getProperties());
  +        Serializer serializer =
  +          SerializerFactory.getSerializer(format.getProperties());
   
           if (null != sresult.getWriter())
             serializer.setWriter(sresult.getWriter());
           else if (null != sresult.getOutputStream())
             serializer.setOutputStream(sresult.getOutputStream());
  -        else if(null != sresult.getSystemId())
  +        else if (null != sresult.getSystemId())
           {
             String fileURL = sresult.getSystemId();
  -          if(fileURL.startsWith("file:///"))
  +
  +          if (fileURL.startsWith("file:///"))
             {
               fileURL = fileURL.substring(8);
             }
  +
             m_outputStream = new java.io.FileOutputStream(fileURL);
  +
             serializer.setOutputStream(m_outputStream);
           }
  -        else throw new TransformerException("No output specified!");
  +        else
  +          throw new TransformerException("No output specified!");
   
           handler = serializer.asContentHandler();
   
  @@ -1013,8 +1090,9 @@
       }
       else
       {
  -      throw new TransformerException("Can't transform to a Result of type "+
  -        outputTarget.getClass().getName()+"!");
  +      throw new TransformerException("Can't transform to a Result of type "
  +                                     + outputTarget.getClass().getName()
  +                                     + "!");
       }
   
       return handler;
  @@ -1030,11 +1108,13 @@
     public void transform(Source xmlSource, Result outputTarget)
             throws TransformerException
     {
  -    synchronized(m_reentryGuard) 
  +
  +    synchronized (m_reentryGuard)
       {
         ContentHandler handler = createResultContentHandler(outputTarget);
  +
         m_outputTarget = outputTarget;
  -  
  +
         this.setContentHandler(handler);
         transform(xmlSource);
       }
  @@ -1055,6 +1135,7 @@
     {
   
       ContentHandler handler = createResultContentHandler(outputTarget);
  +
       m_outputTarget = outputTarget;
   
       this.setContentHandler(handler);
  @@ -1073,33 +1154,33 @@
      */
     public void transformNode(int node) throws TransformerException
     {
  +
       // Make sure we're not writing to the same output content handler.
  -    synchronized(m_outputContentHandler)
  +    synchronized (m_outputContentHandler)
       {
         m_hasBeenReset = false;
  -  
  +
         try
         {
           pushGlobalVars(node);
  -  
  +
           // ==========
           // Give the top-level templates a chance to pass information into 
           // the context (this is mainly for setting up tables for extensions).
           StylesheetRoot stylesheet = this.getStylesheet();
           int n = stylesheet.getGlobalImportCount();
  -  
  +
           for (int i = 0; i < n; i++)
           {
             StylesheetComposed imported = stylesheet.getGlobalImport(i);
  -  
             int includedCount = imported.getIncludeCountComposed();
  -  
  +
             for (int j = -1; j < includedCount; j++)
             {
               Stylesheet included = imported.getIncludeComposed(j);
  -  
  +
               included.runtimeInit(this);
  -  
  +
               for (ElemTemplateElement child = included.getFirstChildElem();
                       child != null; child = child.getNextSiblingElem())
               {
  @@ -1107,19 +1188,20 @@
               }
             }
           }
  -  
  +
           // ===========
           // System.out.println("Calling applyTemplateToNode - 
"+Thread.currentThread().getName());
           this.applyTemplateToNode(null, null, node);
  +
           // System.out.println("Done with applyTemplateToNode - 
"+Thread.currentThread().getName());
  -  
           if (null != m_resultTreeHandler)
           {
             m_resultTreeHandler.endDocument();
  -        }   
  +        }
         }
         catch (Exception se)
         {
  +
           // System.out.println(Thread.currentThread().getName()+" threw an 
exception! "
           //                   +se.getMessage());
           // If an exception was thrown, we need to make sure that any waiting 
  @@ -1131,8 +1213,9 @@
             {
               m_resultTreeHandler.endDocument();
             }
  -          catch(Exception e){}
  +          catch (Exception e){}
           }
  +
           throw new TransformerException(se.getMessage(), se);
         }
         finally
  @@ -1141,10 +1224,10 @@
         }
       }
     }
  -  
  +
     /**
      * Get a SAX2 ContentHandler for the input.
  -   * 
  +   *
      * @return A valid ContentHandler, which should never be null, as
      * long as getFeature("http://xml.org/trax/features/sax/input";)
      * returns true.
  @@ -1156,10 +1239,10 @@
   
     /**
      * Get a SAX2 ContentHandler for the input.
  -   * 
  -   * @param doDocFrag true if a DocumentFragment should be created as 
  +   *
  +   * @param doDocFrag true if a DocumentFragment should be created as
      * the root, rather than a Document.
  -   * 
  +   *
      * @return A valid ContentHandler, which should never be null, as
      * long as getFeature("http://xml.org/trax/features/sax/input";)
      * returns true.
  @@ -1169,9 +1252,11 @@
   
       if (null == m_inputContentHandler)
       {
  +
         //      if(null == m_urlOfSource && null != m_stylesheetRoot)
         //        m_urlOfSource = m_stylesheetRoot.getBaseIdentifier();
  -      m_inputContentHandler = new TransformerHandlerImpl(this, doDocFrag, 
m_urlOfSource);
  +      m_inputContentHandler = new TransformerHandlerImpl(this, doDocFrag,
  +              m_urlOfSource);
       }
   
       return m_inputContentHandler;
  @@ -1212,7 +1297,7 @@
      * properties will override properties set in the templates
      * with xsl:output.
      *
  -   * @param oformat A valid OutputProperties object (which will 
  +   * @param oformat A valid OutputProperties object (which will
      * not be mutated), or null.
      */
     public void setOutputFormat(OutputProperties oformat)
  @@ -1223,7 +1308,7 @@
     /**
      * Get the output properties used for the transformation.
      *
  -   * @return the output format that was set by the user, 
  +   * @return the output format that was set by the user,
      * otherwise the output format from the stylesheet.
      */
     public OutputProperties getOutputFormat()
  @@ -1232,8 +1317,8 @@
       // Get the output format that was set by the user, otherwise get the 
       // output format from the stylesheet.
       OutputProperties format = (null == m_outputFormat)
  -                          ? getStylesheet().getOutputComposed()
  -                          : m_outputFormat;
  +                              ? getStylesheet().getOutputComposed()
  +                              : m_outputFormat;
   
       return format;
     }
  @@ -1241,7 +1326,7 @@
     /**
      * <meta name="usage" content="internal"/>
      * Get the current serializer in use, which may well not
  -   * be the main serializer (for instance, this may well be 
  +   * be the main serializer (for instance, this may well be
      * a text serializer for string creation from templates).
      *
      * @return The current serializer, or null if there is none.
  @@ -1264,7 +1349,7 @@
   
     /**
      * Set a parameter for the templates.
  -   * 
  +   *
      * @param name The name of the parameter.
      * @param namespace The namespace of the parameter.
      * @param value The value object.  This can be any valid Java object
  @@ -1281,9 +1366,10 @@
   
       varstack.pushOrReplaceParameter(qname, xobject);
     }
  -  
  +
  +  /** NEEDSDOC Field m_userParams          */
     Vector m_userParams;
  -  
  +
     /**
      * Set a parameter for the transformation.
      *
  @@ -1296,16 +1382,21 @@
      */
     public void setParameter(String name, Object value)
     {
  +
       StringTokenizer tokenizer = new StringTokenizer(name, "{}", false);
  +
       try
       {
  +
         // The first string might be the namespace, or it might be 
         // the local name, if the namespace is null.
         String s1 = tokenizer.nextToken();
         String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
  -      if(null == m_userParams)
  +
  +      if (null == m_userParams)
           m_userParams = new Vector();
  -      if(null == s2)
  +
  +      if (null == s2)
         {
           replaceOrPushUserParam(new QName(s1), new XObject(value));
           setParameter(s1, null, value);
  @@ -1315,71 +1406,90 @@
           replaceOrPushUserParam(new QName(s1, s2), new XObject(value));
           setParameter(s2, s1, value);
         }
  -      
       }
  -    catch(java.util.NoSuchElementException  nsee)
  +    catch (java.util.NoSuchElementException nsee)
       {
  +
         // Should throw some sort of an error.
       }
     }
  -  
  +
  +  /**
  +   * NEEDSDOC Method replaceOrPushUserParam 
  +   *
  +   *
  +   * NEEDSDOC @param qname
  +   * NEEDSDOC @param xval
  +   */
     private void replaceOrPushUserParam(QName qname, XObject xval)
     {
  -      int n = m_userParams.size();
  -      for(int i = n-1; i >= 0; i--)
  +
  +    int n = m_userParams.size();
  +
  +    for (int i = n - 1; i >= 0; i--)
  +    {
  +      Arg arg = (Arg) m_userParams.elementAt(i);
  +
  +      if (arg.getQName().equals(qname))
         {
  -        Arg arg = (Arg)m_userParams.elementAt(i);
  -        if(arg.getQName().equals(qname))
  -        {
  -          m_userParams.setElementAt(new Arg(qname, xval, true), i);
  -          return;
  -        }
  +        m_userParams.setElementAt(new Arg(qname, xval, true), i);
  +
  +        return;
         }
  -      m_userParams.addElement(new Arg(qname, xval, true));
  +    }
  +
  +    m_userParams.addElement(new Arg(qname, xval, true));
     }
  -  
  +
     /**
  -   * Get a parameter that was explicitly set with setParameter 
  +   * Get a parameter that was explicitly set with setParameter
      * or setParameters.
  +   *
      *
  -   * @return A parameter that has been set with setParameter 
  +   * NEEDSDOC @param name
  +   * @return A parameter that has been set with setParameter
      * or setParameters,
  -   * *not* all the xsl:params on the stylesheet (which require 
  +   * *not* all the xsl:params on the stylesheet (which require
      * a transformation Source to be evaluated).
      */
     public Object getParameter(String name)
     {
  +
       try
       {
  +
         // VariableStack varstack = getXPathContext().getVarStack();
         // The first string might be the namespace, or it might be 
         // the local name, if the namespace is null.
         QName qname = QName.getQNameFromString(name);
   
  -      if(null == m_userParams)
  +      if (null == m_userParams)
           return null;
  +
         int n = m_userParams.size();
  -      for(int i = n-1; i >= 0; i--)
  +
  +      for (int i = n - 1; i >= 0; i--)
         {
  -        Arg arg = (Arg)m_userParams.elementAt(i);
  -        if(arg.getQName().equals(qname))
  +        Arg arg = (Arg) m_userParams.elementAt(i);
  +
  +        if (arg.getQName().equals(qname))
           {
             return arg.getVal().object();
           }
         }
  +
         return null;
       }
  -    catch(java.util.NoSuchElementException  nsee)
  +    catch (java.util.NoSuchElementException nsee)
       {
  +
         // Should throw some sort of an error.
         return null;
  -    }  
  +    }
     }
  -  
  -  
   
     /**
  -   * Set a bag of parameters for the transformation. Note that 
  +   * Set a bag of parameters for the transformation. Note that
      * these will not be additive, they will replace the existing
      * set of parameters.
      *
  @@ -1389,28 +1499,37 @@
      * -- it's up to the processor to provide the proper
      * coersion to the object, or simply pass it on for use
      * in extensions.
  +   *
  +   * NEEDSDOC @param params
      */
     public void setParameters(Properties params)
     {
  +
       clearParameters();
  +
       Enumeration names = params.propertyNames();
  -    while(names.hasMoreElements())
  +
  +    while (names.hasMoreElements())
       {
  -      String name = params.getProperty((String)names.nextElement());
  +      String name = params.getProperty((String) names.nextElement());
         StringTokenizer tokenizer = new StringTokenizer(name, "{}", false);
  +
         try
         {
  +
           // The first string might be the namespace, or it might be 
           // the local name, if the namespace is null.
           String s1 = tokenizer.nextToken();
           String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
  -        if(null == s2)
  +
  +        if (null == s2)
             setParameter(s1, null, params.getProperty(name));
           else
             setParameter(s2, s1, params.getProperty(name));
         }
  -      catch(java.util.NoSuchElementException  nsee)
  +      catch (java.util.NoSuchElementException nsee)
         {
  +
           // Should throw some sort of an error.
         }
       }
  @@ -1421,10 +1540,13 @@
      */
     public void clearParameters()
     {
  -    synchronized(m_reentryGuard) 
  +
  +    synchronized (m_reentryGuard)
       {
         VariableStack varstack = new VariableStack();
  +
         getXPathContext().setVarStack(varstack);
  +
         m_userParams = null;
       }
     }
  @@ -1452,14 +1574,16 @@
       // of the current stack frame.
       VariableStack vars = xctxt.getVarStack();
       int n = xslCallTemplateElement.getParamElemCount();
  -    
       int paramDeclareContext = vars.getSearchStartOrTop();
  +
       vars.pushContextMarker();
  +
       int paramReferenceContext = -1;
   
       for (int i = 0; i < n; i++)
       {
         vars.setSearchStart(paramDeclareContext);
  +
         ElemWithParam xslParamElement = xslCallTemplateElement.getParamElem(i);
   
         // Get the argument value as either an expression or 
  @@ -1470,6 +1594,7 @@
         if (null != param)
         {
           int sourceNode = xctxt.getCurrentNode();
  +
           var = param.execute(getXPathContext(), sourceNode, xslParamElement);
         }
         else if (null == xslParamElement.getFirstChildElem())
  @@ -1478,10 +1603,10 @@
         }
         else
         {
  +        int sourceNode = xctxt.getCurrentNode();
   
  -         int sourceNode = xctxt.getCurrentNode();
  -       // Use result tree fragment
  -       // %REVIEW% Make sure current node is pushed.
  +        // Use result tree fragment
  +        // %REVIEW% Make sure current node is pushed.
           int df = transformToRTF(xslParamElement);
   
           var = new XRTreeFrag(df, xctxt);
  @@ -1489,21 +1614,22 @@
   
         vars.setSearchStart(paramReferenceContext);
         vars.pushVariableArg(new Arg(xslParamElement.getName(), var, true));
  -//      m_newVars.addElement(new Arg(xslParamElement.getName(), var, true));
  +
  +      //      m_newVars.addElement(new Arg(xslParamElement.getName(), var, 
true));
       }
   
  -//    int nNew = m_newVars.size();
  -//
  -//    if (nNew > 0)
  -//    {
  -//      for (int i = 0; i < nNew; i++)
  -//      {
  -//        vars.pushVariableArg((Arg) m_newVars.elementAt(i));
  -//      }
  -//
  -//      // Dragons check: make sure this is nulling the refs.
  -//      m_newVars.removeAllElements();
  -//    }
  +    //    int nNew = m_newVars.size();
  +    //
  +    //    if (nNew > 0)
  +    //    {
  +    //      for (int i = 0; i < nNew; i++)
  +    //      {
  +    //        vars.pushVariableArg((Arg) m_newVars.elementAt(i));
  +    //      }
  +    //
  +    //      // Dragons check: make sure this is nulling the refs.
  +    //      m_newVars.removeAllElements();
  +    //    }
     }  // end pushParams method
   
     /**
  @@ -1533,48 +1659,53 @@
       // in scope, when really only the current stylesheet's 
       // global variables should be in scope.  Have to think on 
       // this more...
  -                XObject xobj;
  +    XObject xobj;
       XPathContext xctxt = getXPathContext();
       VariableStack vs = xctxt.getVarStack();
       StylesheetRoot sr = getStylesheet();
       Vector vars = sr.getVariablesAndParamsComposed();
  -
       int startGlobals = vs.size();
       int i = vars.size();
  +
       while (--i >= 0)
       {
         ElemVariable v = (ElemVariable) vars.elementAt(i);
  -
         Arg previouslyDeclared = vs.getDeclaredVariable(v.getName());
  +
         if (null != previouslyDeclared)
         {
  -        if ( (v instanceof ElemParam) && 
previouslyDeclared.isFromWithParam() )
  +        if ((v instanceof ElemParam) && previouslyDeclared.isFromWithParam())
           {
             previouslyDeclared.setIsVisible(true);
           }
  -                                else
  +        else
           {
  -          xobj = new XUnresolvedVariable(v, contextNode, 
  -                             this, vs.getSearchStartOrTop(), 0, true);
  +          xobj = new XUnresolvedVariable(v, contextNode, this,
  +                                         vs.getSearchStartOrTop(), 0, true);
  +
             previouslyDeclared.setVal(xobj);
           }
  +
           continue;
         }
   
         // XObject xobj = v.getValue(this, contextNode);
  -      xobj = new XUnresolvedVariable(v, contextNode, 
  -                             this, vs.getSearchStartOrTop(), 0, true);
  +      xobj = new XUnresolvedVariable(v, contextNode, this,
  +                                     vs.getSearchStartOrTop(), 0, true);
   
         vs.pushVariable(v.getName(), xobj);
         vs.markGlobalStackFrame();
       }
  +
       vs.markGlobalStackFrame();
  -    
  +
       int endGlobals = vs.size();
  -    for(i = startGlobals; i < endGlobals; i++)
  +
  +    for (i = startGlobals; i < endGlobals; i++)
       {
  -      Arg arg = (Arg)vs.elementAt(i);
  -      XUnresolvedVariable uv = (XUnresolvedVariable)arg.getVal();
  +      Arg arg = (Arg) vs.elementAt(i);
  +      XUnresolvedVariable uv = (XUnresolvedVariable) arg.getVal();
  +
         uv.setVarStackPos(endGlobals);
       }
   
  @@ -1589,16 +1720,17 @@
      */
     public void setURIResolver(URIResolver resolver)
     {
  -    synchronized(m_reentryGuard) 
  +
  +    synchronized (m_reentryGuard)
       {
         getXPathContext().getSourceTreeManager().setURIResolver(resolver);
       }
     }
  -  
  +
     /**
      * Get an object that will be used to resolve URIs used in
      * document(), etc.
  -   * 
  +   *
      * @return An object that implements the URIResolver interface,
      * or null.
      */
  @@ -1607,27 +1739,29 @@
       return getXPathContext().getSourceTreeManager().getURIResolver();
     }
   
  -
     // ======== End Transformer Implementation ========  
   
     /**
      * Set the content event handler.
      *
      * @param resolver The new content handler.
  +   *
  +   * NEEDSDOC @param handler
      * @throws java.lang.NullPointerException If the handler
      *            is null.
      * @see org.xml.sax.XMLReader#setContentHandler
      */
  -  public void setContentHandler (ContentHandler handler)
  +  public void setContentHandler(ContentHandler handler)
     {
  -    if (handler == null) 
  +
  +    if (handler == null)
       {
         throw new NullPointerException("Null content handler");
  -    } 
  -    else 
  +    }
  +    else
       {
         m_outputContentHandler = handler;
  -      
  +
         if (null == m_resultTreeHandler)
           m_resultTreeHandler = new ResultTreeHandler(this, handler);
         else
  @@ -1635,14 +1769,13 @@
       }
     }
   
  -
     /**
      * Get the content event handler.
      *
      * @return The current content handler, or null if none was set.
      * @see org.xml.sax.XMLReader#getContentHandler
      */
  -  public ContentHandler getContentHandler ()
  +  public ContentHandler getContentHandler()
     {
       return m_outputContentHandler;
     }
  @@ -1658,12 +1791,11 @@
      *
      * @throws TransformerException
      */
  -  public int transformToRTF(
  -          ElemTemplateElement templateParent)
  -            throws TransformerException
  +  public int transformToRTF(ElemTemplateElement templateParent)
  +          throws TransformerException
     {
  +
       XPathContext xctxt = getXPathContext();
  -    
       DTM dtmFrag = xctxt.getDTM(null, true, this, false, false);
       ContentHandler rtfHandler = dtmFrag.getContentHandler();
   
  @@ -1675,43 +1807,44 @@
   
       // And make a new handler for the RTF.
       m_resultTreeHandler = new ResultTreeHandler(this, rtfHandler);
  +
       ResultTreeHandler rth = m_resultTreeHandler;
   
       try
       {
         rth.startDocument();
  -  
  +
         try
         {
  +
           // Do the transformation of the child elements.
           executeChildTemplates(templateParent, true);
  -        
  +
           // Make sure everything is flushed!
           rth.flushPending();
         }
         finally
  -      {      
  +      {
           rth.endDocument();
         }
       }
  -    catch(org.xml.sax.SAXException se)
  +    catch (org.xml.sax.SAXException se)
       {
         throw new TransformerException(se);
       }
  -
       finally
       {
  +
         // Restore the previous result tree handler.
         this.m_resultTreeHandler = savedRTreeHandler;
       }
  -    
  +
       return resultFragment;
     }
   
  -
     /**
      * <meta name="usage" content="internal"/>
  -   * Get the StringWriter pool, so that StringWriter 
  +   * Get the StringWriter pool, so that StringWriter
      * objects may be reused.
      *
      * @return The string writer pool, not null.
  @@ -1726,20 +1859,27 @@
      * Take the contents of a template element, process it, and
      * convert it to a string.
      *
  -   * @param elem The parent element whose children will be output 
  +   * @param elem The parent element whose children will be output
      * as a string.
      * @param transformer The XSLT transformer instance.
      * @param sourceNode The current source node context.
      * @param mode The current xslt mode.
  -   * 
  +   *
      * @return The stringized result of executing the elements children.
  -   * 
  +   *
      * @throws TransformerException
      */
  -  public String transformToString(
  -          ElemTemplateElement elem)
  -            throws TransformerException
  +  public String transformToString(ElemTemplateElement elem)
  +          throws TransformerException
     {
  +    ElemTemplateElement firstChild = elem.getFirstChildElem();
  +    if(null == firstChild)
  +      return "";
  +    if(firstChild.getXSLToken() == Constants.ELEMNAME_TEXTLITERALRESULT && 
  +       firstChild.getNextSiblingElem() == null)
  +    {
  +      return ((ElemTextLiteral)firstChild).getNodeValue();
  +    }
   
       // Save the current result tree handler.
       ResultTreeHandler savedRTreeHandler = this.m_resultTreeHandler;
  @@ -1757,7 +1897,8 @@
       {
         if (null == serializer)
         {
  -        serializer = 
SerializerFactory.getSerializer(m_textformat.getProperties());
  +        serializer =
  +          SerializerFactory.getSerializer(m_textformat.getProperties());
   
           m_resultTreeHandler.setSerializer(serializer);
           serializer.setWriter(sw);
  @@ -1768,6 +1909,7 @@
         }
         else
         {
  +
           // Leave Commented.  -sb
           // serializer.setWriter(sw);
           // serializer.setOutputFormat(m_textformat);
  @@ -1792,7 +1934,7 @@
   
         result = sw.toString();
       }
  -    catch(org.xml.sax.SAXException se)
  +    catch (org.xml.sax.SAXException se)
       {
         throw new TransformerException(se);
       }
  @@ -1831,10 +1973,11 @@
      */
     public boolean applyTemplateToNode(ElemTemplateElement xslInstruction,  // 
xsl:apply-templates or xsl:for-each
                                        ElemTemplateElement template, int child)
  -                                                     throws 
TransformerException
  +                                             throws TransformerException
     {
  +
       DTM dtm = m_xcontext.getDTM(child);
  -    short nodeType =  dtm.getNodeType(child);
  +    short nodeType = dtm.getNodeType(child);
       boolean isDefaultTextRule = false;
   
       if (null == template)
  @@ -1847,7 +1990,8 @@
   
         if (isApplyImports)
         {
  -        maxImportLevel = 
xslInstruction.getStylesheetComposed().getImportCountComposed() - 1;
  +        maxImportLevel =
  +          xslInstruction.getStylesheetComposed().getImportCountComposed() - 
1;
         }
         else
         {
  @@ -1860,31 +2004,32 @@
         // that we should find any template.  This is because a value of -1 for
         // maxImportLevel has a special meaning.  But we don't want that.
         // We want to match -no- templates. See bugzilla bug 1170.
  -
         if (isApplyImports && (maxImportLevel == -1))
         {
           template = null;
  +      }
  +      else
  +      {
  +
  +        // Find the XSL template that is the best match for the 
  +        // element.        
  +        XPathContext xctxt = getXPathContext();
  +        PrefixResolver savedPrefixResolver = xctxt.getNamespaceContext();
  +
  +        try
  +        {
  +          xctxt.setNamespaceContext(xslInstruction);
  +
  +          QName mode = this.getMode();
  +
  +          template = m_stylesheetRoot.getTemplateComposed(xctxt, child, mode,
  +                  maxImportLevel, m_quietConflictWarnings, dtm);
  +        }
  +        finally
  +        {
  +          xctxt.setNamespaceContext(savedPrefixResolver);
  +        }
         }
  -                        else
  -                        {
  -                                // Find the XSL template that is the best 
match for the 
  -                                // element.        
  -                                XPathContext xctxt = getXPathContext();
  -                                PrefixResolver savedPrefixResolver = 
xctxt.getNamespaceContext();
  -
  -                                try
  -                                {
  -                                        
xctxt.setNamespaceContext(xslInstruction);
  -
  -                                        QName mode = this.getMode();
  -                                        template = 
m_stylesheetRoot.getTemplateComposed(xctxt, child, mode, maxImportLevel,
  -                                                                             
                                                                                
                                                                           
m_quietConflictWarnings);
  -                                }
  -                                finally
  -                                {
  -                                        
xctxt.setNamespaceContext(savedPrefixResolver);
  -                                }
  -                        }
   
         // If that didn't locate a node, fall back to a default template rule.
         // See http://www.w3.org/TR/xslt#built-in-rule.
  @@ -1939,9 +2084,8 @@
   
           // Fire a trace event for the template.
           // 
  -//        if (TransformerImpl.S_DEBUG)
  -//          getTraceManager().fireTraceEvent(child, mode, template);
  -
  +        //        if (TransformerImpl.S_DEBUG)
  +        //          getTraceManager().fireTraceEvent(child, mode, template);
           // And execute the child templates.
           // 9/11/00: If template has been compiled, hand off to it
           // since much (most? all?) of the processing has been inlined.
  @@ -1951,13 +2095,11 @@
           // compiled obviously has to run its own code. It's
           // also unclear that "execute" is really the right name for
           // that entry point.)
  -
           m_xcontext.setSAXLocator(template);
  -
           executeChildTemplates(template, true);
         }
       }
  -    catch(org.xml.sax.SAXException se)
  +    catch (org.xml.sax.SAXException se)
       {
         throw new TransformerException(se);
       }
  @@ -1970,38 +2112,39 @@
   
       return true;
     }
  -  
  +
     /**
      * <meta name="usage" content="advanced"/>
  -   * Execute each of the children of a template element.  This method 
  +   * Execute each of the children of a template element.  This method
      * is only for extension use.
      *
  -   * @param elem The ElemTemplateElement that contains the children 
  +   * @param elem The ElemTemplateElement that contains the children
      * that should execute.
      * @param sourceNode The current context node.
  +   * NEEDSDOC @param context
      * @param mode The current mode.
  -   * @param handler The ContentHandler to where the result events 
  +   * @param handler The ContentHandler to where the result events
      * should be fed.
  -   * 
  +   *
      * @throws TransformerException
      */
     public void executeChildTemplates(
  -          ElemTemplateElement elem, org.w3c.dom.Node context, QName mode, 
  -           ContentHandler handler)
  +          ElemTemplateElement elem, org.w3c.dom.Node context, QName mode, 
ContentHandler handler)
               throws TransformerException
     {
  +
       XPathContext xctxt = getXPathContext();
  +
       try
       {
  -      xctxt.pushCurrentNode(
  -           xctxt.getDTMHandleFromNode(context));
  -             
  -      executeChildTemplates( elem, handler);
  +      xctxt.pushCurrentNode(xctxt.getDTMHandleFromNode(context));
  +      executeChildTemplates(elem, handler);
       }
       finally
       {
         xctxt.popCurrentNode();
  -      if(null != mode)
  +
  +      if (null != mode)
           popMode();
       }
     }
  @@ -2010,11 +2153,11 @@
      * <meta name="usage" content="advanced"/>
      * Execute each of the children of a template element.
      *
  -   * @param elem The ElemTemplateElement that contains the children 
  +   * @param elem The ElemTemplateElement that contains the children
      * that should execute.
  -   * @param handler The ContentHandler to where the result events 
  +   * @param handler The ContentHandler to where the result events
      * should be fed.
  -   * 
  +   *
      * @throws TransformerException
      */
     public void executeChildTemplates(
  @@ -2023,7 +2166,7 @@
     {
   
       ResultTreeHandler rth = this.getResultTreeHandler();
  -    
  +
       // These may well not be the same!  In this case when calling 
       // the Redirect extension, it has already set the ContentHandler
       // in the Transformer.
  @@ -2034,17 +2177,18 @@
       {
         getResultTreeHandler().flushPending();
         this.setContentHandler(handler);
  +
         // %REVIEW% Make sure current node is being pushed.
         executeChildTemplates(elem, true);
       }
  -    catch(org.xml.sax.SAXException se)
  +    catch (org.xml.sax.SAXException se)
       {
         throw new TransformerException(se);
       }
       finally
       {
         this.setContentHandler(savedHandler);
  -      
  +
         // This fixes a bug where the ResultTreeHandler's ContentHandler
         // was being reset to the wrong ContentHandler.
         rth.setContentHandler(savedRTHHandler);
  @@ -2057,12 +2201,12 @@
      *
      * @param transformer The XSLT transformer instance.
      *
  -   * @param elem The ElemTemplateElement that contains the children 
  +   * @param elem The ElemTemplateElement that contains the children
      * that should execute.
      * @param sourceNode The current context node.
      * @param mode The current mode.
      * @param shouldAddAttrs true if xsl:attributes should be executed.
  -   * 
  +   *
      * @throws TransformerException
      */
     public void executeChildTemplates(
  @@ -2076,8 +2220,24 @@
       if (null == t)
         return;
         
  +    if(t.getXSLToken() == Constants.ELEMNAME_TEXTLITERALRESULT && 
  +       t.getNextSiblingElem() == null)
  +    {
  +      char[] chars = ((ElemTextLiteral)t).getChars();
  +      try
  +      {
  +        // %TBD% Have to push stuff on for tooling...
  +        m_resultTreeHandler.characters(chars, 0, chars.length);
  +      }
  +      catch(SAXException se)
  +      {
  +        throw new TransformerException(se);
  +      }
  +      return;
  +    }
  +
       XPathContext xctxt = getXPathContext();
  -    
  +
       // Check for infinite loops if we have to.
       boolean check = (m_stackGuard.m_recursionLimit > -1);
   
  @@ -2098,13 +2258,15 @@
   
         // Loop through the children of the template, calling execute on 
         // each of them.
  -      for (; t != null;
  -              t = t.getNextSiblingElem())
  +      for (; t != null; t = t.getNextSiblingElem())
         {
  -        if(!shouldAddAttrs && t.getXSLToken() == 
Constants.ELEMNAME_ATTRIBUTE)
  +        if (!shouldAddAttrs
  +                && t.getXSLToken() == Constants.ELEMNAME_ATTRIBUTE)
             continue;
  +
           xctxt.setSAXLocator(t);
  -        m_currentTemplateElements.setElementAt(t, 
m_currentTemplateElements.size()-1);
  +        m_currentTemplateElements.setElementAt(
  +          t, m_currentTemplateElements.size() - 1);
           t.execute(this);
         }
       }
  @@ -2128,16 +2290,15 @@
      * Note: Should this go into ElemForEach?
      *
      * @param foreach Valid ElemForEach element, not null.
  -   * @param sourceNodeContext The current node context in the source tree, 
  +   * @param sourceNodeContext The current node context in the source tree,
      * needed to evaluate the Attribute Value Templates.
      *
      * @return A Vector of NodeSortKeys, or null.
      *
      * @throws TransformerException
      */
  -  public Vector processSortKeys(
  -                                ElemForEach foreach, int sourceNodeContext)
  -    throws TransformerException
  +  public Vector processSortKeys(ElemForEach foreach, int sourceNodeContext)
  +          throws TransformerException
     {
   
       Vector keys = null;
  @@ -2152,67 +2313,63 @@
       {
         ElemSort sort = foreach.getSortElem(i);
         String langString =
  -                         (null != sort.getLang())
  -                         ? sort.getLang().evaluate(xctxt, sourceNodeContext, 
foreach)
  -                           : null;
  +        (null != sort.getLang())
  +        ? sort.getLang().evaluate(xctxt, sourceNodeContext, foreach) : null;
         String dataTypeString = sort.getDataType().evaluate(xctxt,
  -                                                          sourceNodeContext, 
foreach);
  +                                sourceNodeContext, foreach);
   
         if (dataTypeString.indexOf(":") >= 0)
           System.out.println(
  -                           "TODO: Need to write the hooks for QNAME sort 
data type");
  +          "TODO: Need to write the hooks for QNAME sort data type");
         else if 
(!(dataTypeString.equalsIgnoreCase(Constants.ATTRVAL_DATATYPE_TEXT))
                  &&!(dataTypeString.equalsIgnoreCase(
  -                                                   
Constants.ATTRVAL_DATATYPE_NUMBER)))
  +                 Constants.ATTRVAL_DATATYPE_NUMBER)))
           foreach.error(XSLTErrorResources.ER_ILLEGAL_ATTRIBUTE_VALUE,
  -                             new Object[]{ Constants.ATTRNAME_DATATYPE,
  -                             dataTypeString });
  +                      new Object[]{ Constants.ATTRNAME_DATATYPE,
  +                                    dataTypeString });
   
         boolean treatAsNumbers =
  -                              ((null != dataTypeString) && 
dataTypeString.equals(
  -                                                                             
    Constants.ATTRVAL_DATATYPE_NUMBER)) ? true : false;
  -      String orderString = sort.getOrder().evaluate(xctxt,
  -                                                    sourceNodeContext, 
foreach);
  +        ((null != dataTypeString) && dataTypeString.equals(
  +        Constants.ATTRVAL_DATATYPE_NUMBER)) ? true : false;
  +      String orderString = sort.getOrder().evaluate(xctxt, sourceNodeContext,
  +                             foreach);
   
         if (!(orderString.equalsIgnoreCase(Constants.ATTRVAL_ORDER_ASCENDING))
  -          &&!(orderString.equalsIgnoreCase(
  -                                           
Constants.ATTRVAL_ORDER_DESCENDING)))
  +              &&!(orderString.equalsIgnoreCase(
  +                Constants.ATTRVAL_ORDER_DESCENDING)))
           foreach.error(XSLTErrorResources.ER_ILLEGAL_ATTRIBUTE_VALUE,
  -                             new Object[]{ Constants.ATTRNAME_ORDER,
  -                             orderString });
  +                      new Object[]{ Constants.ATTRNAME_ORDER,
  +                                    orderString });
   
         boolean descending =
  -                          ((null != orderString) && orderString.equals(
  -                                                                       
Constants.ATTRVAL_ORDER_DESCENDING)) ? true : false;
  +        ((null != orderString) && orderString.equals(
  +        Constants.ATTRVAL_ORDER_DESCENDING)) ? true : false;
         AVT caseOrder = sort.getCaseOrder();
         boolean caseOrderUpper;
   
         if (null != caseOrder)
         {
  -        String caseOrderString = caseOrder.evaluate(xctxt,
  -                                                    sourceNodeContext,
  +        String caseOrderString = caseOrder.evaluate(xctxt, sourceNodeContext,
                                                       foreach);
   
           if 
(!(caseOrderString.equalsIgnoreCase(Constants.ATTRVAL_CASEORDER_UPPER))
  -            &&!(caseOrderString.equalsIgnoreCase(
  -                                                 
Constants.ATTRVAL_CASEORDER_LOWER)))
  -          foreach.error(
  -                               XSLTErrorResources.ER_ILLEGAL_ATTRIBUTE_VALUE,
  -                               new Object[]{ Constants.ATTRNAME_CASEORDER,
  -                               caseOrderString });
  +                &&!(caseOrderString.equalsIgnoreCase(
  +                  Constants.ATTRVAL_CASEORDER_LOWER)))
  +          foreach.error(XSLTErrorResources.ER_ILLEGAL_ATTRIBUTE_VALUE,
  +                        new Object[]{ Constants.ATTRNAME_CASEORDER,
  +                                      caseOrderString });
   
           caseOrderUpper =
  -                        ((null != caseOrderString) && caseOrderString.equals(
  -                                                                             
Constants.ATTRVAL_CASEORDER_UPPER)) ? true : false;
  +          ((null != caseOrderString) && caseOrderString.equals(
  +          Constants.ATTRVAL_CASEORDER_UPPER)) ? true : false;
         }
         else
         {
           caseOrderUpper = false;
         }
   
  -      keys.addElement(new NodeSortKey(this, sort.getSelect(),
  -                                      treatAsNumbers, descending,
  -                                      langString, caseOrderUpper,
  +      keys.addElement(new NodeSortKey(this, sort.getSelect(), treatAsNumbers,
  +                                      descending, langString, caseOrderUpper,
                                         foreach));
       }
   
  @@ -2231,7 +2388,7 @@
      */
     public void pushElemTemplateElement(ElemTemplateElement elem)
     {
  -     m_currentTemplateElements.push(elem);
  +    m_currentTemplateElements.push(elem);
     }
   
     /**
  @@ -2243,22 +2400,23 @@
     }
   
     /**
  -   * Set the top of the current template elements 
  +   * Set the top of the current template elements
      * stack.
      *
  -   * @param e The current ElemTemplateElement about to 
  +   * @param e The current ElemTemplateElement about to
      * be executed.
      */
     public void setCurrentElement(ElemTemplateElement e)
     {
  -    m_currentTemplateElements.setElementAt(e, 
m_currentTemplateElements.size()-1);
  +    m_currentTemplateElements.setElementAt(e, 
m_currentTemplateElements.size()
  +                                           - 1);
     }
   
     /**
  -   * Retrieves the current ElemTemplateElement that is 
  +   * Retrieves the current ElemTemplateElement that is
      * being executed.
      *
  -   * @return The current ElemTemplateElement that is executing, 
  +   * @return The current ElemTemplateElement that is executing,
      * should not normally be null.
      */
     public ElemTemplateElement getCurrentElement()
  @@ -2290,6 +2448,7 @@
      */
     public ElemTemplate getCurrentTemplate()
     {
  +
       ElemTemplateElement elem = getCurrentElement();
   
       while ((null != elem)
  @@ -2302,7 +2461,7 @@
     }
   
     /**
  -   * Push both the current xsl:template or xsl:for-each onto the 
  +   * Push both the current xsl:template or xsl:for-each onto the
      * stack, along with the child node that was matched.
      * (Note: should this only be used for xsl:templates?? -sb)
      *
  @@ -2342,7 +2501,7 @@
      * Retrieves the node in the source tree that matched
      * the template obtained via getMatchedTemplate().
      *
  -   * @return The matched node that corresponds to the 
  +   * @return The matched node that corresponds to the
      * match attribute of the current xsl:template.
      */
     public int getMatchedNode()
  @@ -2360,8 +2519,9 @@
   
       try
       {
  -                        DTMIterator cnl = 
getXPathContext().getContextNodeList();
  -                        return (cnl == null)? null : 
(DTMIterator)cnl.cloneWithReset();      
  +      DTMIterator cnl = getXPathContext().getContextNodeList();
  +
  +      return (cnl == null) ? null : (DTMIterator) cnl.cloneWithReset();
       }
       catch (CloneNotSupportedException cnse)
       {
  @@ -2403,7 +2563,7 @@
     /**
      * Get the current stylesheet for this processor.
      *
  -   * @return The stylesheet that is associated with this 
  +   * @return The stylesheet that is associated with this
      * transformer.
      */
     public StylesheetRoot getStylesheet()
  @@ -2412,11 +2572,11 @@
     }
   
     /**
  -   * Get quietConflictWarnings property. If the quietConflictWarnings 
  +   * Get quietConflictWarnings property. If the quietConflictWarnings
      * property is set to true, warnings about pattern conflicts won't be
      * printed to the diagnostics stream.
      *
  -   * @return True if this transformer should not report 
  +   * @return True if this transformer should not report
      * template match conflicts.
      */
     public boolean getQuietConflictWarnings()
  @@ -2430,7 +2590,7 @@
      * printed to the diagnostics stream.
      * False by default.
      * (Currently setting this property will have no effect.)
  -   * 
  +   *
      * @param b true if conflict warnings should be suppressed.
      */
     public void setQuietConflictWarnings(boolean b)
  @@ -2442,7 +2602,7 @@
      * <meta name="usage" content="internal"/>
      * Set the execution context for XPath.
      *
  -   * @param xcontext A non-null reference to the XPathContext 
  +   * @param xcontext A non-null reference to the XPathContext
      * associated with this transformer.
      */
     public void setXPathContext(XPathContext xcontext)
  @@ -2499,7 +2659,7 @@
      * infinite loop situation, when there is none.
      * Post version 1.0.0, we'll make this a runtime feature.
      *
  -   * @param limit A number that represents the limit of recursion, 
  +   * @param limit A number that represents the limit of recursion,
      * or -1 if no checking is to be done.
      */
     public void setRecursionLimit(int limit)
  @@ -2510,7 +2670,7 @@
     /**
      * Get the ResultTreeHandler object.
      *
  -   * @return The current ResultTreeHandler, which may not 
  +   * @return The current ResultTreeHandler, which may not
      * be the main result tree manager.
      */
     public ResultTreeHandler getResultTreeHandler()
  @@ -2591,7 +2751,7 @@
     }
   
     /**
  -   * Tell if the current template rule is null, i.e. if we are 
  +   * Tell if the current template rule is null, i.e. if we are
      * directly within an apply-templates.  Used for xsl:apply-imports.
      *
      * @return True if the current template rule is null.
  @@ -2606,7 +2766,7 @@
      * Push true if the current template rule is null, false
      * otherwise.
      *
  -   * @param b True if the we are executing an xsl:for-each 
  +   * @param b True if the we are executing an xsl:for-each
      * (or xsl:call-template?).
      */
     public void pushCurrentTemplateRuleIsNull(boolean b)
  @@ -2636,36 +2796,36 @@
   
       return m_msgMgr;
     }
  -  
  +
     /**
      * Set the error event listener.
      *
      * @param listener The new error listener.
  -   * @throws IllegalArgumentException if 
  +   * @throws IllegalArgumentException if
      */
  -  public void setErrorListener (ErrorListener listener)
  -    throws IllegalArgumentException
  +  public void setErrorListener(ErrorListener listener)
  +          throws IllegalArgumentException
     {
  -    synchronized(m_reentryGuard) 
  +
  +    synchronized (m_reentryGuard)
       {
  -      if (listener == null) 
  +      if (listener == null)
           throw new IllegalArgumentException("Null error handler");
  +
         m_errorHandler = listener;
       }
     }
   
  -
     /**
      * Get the current error event handler.
      *
      * @return The current error handler, which should never be null.
      */
  -  public ErrorListener getErrorListener ()
  +  public ErrorListener getErrorListener()
     {
       return m_errorHandler;
     }
   
  -
     /**
      * Get an instance of the trace manager for this transformation.
      * This object can be used to set trace listeners on various
  @@ -2721,127 +2881,182 @@
   
       throw new SAXNotRecognizedException(name);
     }
  -  
  +
     // %TODO% Doc
  +
  +  /**
  +   * NEEDSDOC Method getMode 
  +   *
  +   *
  +   * NEEDSDOC (getMode) @return
  +   */
     public QName getMode()
     {
  -    return m_modes.isEmpty() ? null : (QName)m_modes.peek();
  +    return m_modes.isEmpty() ? null : (QName) m_modes.peek();
     }
  -  
  +
     // %TODO% Doc
  +
  +  /**
  +   * NEEDSDOC Method pushMode 
  +   *
  +   *
  +   * NEEDSDOC @param mode
  +   */
     public void pushMode(QName mode)
     {
       m_modes.push(mode);
     }
  -  
  +
     // %TODO% Doc
  +
  +  /**
  +   * NEEDSDOC Method popMode 
  +   *
  +   */
     public void popMode()
     {
       m_modes.pop();
     }
   
  -
     ////////////////////////
     // Implement Runnable //  
     ////////////////////////
  -        
  -        /** Base thread controler for xalan. Must be overriden with
  -      a derived class to support thread pooling.
  -
  -      All thread-related stuff is in this class.
  -  */
  -  public static class ThreadControler {
  -    
  -    /** Will get a thread from the pool, execute the task
  +
  +  /**
  +   * Base thread controler for xalan. Must be overriden with
  +   * a derived class to support thread pooling.
  +   *
  +   * All thread-related stuff is in this class.
  +   */
  +  public static class ThreadControler
  +  {
  +
  +    /**
  +     * Will get a thread from the pool, execute the task
        *  and return the thread to the pool.
        *
        *  The return value is used only to wait for completion
        *
  +     *
  +     * NEEDSDOC @param task
        * @param priority if >0 the task will run with the given priority
        *  ( doesn't seem to be used in xalan, since it's allways the default )
        * @returns The thread that is running the task, can be used
        *          to wait for completion
  +     *
  +     * NEEDSDOC ($objectName$) @return
        */
  -    public Thread run( Runnable task, int priority ) {
  -      Thread t=new Thread(task);
  +    public Thread run(Runnable task, int priority)
  +    {
  +
  +      Thread t = new Thread(task);
  +
         t.start();
  -//       if( priority > 0 )
  -//   t.setPriority( priority );
  +
  +      //       if( priority > 0 )
  +      //      t.setPriority( priority );
         return t;
       }
   
  -
       /**
        *  Wait until the task is completed on the worker
  -     *  thread. 
  +     *  thread.
  +     *
  +     * NEEDSDOC @param worker
  +     * NEEDSDOC @param task
  +     *
  +     * @throws InterruptedException
        */
  -    public void waitThread( Thread worker, Runnable task )
  -      throws InterruptedException
  +    public void waitThread(Thread worker, Runnable task)
  +            throws InterruptedException
       {
  +
         // This should wait until the transformThread is considered not alive.
         worker.join();
       }
     }
   
  -  static ThreadControler tpool=new ThreadControler();
  +  /** NEEDSDOC Field tpool          */
  +  static ThreadControler tpool = new ThreadControler();
   
  -  /** Change the ThreadControler that will be used to
  +  /**
  +   * Change the ThreadControler that will be used to
      *  manage the transform threads.
  +   *
  +   * NEEDSDOC @param tp
      */
  -  public static void setThreadControler( ThreadControler tp ) {
  -    tpool=tp;
  +  public static void setThreadControler(ThreadControler tp)
  +  {
  +    tpool = tp;
     }
  -  
  -  /** Called by SourceTreeHandler to start the transformation
  +
  +  /**
  +   * Called by SourceTreeHandler to start the transformation
      *  in a separate thread
  +   *
  +   * NEEDSDOC @param priority
      */
  -  public void runTransformThread( int priority ) {
  +  public void runTransformThread(int priority)
  +  {
  +
       // used in SourceTreeHandler
  -    Thread t=tpool.run( this, priority );
  -    this.setTransformThread( t );
  +    Thread t = tpool.run(this, priority);
  +
  +    this.setTransformThread(t);
     }
   
  -  /** Called by this.transform() if isParserEventsOnMain()==false.
  +  /**
  +   * Called by this.transform() if isParserEventsOnMain()==false.
      *  Similar with runTransformThread(), but no priority is set
      *  and setTransformThread is not set.
      */
  -  public void runTransformThread( ) {
  -    tpool.run( this, -1);
  +  public void runTransformThread()
  +  {
  +    tpool.run(this, -1);
     }
  -        
  -        /** Used by SourceTreeHandler to wait until the transform
  +
  +  /**
  +   * Used by SourceTreeHandler to wait until the transform
      *   completes
  +   *
  +   * @throws SAXException
      */
  -  public void waitTransformThread() throws SAXException {
  +  public void waitTransformThread() throws SAXException
  +  {
  +
       // This is called to make sure the task is done.
       // It is possible that the thread has been reused -
       // but for a different transformation. ( what if we 
       // recycle the transformer ? Not a problem since this is
       // still in use. )
       Thread transformThread = this.getTransformThread();
  +
       if (null != transformThread)
  +    {
  +      try
         {
  -        try
  -          {
  -            tpool.waitThread( transformThread, this );
  -            
  -            if(!this.hasTransformThreadErrorCatcher())
  -              {
  -                Exception e = this.getExceptionThrown();
  -                if(null != e)
  -                  throw new org.xml.sax.SAXException(e);
  -              }
  -            this.setTransformThread(null);
  -          }
  -        catch (InterruptedException ie){}
  +        tpool.waitThread(transformThread, this);
  +
  +        if (!this.hasTransformThreadErrorCatcher())
  +        {
  +          Exception e = this.getExceptionThrown();
  +
  +          if (null != e)
  +            throw new org.xml.sax.SAXException(e);
  +        }
  +
  +        this.setTransformThread(null);
         }
  +      catch (InterruptedException ie){}
  +    }
     }
   
     /**
  -   * Get the exception thrown by the secondary thread (normally 
  +   * Get the exception thrown by the secondary thread (normally
      * the transform thread).
      *
  -   * @return The thrown exception, or null if no exception was 
  +   * @return The thrown exception, or null if no exception was
      * thrown.
      */
     public Exception getExceptionThrown()
  @@ -2850,10 +3065,10 @@
     }
   
     /**
  -   * Set the exception thrown by the secondary thread (normally 
  +   * Set the exception thrown by the secondary thread (normally
      * the transform thread).
      *
  -   * @param e The thrown exception, or null if no exception was 
  +   * @param e The thrown exception, or null if no exception was
      * thrown.
      */
     public void setExceptionThrown(Exception e)
  @@ -2864,19 +3079,19 @@
     /**
      * This is just a way to set the document for run().
      *
  -   * @param doc A non-null reference to the root of the 
  +   * @param doc A non-null reference to the root of the
      * tree to be transformed.
      */
     public void setSourceTreeDocForThread(int doc)
     {
       m_doc = doc;
     }
  -  
  -  
  -  /** Set the input source for the source tree, which is needed if the 
  -   * parse thread is not the main thread, in order for the parse 
  -   * thread's run method to get to the input source.  
  -   * 
  +
  +  /**
  +   * Set the input source for the source tree, which is needed if the
  +   * parse thread is not the main thread, in order for the parse
  +   * thread's run method to get to the input source.
  +   *
      * @param source The input source for the source tree.
      */
     public void setXMLSource(Source source)
  @@ -2887,12 +3102,13 @@
     /**
      * Tell if the transform method is completed.
      *
  -   * @return True if transformNode has completed, or 
  +   * @return True if transformNode has completed, or
      * an exception was thrown.
      */
     public boolean isTransformDone()
     {
  -    synchronized(this)
  +
  +    synchronized (this)
       {
         return m_isTransformDone;
       }
  @@ -2901,12 +3117,13 @@
     /**
      * Set if the transform method is completed.
      *
  -   * @param done True if transformNode has completed, or 
  +   * @param done True if transformNode has completed, or
      * an exception was thrown.
      */
     public void setIsTransformDone(boolean done)
     {
  -    synchronized(this)
  +
  +    synchronized (this)
       {
         m_isTransformDone = done;
       }
  @@ -2918,50 +3135,48 @@
      *
      * @param e The exception that was thrown.
      */
  -  void postExceptionFromThread(Exception e)  
  +  void postExceptionFromThread(Exception e)
     {
  +
       // Commented out in response to problem reported by Nicola Brown <[EMAIL 
PROTECTED]>
  -//    if(m_reportInPostExceptionFromThread)
  -//    {
  -//      // Consider re-throwing the exception if this flag is set.
  -//      e.printStackTrace();
  -//    }
  -  
  +    //    if(m_reportInPostExceptionFromThread)
  +    //    {
  +    //      // Consider re-throwing the exception if this flag is set.
  +    //      e.printStackTrace();
  +    //    }
       // %REVIEW Need DTM equivelent?    
  -//    if (m_inputContentHandler instanceof SourceTreeHandler)
  -//    {
  -//      SourceTreeHandler sth = (SourceTreeHandler) m_inputContentHandler;
  -//
  -//      sth.setExceptionThrown(e);
  -//    }
  +    //    if (m_inputContentHandler instanceof SourceTreeHandler)
  +    //    {
  +    //      SourceTreeHandler sth = (SourceTreeHandler) 
m_inputContentHandler;
  +    //
  +    //      sth.setExceptionThrown(e);
  +    //    }
       ContentHandler ch = getContentHandler();
  -//    if(ch instanceof SourceTreeHandler)
  -//    {
  -//      SourceTreeHandler sth = (SourceTreeHandler) ch;
  -//      ((TransformerImpl)(sth.getTransformer())).postExceptionFromThread(e);
  -//    }
   
  +    //    if(ch instanceof SourceTreeHandler)
  +    //    {
  +    //      SourceTreeHandler sth = (SourceTreeHandler) ch;
  +    //      
((TransformerImpl)(sth.getTransformer())).postExceptionFromThread(e);
  +    //    }
       m_isTransformDone = true;
       m_exceptionThrown = e;
       ;  // should have already been reported via the error handler?
   
       synchronized (this)
       {
  -      // See message from me on 3/27/2001 to Patrick Moore.
  -//      String msg = e.getMessage();
   
  +      // See message from me on 3/27/2001 to Patrick Moore.
  +      //      String msg = e.getMessage();
         // System.out.println(e.getMessage());
  -      
         // Is this really needed?  -sb
         notifyAll();
   
  -//      if (null == msg)
  -//      {
  -//
  -//        // m_throwNewError = false;
  -//        e.printStackTrace();
  -//      }
  -
  +      //      if (null == msg)
  +      //      {
  +      //
  +      //        // m_throwNewError = false;
  +      //        e.printStackTrace();
  +      //      }
         // throw new org.apache.xml.utils.WrappedRuntimeException(e);
       }
     }
  @@ -2971,21 +3186,24 @@
      */
     public void run()
     {
  +
       m_hasBeenReset = false;
   
       try
       {
  +
         // int n = ((SourceTreeHandler)getInputContentHandler()).getDTMRoot();
         // transformNode(n);
         try
         {
           m_isTransformDone = false;
  -        
  +
           transformNode(m_doc);
         }
         catch (Exception e)
         {
           e.printStackTrace();
  +
           // Strange that the other catch won't catch this...
           postExceptionFromThread(e);
         }
  @@ -2993,92 +3211,109 @@
         {
           m_isTransformDone = true;
   
  -        if(m_inputContentHandler instanceof TransformerHandlerImpl)
  +        if (m_inputContentHandler instanceof TransformerHandlerImpl)
           {
  -          ((TransformerHandlerImpl)m_inputContentHandler).clearCoRoutine();
  +          ((TransformerHandlerImpl) m_inputContentHandler).clearCoRoutine();
           }
   
  -//        synchronized (this)
  -//        {
  -//          notifyAll();
  -//        }
  +        //        synchronized (this)
  +        //        {
  +        //          notifyAll();
  +        //        }
         }
       }
       catch (Exception e)
       {
  +
         // e.printStackTrace();
         postExceptionFromThread(e);
       }
     }
  -  
  +
     // Fragment re-execution interfaces for a tool.
  -  
  +
  +  /**
  +   * NEEDSDOC Method getSnapshot 
  +   *
  +   *
  +   * NEEDSDOC (getSnapshot) @return
  +   */
     public TransformSnapshot getSnapshot()
     {
       return new TransformSnapshotImpl(this);
     }
  -  
  +
     /**
      * This will execute the following XSLT instructions
      * from the snapshot point.
  +   *
  +   * NEEDSDOC @param ts
  +   *
  +   * @throws TransformerException
      */
     public void executeFromSnapshot(TransformSnapshot ts)
  -                throws TransformerException
  +          throws TransformerException
     {
  +
       ElemTemplateElement template = getMatchedTemplate();
  -                int child = getMatchedNode();
  -                pushElemTemplateElement(template); //needed??
  -    m_xcontext.pushCurrentNode(child); //needed??
  -                this.executeChildTemplates(template, true); // 
getResultTreeHandler());
  +    int child = getMatchedNode();
  +
  +    pushElemTemplateElement(template);  //needed??
  +    m_xcontext.pushCurrentNode(child);  //needed??
  +    this.executeChildTemplates(template, true);  // getResultTreeHandler());
     }
  -        
  -        /**
  +
  +  /**
      * This will execute the following XSLT instructions
      * from the snapshot point.
  +   *
  +   * NEEDSDOC @param ts
      */
  -  public void resetToStylesheet(TransformSnapshot ts)                
  -  {
  -    ((TransformSnapshotImpl)ts).apply(this);         
  -  }
  -  
  -  public void stopTransformation()
  +  public void resetToStylesheet(TransformSnapshot ts)
     {
  +    ((TransformSnapshotImpl) ts).apply(this);
     }
  -  
  +
  +  /**
  +   * NEEDSDOC Method stopTransformation 
  +   *
  +   */
  +  public void stopTransformation(){}
  +
     /**
  -   * Test whether whitespace-only text nodes are visible in the logical 
  +   * Test whether whitespace-only text nodes are visible in the logical
      * view of <code>DTM</code>. Normally, this function
  -   * will be called by the implementation of <code>DTM</code>; 
  +   * will be called by the implementation of <code>DTM</code>;
      * it is not normally called directly from
      * user code.
  -   * 
  +   *
      * @param elementHandle int Handle of the element.
      * @return one of NOTSTRIP, STRIP, or INHERIT.
      */
  -  public short getShouldStripSpace(int elementHandle)
  +  public short getShouldStripSpace(int elementHandle, DTM dtm)
     {
  +
       try
  -    {      
  -      org.apache.xalan.templates.WhiteSpaceInfo info = 
  -        m_stylesheetRoot.getWhiteSpaceInfo(m_xcontext, elementHandle);
  -         
  +    {
  +      org.apache.xalan.templates.WhiteSpaceInfo info =
  +        m_stylesheetRoot.getWhiteSpaceInfo(m_xcontext, elementHandle, dtm);
  +
         if (null == info)
         {
           return DTMWSFilter.INHERIT;
         }
         else
         {
  +
           // System.out.println("getShouldStripSpace: 
"+info.getShouldStripSpace());
  -        return info.getShouldStripSpace() ? DTMWSFilter.STRIP : 
DTMWSFilter.NOTSTRIP;
  +        return info.getShouldStripSpace()
  +               ? DTMWSFilter.STRIP : DTMWSFilter.NOTSTRIP;
         }
       }
       catch (TransformerException se)
       {
         return DTMWSFilter.INHERIT;
       }
  -
     }
  -
  -  
   }  // end TransformerImpl class
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +1 -1      
xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMWSFilter.java
  
  Index: DTMWSFilter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMWSFilter.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DTMWSFilter.java  2001/05/06 02:13:09     1.1.2.1
  +++ DTMWSFilter.java  2001/05/30 20:30:57     1.1.2.2
  @@ -31,6 +31,6 @@
      * @param elementHandle int Handle of the element.
      * @return one of NOTSTRIP, STRIP, or INHERIT.
      */
  -  public short getShouldStripSpace(int elementHandle);
  +  public short getShouldStripSpace(int elementHandle, DTM dtm);
     
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +28 -31    
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBase.java
  
  Index: DTMDefaultBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBase.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- DTMDefaultBase.java       2001/05/29 14:31:12     1.1.2.4
  +++ DTMDefaultBase.java       2001/05/30 20:31:00     1.1.2.5
  @@ -104,10 +104,10 @@
     protected int[] m_nextsib;
   
     /** Previous sibling values, one array element for each node. */
  -  protected short[] m_prevsib;
  +  protected int[] m_prevsib;
   
     /** Previous sibling values, one array element for each node. */
  -  protected short[] m_parent;
  +  protected int[] m_parent;
     
     /** Experemental.  -sb */
     protected boolean m_haveSeenNamespace = false;
  @@ -118,7 +118,7 @@
      * name, and the last array contains the the first free element
      * at the start, and the list of element handles following.
      */
  -  protected short[][][] m_elemIndexes;
  +  protected int[][][] m_elemIndexes;
   
     /** The default initial block size of the node arrays */
     protected int m_initialblocksize = 512;  // favor small docs.
  @@ -196,8 +196,8 @@
       m_level = new byte[m_initialblocksize];
       m_firstch = new int[m_initialblocksize];
       m_nextsib = new int[m_initialblocksize];
  -    m_prevsib = new short[m_initialblocksize];
  -    m_parent = new short[m_initialblocksize];
  +    m_prevsib = new int[m_initialblocksize];
  +    m_parent = new int[m_initialblocksize];
       m_mgr = mgr;
       m_documentBaseURI = (null != source) ? source.getSystemId() : null;
       m_dtmIdent = dtmIdentity;
  @@ -238,48 +238,48 @@
   
       if (null == m_elemIndexes)
       {
  -      m_elemIndexes = new short[namespaceID + 20][][];
  +      m_elemIndexes = new int[namespaceID + 20][][];
       }
       else if (m_elemIndexes.length <= namespaceID)
       {
  -      short[][][] indexes = m_elemIndexes;
  +      int[][][] indexes = m_elemIndexes;
   
  -      m_elemIndexes = new short[namespaceID + 20][][];
  +      m_elemIndexes = new int[namespaceID + 20][][];
   
         System.arraycopy(indexes, 0, m_elemIndexes, 0, indexes.length);
       }
   
  -    short[][] localNameIndex = m_elemIndexes[namespaceID];
  +    int[][] localNameIndex = m_elemIndexes[namespaceID];
   
       if (null == localNameIndex)
       {
  -      localNameIndex = new short[LocalNameID + 100][];
  +      localNameIndex = new int[LocalNameID + 100][];
         m_elemIndexes[namespaceID] = localNameIndex;
       }
       else if (localNameIndex.length <= LocalNameID)
       {
  -      short[][] indexes = localNameIndex;
  +      int[][] indexes = localNameIndex;
   
  -      localNameIndex = new short[LocalNameID + 100][];
  +      localNameIndex = new int[LocalNameID + 100][];
   
         System.arraycopy(indexes, 0, localNameIndex, 0, indexes.length);
   
         m_elemIndexes[namespaceID] = localNameIndex;
       }
   
  -    short[] elemHandles = localNameIndex[LocalNameID];
  +    int[] elemHandles = localNameIndex[LocalNameID];
   
       if (null == elemHandles)
       {
  -      elemHandles = new short[128];
  +      elemHandles = new int[128];
         localNameIndex[LocalNameID] = elemHandles;
         elemHandles[0] = 1;
       }
       else if (elemHandles.length <= elemHandles[0] + 1)
       {
  -      short[] indexes = elemHandles;
  +      int[] indexes = elemHandles;
   
  -      elemHandles = new short[elemHandles[0] + 1024];
  +      elemHandles = new int[elemHandles[0] + 1024];
   
         System.arraycopy(indexes, 0, elemHandles, 0, indexes.length);
   
  @@ -307,9 +307,9 @@
   
         ensureSizeOfIndex(namespaceID, localNameID);
   
  -      short[] index = m_elemIndexes[namespaceID][localNameID];
  +      int[] index = m_elemIndexes[namespaceID][localNameID];
   
  -      index[index[0]] = (short) identity;
  +      index[index[0]] = identity;
   
         index[0]++;
       }
  @@ -328,7 +328,7 @@
      * @return The index in the list of the slot that is higher or identical
      * to the identity argument, or -1 if no node is higher or equal.
      */
  -  protected int findGTE(short[] list, int start, int len, int value)
  +  protected int findGTE(int[] list, int start, int len, int value)
     {
   
       int low = start;
  @@ -365,15 +365,15 @@
     int findElementFromIndex(int nsIndex, int lnIndex, int firstPotential)
     {
   
  -    short[][][] indexes = m_elemIndexes;
  +    int[][][] indexes = m_elemIndexes;
   
       if (null != indexes && nsIndex < indexes.length)
       {
  -      short[][] lnIndexs = indexes[nsIndex];
  +      int[][] lnIndexs = indexes[nsIndex];
   
         if (null != lnIndexs && lnIndex < lnIndexs.length)
         {
  -        short[] elems = lnIndexs[lnIndex];
  +        int[] elems = lnIndexs[lnIndex];
   
           if (null != elems)
           {
  @@ -440,15 +440,15 @@
         byte[] level = m_level;
         int[] firstch = m_firstch;
         int[] nextsib = m_nextsib;
  -      short[] prevsib = m_prevsib;
  -      short[] parent = m_parent;
  +      int[] prevsib = m_prevsib;
  +      int[] parent = m_parent;
   
         m_exptype = new int[newcapacity];
         m_level = new byte[newcapacity];
         m_firstch = new int[newcapacity];
         m_nextsib = new int[newcapacity];
  -      m_prevsib = new short[newcapacity];
  -      m_parent = new short[newcapacity];
  +      m_prevsib = new int[newcapacity];
  +      m_parent = new int[newcapacity];
   
         System.arraycopy(exptype, 0, m_exptype, 0, capacity);
         System.arraycopy(level, 0, m_level, 0, capacity);
  @@ -1456,17 +1456,14 @@
      * Given a node handle, return its DOM-style node type.
      * <p>
      * %REVIEW% Generally, returning short is false economy. Return int?
  +   * %REVIEW% Make assumption that node has already arrived.  Is OK?
      *
      * @param nodeHandle The node id.
      * @return int Node type, as per the DOM's Node._NODE constants.
      */
     public short getNodeType(int nodeHandle)
     {
  -
  -    int identity = nodeHandle & m_mask;
  -    short type = (short) _type(identity);
  -
  -    return type;
  +    return (short)(_exptype(nodeHandle & m_mask) >> 
ExpandedNameTable.ROTAMOUNT_TYPE);
     }
   
     /**
  
  
  
  1.1.2.8   +2 -2      
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBaseTraversers.java
  
  Index: DTMDefaultBaseTraversers.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBaseTraversers.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- DTMDefaultBaseTraversers.java     2001/05/29 14:31:13     1.1.2.7
  +++ DTMDefaultBaseTraversers.java     2001/05/30 20:31:00     1.1.2.8
  @@ -723,7 +723,7 @@
       {
   
         int first;
  -      int type = getNodeType(context);
  +      int type = _type(context);
   
         if ((DTM.ATTRIBUTE_NODE == type) || (DTM.NAMESPACE_NODE == type))
         {
  @@ -759,7 +759,7 @@
       {
   
         int first;
  -      int type = getNodeType(context);
  +      int type = _type(context);
   
         if ((DTM.ATTRIBUTE_NODE == type) || (DTM.NAMESPACE_NODE == type))
         {
  
  
  
  1.1.2.3   +2 -1      
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMManagerDefault.java
  
  Index: DTMManagerDefault.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMManagerDefault.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DTMManagerDefault.java    2001/05/28 04:07:28     1.1.2.2
  +++ DTMManagerDefault.java    2001/05/30 20:31:01     1.1.2.3
  @@ -145,6 +145,7 @@
                       DTMWSFilter whiteSpaceFilter, boolean incremental, 
                       boolean doIndexing)
     {
  +
       if(DEBUG && null != source)
         System.out.println("Starting source: "+source.getSystemId());
       XMLStringFactory xstringFactory = m_xsf;
  @@ -220,7 +221,7 @@
           if (haveXercesParser)
             incremental = true;  // No matter what.  %REVIEW%
   
  -        if (incremental)
  +        if (true && incremental)
           {
   
             // Create a CoroutineManager to manage the coordination between 
the 
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.7   +5 -4      
xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/Attic/DOM2DTM.java
  
  Index: DOM2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/Attic/DOM2DTM.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- DOM2DTM.java      2001/05/29 14:31:22     1.1.2.6
  +++ DOM2DTM.java      2001/05/30 20:31:05     1.1.2.7
  @@ -266,8 +266,8 @@
       
       m_firstch[nodeIndex] = NOTPROCESSED;
       m_nextsib[nodeIndex] = NOTPROCESSED;
  -    m_prevsib[nodeIndex] = (short)previousSibling;
  -    m_parent[nodeIndex] = (short)parentIndex;
  +    m_prevsib[nodeIndex] = previousSibling;
  +    m_parent[nodeIndex] = parentIndex;
       
       if(DTM.NULL != parentIndex && 
          type != DTM.ATTRIBUTE_NODE && 
  @@ -275,7 +275,7 @@
       {
         // If the DTM parent had no children, this becomes its first child.
         if(NOTPROCESSED == m_firstch[parentIndex])
  -        m_firstch[parentIndex] = (short)nodeIndex;
  +        m_firstch[parentIndex] = nodeIndex;
       }
       
       String nsURI = node.getNamespaceURI();
  @@ -507,7 +507,8 @@
                                  
         if((null != m_wsfilter) && (Node.ELEMENT_NODE == pos.getNodeType()))
         {
  -        short wsv = 
m_wsfilter.getShouldStripSpace(newIndexHandle|m_dtmIdent);
  +        short wsv = 
m_wsfilter.getShouldStripSpace(newIndexHandle|m_dtmIdent, 
  +                                                                      this);
           boolean shouldStrip = (DTMWSFilter.INHERIT == wsv) ? 
                     getShouldStripWhitespace() : (DTMWSFilter.STRIP == wsv);
           pushShouldStripWhitespace(shouldStrip);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +8 -8      
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM.java
  
  Index: SAX2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- SAX2DTM.java      2001/05/29 14:31:26     1.1.2.4
  +++ SAX2DTM.java      2001/05/30 20:31:07     1.1.2.5
  @@ -164,7 +164,7 @@
     private boolean m_endDocumentOccured = false;
   
     /** Data or qualified name values, one array element for each node. */
  -  protected short[] m_dataOrQName;
  +  protected int[] m_dataOrQName;
   
     /**
      * This table holds the ID string to node associations, for
  @@ -235,7 +235,7 @@
             
       m_data = new IntVector(doIndexing ? (1024*4) : 512);
   
  -    m_dataOrQName = new short[m_initialblocksize];
  +    m_dataOrQName = new int[m_initialblocksize];
   
       int doc = addNode(DTM.DOCUMENT_NODE,
                         
m_expandedNameTable.getExpandedTypeID(DTM.DOCUMENT_NODE),
  @@ -815,10 +815,10 @@
   
       if (capacity <= index)
       {
  -      short[] dataOrQName = m_dataOrQName;
  +      int[] dataOrQName = m_dataOrQName;
         int newcapacity = capacity + m_blocksize;
   
  -      m_dataOrQName = new short[newcapacity];
  +      m_dataOrQName = new int[newcapacity];
   
         System.arraycopy(dataOrQName, 0, m_dataOrQName, 0, capacity);
         
  @@ -855,10 +855,10 @@
       m_level[nodeIndex] = (byte) level;
       m_firstch[nodeIndex] = canHaveFirstChild ? NOTPROCESSED : DTM.NULL;
       m_nextsib[nodeIndex] = NOTPROCESSED;
  -    m_prevsib[nodeIndex] = (short) previousSibling;
  -    m_parent[nodeIndex] = (short) parentIndex;
  +    m_prevsib[nodeIndex] = previousSibling;
  +    m_parent[nodeIndex] = parentIndex;
       m_exptype[nodeIndex] = expandedTypeID;
  -    m_dataOrQName[nodeIndex] = (short) dataOrPrefix;
  +    m_dataOrQName[nodeIndex] = dataOrPrefix;
       
       if(DTM.NAMESPACE_NODE == type)
         m_haveSeenNamespace = true;
  @@ -1744,7 +1744,7 @@
   
       if (null != m_wsfilter)
       {
  -      short wsv = m_wsfilter.getShouldStripSpace(elemNode | m_dtmIdent);
  +      short wsv = m_wsfilter.getShouldStripSpace(elemNode | m_dtmIdent, 
this);
         boolean shouldStrip = (DTMWSFilter.INHERIT == wsv)
                               ? getShouldStripWhitespace()
                               : (DTMWSFilter.STRIP == wsv);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.3   +145 -21   xml-xalan/java/src/org/apache/xml/utils/NodeVector.java
  
  Index: NodeVector.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/NodeVector.java,v
  retrieving revision 1.3.2.2
  retrieving revision 1.3.2.3
  diff -u -r1.3.2.2 -r1.3.2.3
  --- NodeVector.java   2001/05/06 02:09:47     1.3.2.2
  +++ NodeVector.java   2001/05/30 20:31:11     1.3.2.3
  @@ -57,6 +57,7 @@
   package org.apache.xml.utils;
   
   import java.io.Serializable;
  +
   import org.apache.xml.dtm.DTM;
   
   /**
  @@ -66,20 +67,28 @@
   public class NodeVector implements Serializable, Cloneable
   {
   
  -  /** Size of blocks to allocate.
  -   *  @serial          */
  +  /**
  +   * Size of blocks to allocate.
  +   *  @serial          
  +   */
     private int m_blocksize;
   
  -  /** Array of nodes this points to.
  -   *  @serial          */
  +  /**
  +   * Array of nodes this points to.
  +   *  @serial          
  +   */
     private int m_map[];
   
  -  /** Number of nodes in this NodeVector.
  -   *  @serial          */
  +  /**
  +   * Number of nodes in this NodeVector.
  +   *  @serial          
  +   */
     protected int m_firstFree = 0;
   
  -  /** Size of the array this points to.
  -   *  @serial           */
  +  /**
  +   * Size of the array this points to.
  +   *  @serial           
  +   */
     private int m_mapSize;  // lazy initialization
   
     /**
  @@ -94,7 +103,7 @@
     /**
      * Construct a NodeVector, using the given block size.
      *
  -   * @param blocksize Size of blocks to allocate 
  +   * @param blocksize Size of blocks to allocate
      */
     public NodeVector(int blocksize)
     {
  @@ -223,7 +232,7 @@
      * Pop a node from the tail of the vector and return the
      * top of the stack after the pop.
      *
  -   * @return The top of the stack after it's been popped 
  +   * @return The top of the stack after it's been popped
      */
     public final int popAndTop()
     {
  @@ -251,7 +260,7 @@
      * Special purpose method for TransformerImpl, pushElemTemplateElement.
      * Performance critical.
      *
  -   * @return Node at the top of the stack or null if stack is empty.  
  +   * @return Node at the top of the stack or null if stack is empty.
      */
     public final int peepOrNull()
     {
  @@ -260,7 +269,7 @@
     }
   
     /**
  -   * Push a pair of nodes into the stack.  
  +   * Push a pair of nodes into the stack.
      * Special purpose method for TransformerImpl, pushElemTemplateElement.
      * Performance critical.
      *
  @@ -295,7 +304,7 @@
     }
   
     /**
  -   * Pop a pair of nodes from the tail of the stack. 
  +   * Pop a pair of nodes from the tail of the stack.
      * Special purpose method for TransformerImpl, pushElemTemplateElement.
      * Performance critical.
      */
  @@ -354,24 +363,26 @@
     {
       return m_map[m_firstFree - 2];
     }
  -  
  +
     /**
      * Insert a node in order in the list.
  -   * 
  +   *
      * @param value Node to insert
      */
     public void insertInOrder(int value)
     {
  -    for (int i = 0; i < m_firstFree; i++) 
  +
  +    for (int i = 0; i < m_firstFree; i++)
       {
  -      if(value < m_map[i])
  +      if (value < m_map[i])
         {
           insertElementAt(value, i);
  +
           return;
         }
       }
  +
       addElement(value);
  -    
     }
   
     /**
  @@ -484,7 +495,7 @@
       {
         int node = m_map[i];
   
  -      if ( node == s )
  +      if (node == s)
         {
           if (i > m_firstFree)
             System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
  @@ -603,7 +614,7 @@
       {
         int node = m_map[i];
   
  -      if ( node == elem )
  +      if (node == elem)
           return i;
       }
   
  @@ -615,7 +626,7 @@
      * beginning the search at index, and testing for equality
      * using the equals method.
      *
  -   * @param elem Node to look for 
  +   * @param elem Node to look for
      * @return the index of the first occurrence of the object
      * argument in this vector at position index or later in the
      * vector; returns -1 if the object is not found.
  @@ -635,5 +646,118 @@
       }
   
       return -1;
  +  }
  +
  +  /**
  +   * Sort an array using a quicksort algorithm.
  +   *
  +   * @param a The array to be sorted.
  +   * @param lo0  The low index.
  +   * @param hi0  The high index.
  +   *
  +   * @throws Exception
  +   */
  +  public void sort(int a[], int lo0, int hi0) throws Exception
  +  {
  +
  +    int lo = lo0;
  +    int hi = hi0;
  +
  +    // pause(lo, hi);
  +    if (lo >= hi)
  +    {
  +      return;
  +    }
  +    else if (lo == hi - 1)
  +    {
  +
  +      /*
  +       *  sort a two element list by swapping if necessary
  +       */
  +      if (a[lo] > a[hi])
  +      {
  +        int T = a[lo];
  +
  +        a[lo] = a[hi];
  +        a[hi] = T;
  +      }
  +
  +      return;
  +    }
  +
  +    /*
  +     *  Pick a pivot and move it out of the way
  +     */
  +    int pivot = a[(lo + hi) / 2];
  +
  +    a[(lo + hi) / 2] = a[hi];
  +    a[hi] = pivot;
  +
  +    while (lo < hi)
  +    {
  +
  +      /*
  +       *  Search forward from a[lo] until an element is found that
  +       *  is greater than the pivot or lo >= hi
  +       */
  +      while (a[lo] <= pivot && lo < hi)
  +      {
  +        lo++;
  +      }
  +
  +      /*
  +       *  Search backward from a[hi] until element is found that
  +       *  is less than the pivot, or lo >= hi
  +       */
  +      while (pivot <= a[hi] && lo < hi)
  +      {
  +        hi--;
  +      }
  +
  +      /*
  +       *  Swap elements a[lo] and a[hi]
  +       */
  +      if (lo < hi)
  +      {
  +        int T = a[lo];
  +
  +        a[lo] = a[hi];
  +        a[hi] = T;
  +
  +        // pause();
  +      }
  +
  +      // if (stopRequested) {
  +      //    return;
  +      // }
  +    }
  +
  +    /*
  +     *  Put the median in the "center" of the list
  +     */
  +    a[hi0] = a[hi];
  +    a[hi] = pivot;
  +
  +    /*
  +     *  Recursive calls, elements a[lo0] to a[lo-1] are less than or
  +     *  equal to pivot, elements a[hi+1] to a[hi0] are greater than
  +     *  pivot.
  +     */
  +    sort(a, lo0, lo - 1);
  +    sort(a, hi + 1, hi0);
  +  }
  +
  +  /**
  +   * Sort an array using a quicksort algorithm.
  +   *
  +   * @param a The array to be sorted.
  +   * @param lo0  The low index.
  +   * @param hi0  The high index.
  +   *
  +   * @throws Exception
  +   */
  +  public void sort() throws Exception
  +  {
  +    sort(m_map, 0, m_firstFree - 1);
     }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.3  +20 -0     xml-xalan/java/src/org/apache/xpath/Expression.java
  
  Index: Expression.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/Expression.java,v
  retrieving revision 1.14.2.2
  retrieving revision 1.14.2.3
  diff -u -r1.14.2.2 -r1.14.2.3
  --- Expression.java   2001/05/29 14:31:31     1.14.2.2
  +++ Expression.java   2001/05/30 20:31:14     1.14.2.3
  @@ -114,6 +114,26 @@
     {
       m_slocator = locator;
     }
  +  
  +  /**
  +   * Execute an expression in the XPath runtime context, and return the 
  +   * result of the expression.
  +   *
  +   *
  +   * @param xctxt The XPath runtime context.
  +   * @param currentNode The currentNode.
  +   *
  +   * @return The result of the expression in the form of a 
<code>XObject</code>.
  +   *
  +   * @throws javax.xml.transform.TransformerException if a runtime exception 
  +   *         occurs.
  +   */
  +  public XObject execute(XPathContext xctxt, int currentNode)
  +    throws javax.xml.transform.TransformerException
  +  {
  +    // For now, the current node is already pushed.
  +    return execute(xctxt);
  +  }
   
     /**
      * Execute an expression in the XPath runtime context, and return the 
  
  
  
  1.10.2.5  +2 -0      xml-xalan/java/src/org/apache/xpath/NodeSet.java
  
  Index: NodeSet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/NodeSet.java,v
  retrieving revision 1.10.2.4
  retrieving revision 1.10.2.5
  diff -u -r1.10.2.4 -r1.10.2.5
  --- NodeSet.java      2001/05/17 05:38:47     1.10.2.4
  +++ NodeSet.java      2001/05/30 20:31:15     1.10.2.5
  @@ -1185,5 +1185,7 @@
     {
       m_last = last;
     }
  +  
  +  
   
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.13.2.7  +9 -3      
xml-xalan/java/src/org/apache/xpath/axes/WalkerFactory.java
  
  Index: WalkerFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/WalkerFactory.java,v
  retrieving revision 1.13.2.6
  retrieving revision 1.13.2.7
  diff -u -r1.13.2.6 -r1.13.2.7
  --- WalkerFactory.java        2001/05/28 04:07:40     1.13.2.6
  +++ WalkerFactory.java        2001/05/30 20:31:18     1.13.2.7
  @@ -295,10 +295,16 @@
         if(canCrissCross(analysis) && !isSet(analysis, BIT_NAMESPACE) && 
            !isSet(analysis, BIT_FILTER))
         {
  +//        if (DEBUG_ITERATOR_CREATION)
  +//          diagnoseIterator("MatchPatternIterator", analysis, compiler);
  +//
  +//        return new MatchPatternIterator(compiler, opPos, analysis);
           if (DEBUG_ITERATOR_CREATION)
  -          diagnoseIterator("MatchPatternIterator", analysis, compiler);
  +          diagnoseIterator("WalkingIteratorSorted", analysis, compiler);
   
  -        return new MatchPatternIterator(compiler, opPos, analysis);
  +        return new WalkingIteratorSorted(compiler, opPos, analysis, true);
  +
  +
         }
         else
         {
  @@ -449,7 +455,7 @@
     /**
      * Tell if the predicates need to have proximity knowledge.
      */
  -  static boolean mightBeProximate(Compiler compiler, int opPos, int stepType)
  +  public static boolean mightBeProximate(Compiler compiler, int opPos, int 
stepType)
             throws javax.xml.transform.TransformerException
     {
   
  
  
  
  1.1.2.2   +17 -10    
xml-xalan/java/src/org/apache/xpath/axes/Attic/WalkingIterator.java
  
  Index: WalkingIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/Attic/WalkingIterator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- WalkingIterator.java      2001/05/27 02:28:51     1.1.2.1
  +++ WalkingIterator.java      2001/05/30 20:31:19     1.1.2.2
  @@ -60,7 +60,7 @@
     }
     
     /**
  -   * Create a LocPathIterator object.
  +   * Create a WalkingIterator object.
      *
      * @param nscontext The namespace context for this iterator,
      * should be OK if null.
  @@ -73,7 +73,7 @@
   
     
     /**
  -   * Get a cloned LocPathIterator that holds the same
  +   * Get a cloned WalkingIterator that holds the same
      * position as this iterator.
      *
      * @return A clone of this iterator that holds the same node position.
  @@ -123,15 +123,22 @@
   
       // If the cache is on, and the node has already been found, then 
       // just return from the list.
  -    if ((null != m_cachedNodes)
  -            && (m_next < m_cachedNodes.size()))
  +    if (null != m_cachedNodes)
       {
  -      int next = m_cachedNodes.elementAt(m_next);
  -    
  -      incrementNextPosition();
  -      m_currentContextNode = next;
  -
  -      return next;
  +      if(m_next < m_cachedNodes.size())
  +      {
  +        int next = m_lastFetched = m_currentContextNode 
  +                                       = m_cachedNodes.elementAt(m_next);
  +      
  +        incrementNextPosition();
  +  
  +        return next;
  +      }
  +      else if(m_foundLast)
  +      {
  +        m_lastFetched = DTM.NULL;
  +        return DTM.NULL;
  +      }
       }
   
       // If the variable stack position is not -1, we'll have to 
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +145 -0    
xml-xalan/java/src/org/apache/xpath/axes/Attic/WalkingIteratorSorted.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.23.2.5  +1 -1      
xml-xalan/java/src/org/apache/xpath/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/Compiler.java,v
  retrieving revision 1.23.2.4
  retrieving revision 1.23.2.5
  diff -u -r1.23.2.4 -r1.23.2.5
  --- Compiler.java     2001/05/25 17:36:51     1.23.2.4
  +++ Compiler.java     2001/05/30 20:31:22     1.23.2.5
  @@ -937,7 +937,7 @@
         // translate this to a select pattern from the node being tested, 
         // which is really how we're treating match patterns, it works out to 
         // self::foo/parent::node[child::foo[3]]", or close enough.
  -      if(addMagicSelf)
  +      if(addMagicSelf && pattern.getPredicateCount() > 0)
         {
           StepPattern selfPattern = new StepPattern(DTMFilter.SHOW_ALL, 
                                                     Axis.PARENT, Axis.CHILD);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.7.2.6   +42 -0     
xml-xalan/java/src/org/apache/xpath/patterns/FunctionPattern.java
  
  Index: FunctionPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/FunctionPattern.java,v
  retrieving revision 1.7.2.5
  retrieving revision 1.7.2.6
  diff -u -r1.7.2.5 -r1.7.2.6
  --- FunctionPattern.java      2001/05/23 02:57:53     1.7.2.5
  +++ FunctionPattern.java      2001/05/30 20:31:25     1.7.2.6
  @@ -106,7 +106,49 @@
      *  @serial   
      */
     Expression m_functionExpr;
  +  /**
  +   * Test a node to see if it matches the given node test.
  +   *
  +   * @param xctxt XPath runtime context.
  +   *
  +   * @return [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
  +   *         [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_NONE},
  +   *         [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
  +   *         [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
  +   *         [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public XObject execute(XPathContext xctxt, int context)
  +          throws javax.xml.transform.TransformerException
  +  {
   
  +    XObject obj = m_functionExpr.execute(xctxt);
  +    DTMIterator nl = obj.nodeset();
  +    XNumber score = SCORE_NONE;
  +
  +    if (null != nl)
  +    {
  +      int n;
  +
  +      while (DTM.NULL != (n = nl.nextNode()))
  +      {
  +        score = (n == context) ? SCORE_OTHER : SCORE_NONE;
  +
  +        if (score == SCORE_OTHER)
  +        {
  +          context = n;
  +
  +          break;
  +        }
  +      }
  +
  +      // nl.detach();
  +    }
  +
  +    return score;
  +  }
  +  
     /**
      * Test a node to see if it matches the given node test.
      *
  
  
  
  1.19.2.6  +46 -12    
xml-xalan/java/src/org/apache/xpath/patterns/StepPattern.java
  
  Index: StepPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/StepPattern.java,v
  retrieving revision 1.19.2.5
  retrieving revision 1.19.2.6
  diff -u -r1.19.2.5 -r1.19.2.6
  --- StepPattern.java  2001/05/25 17:37:05     1.19.2.5
  +++ StepPattern.java  2001/05/30 20:31:26     1.19.2.6
  @@ -311,7 +311,47 @@
       if (null == m_targetString)
         calcTargetString();
     }
  +  
  +  /**
  +   * Execute this pattern step, including predicates.
  +   *
  +   *
  +   * @param xctxt XPath runtime context.
  +   *
  +   * @return [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
  +   *         [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_NONE},
  +   *         [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
  +   *         [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
  +   *         [EMAIL PROTECTED] 
org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public XObject execute(XPathContext xctxt, int currentNode)
  +          throws javax.xml.transform.TransformerException
  +  {
   
  +    if (m_whatToShow == NodeTest.SHOW_BYFUNCTION)
  +    {
  +      if (null != m_relativePathPattern)
  +      {
  +        return m_relativePathPattern.execute(xctxt, currentNode);
  +      }
  +      else
  +        return NodeTest.SCORE_NONE;
  +    }
  +
  +    if (null == m_relativePathPattern)
  +    {
  +      return super.execute(xctxt, currentNode);
  +    }
  +    else
  +    {
  +      if (super.execute(xctxt, currentNode) == NodeTest.SCORE_NONE)
  +        return NodeTest.SCORE_NONE;
  +      return m_relativePathPattern.executeRelativePathPattern(xctxt, this);
  +    }
  +  }
  +
     /**
      * Execute this pattern step, including predicates.
      *
  @@ -332,17 +372,15 @@
   
       if (m_whatToShow == NodeTest.SHOW_BYFUNCTION)
       {
  -      XObject score = NodeTest.SCORE_NONE;
  -
         if (null != m_relativePathPattern)
         {
  -        score = m_relativePathPattern.execute(xctxt);
  +        return m_relativePathPattern.execute(xctxt);
         }
  -
  -      return score;
  +      else
  +        return NodeTest.SCORE_NONE;
       }
   
  -    XObject score = super.execute(xctxt);
  +    XObject score = super.execute(xctxt, xctxt.getCurrentNode());
   
       if (score == NodeTest.SCORE_NONE)
         return score;
  @@ -353,11 +391,7 @@
       }
       else
       {
  -      // System.out.println("PredicateRoot: "+xctxt.getPredicateRoot());
  -      // int current = xctxt.getCurrentNode();
         return score;
  -      // int parent = xctxt.getDTM(current).getParent(current);
  -      // return executePredicates(xctxt, this, score, current, current);
       }
     }
     
  @@ -393,7 +427,7 @@
           {
             xctxt.pushCurrentNode(child);
   
  -          if (NodeTest.SCORE_NONE != super.execute(xctxt))
  +          if (NodeTest.SCORE_NONE != super.execute(xctxt, child))
             {
               boolean pass = true;
               
  @@ -509,7 +543,7 @@
             {
               xctxt.pushCurrentNode(child);
   
  -            if (NodeTest.SCORE_NONE != super.execute(xctxt))
  +            if (NodeTest.SCORE_NONE != super.execute(xctxt, child))
                 count++;
             }
             finally
  
  
  

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

Reply via email to