You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by pa...@apache.org on 2002/08/14 22:07:10 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath/types Atomizer.java InstanceofExpr.java Promoter.java

pauldick    2002/08/14 13:07:10

  Modified:    java/src/org/apache/xpath Tag: xalan3 CachedXPathAPI.java
                        Expression.java ExpressionOwner.java NodeSet.java
                        NodeSetDTM.java XPath.java XPathAPI.java
                        XPathContext.java XPathVisitor.java
               java/src/org/apache/xpath/axes Tag: xalan3
                        AttributeIterator.java AxesWalker.java
                        BasicTestIterator.java ChildIterator.java
                        ChildTestIterator.java ContextNodeList.java
                        DescendantIterator.java FilterExprIterator.java
                        FilterExprIteratorSimple.java FilterExprWalker.java
                        HasPositionalPredChecker.java LocPathIterator.java
                        MatchPatternIterator.java OneStepIterator.java
                        OneStepIteratorForward.java PredicatedNodeTest.java
                        RTFIterator.java ReverseAxesWalker.java
                        SelfIteratorNoPredicate.java UnionPathIterator.java
                        WalkerFactory.java WalkingIterator.java
                        WalkingIteratorSorted.java
               java/src/org/apache/xpath/functions Tag: xalan3
                        FuncCeiling.java FuncCount.java FuncCurrent.java
                        FuncExtFunction.java FuncExtFunctionAvailable.java
                        FuncFalse.java FuncFloor.java FuncId.java
                        FuncLast.java FuncNumber.java FuncPosition.java
                        FuncRound.java FuncStringLength.java FuncSum.java
                        FuncSystemProperty.java FuncTrue.java Function.java
                        Function2Args.java Function3Args.java
                        FunctionDef1Arg.java FunctionMultiArgs.java
                        FunctionOneArg.java
               java/src/org/apache/xpath/objects Tag: xalan3 XBoolean.java
                        XNodeSet.java XNodeSetForDOM.java XNull.java
                        XNumber.java XObject.java XObjectFactory.java
                        XRTreeFrag.java XRTreeFragSelectWrapper.java
                        XString.java XStringForChars.java
                        XStringForFSB.java
               java/src/org/apache/xpath/operations Tag: xalan3 And.java
                        Div.java Equals.java Gt.java Gte.java Lt.java
                        Lte.java Mod.java Mult.java Neg.java NotEquals.java
                        Number.java Operation.java Or.java Quo.java
                        UnaryOperation.java Variable.java
               java/src/org/apache/xpath/patterns Tag: xalan3
                        ContextMatchStepPattern.java FunctionPattern.java
                        NodeTest.java StepPattern.java UnionPattern.java
               java/src/org/apache/xpath/res Tag: xalan3
                        XPATHErrorResources.java
                        XPATHErrorResources.properties
  Added:       java/src/org/apache/xpath Tag: xalan3
                        VariableComposeState.java
               java/src/org/apache/xpath/conditional Tag: xalan3 Else.java
                        If.java Then.java
               java/src/org/apache/xpath/functions Tag: xalan3
                        FuncAddDTDurationToDT.java
                        FuncAddDTDurationToDate.java
                        FuncAddDTDurationToTime.java
                        FuncAddDayTimeDuration.java FuncAddDays.java
                        FuncAddYMDurationToDT.java
                        FuncAddYMDurationToDate.java
                        FuncAddYearMonthDuration.java FuncCurrentDate.java
                        FuncCurrentDateTime.java FuncDTDuration.java
                        FuncDTDurationEqual.java
                        FuncDTDurationFromSecs.java FuncDTDurationGT.java
                        FuncDTDurationLT.java FuncData.java FuncDate.java
                        FuncDateTime.java FuncDateTimeEq.java
                        FuncDateTimeGT.java FuncDateTimeLT.java
                        FuncDivDayTimeDuration.java
                        FuncDivYearMonthDuration.java FuncDuration.java
                        FuncDurationEqual.java FuncGDay.java
                        FuncGMonth.java FuncGMonthDay.java FuncGYear.java
                        FuncGYearMonth.java FuncGetDFromDT.java
                        FuncGetDFromDTDuration.java FuncGetDFromDate.java
                        FuncGetDTDuration.java FuncGetHFromDT.java
                        FuncGetHFromDTDuration.java FuncGetHFromTime.java
                        FuncGetMFromDT.java FuncGetMFromDate.java
                        FuncGetMFromYMDuration.java FuncGetMnFromDT.java
                        FuncGetMnFromDTDuration.java FuncGetMnFromTime.java
                        FuncGetSFromDT.java FuncGetSFromDTDuration.java
                        FuncGetSFromTime.java FuncGetTZFromDT.java
                        FuncGetTZFromDate.java FuncGetTZFromTime.java
                        FuncGetYFromDT.java FuncGetYFromDate.java
                        FuncGetYFromYMDuration.java FuncGetYMDuration.java
                        FuncMultDayTimeDuration.java
                        FuncMultYearMonthDuration.java
                        FuncSubDayTimeDuration.java
                        FuncSubYearMonthDuration.java
                        FuncSubtractDTDurationFromDT.java
                        FuncSubtractDTDurationFromDate.java
                        FuncSubtractDTDurationFromTime.java
                        FuncSubtractYMDurationFromDT.java
                        FuncSubtractYMDurationFromDate.java FuncTime.java
                        FuncYMDuration.java FuncYMDurationEqual.java
                        FuncYMDurationFromDT.java
                        FuncYMDurationFromMonths.java FuncYMDurationGT.java
                        FuncYMDurationLT.java
               java/src/org/apache/xpath/objects Tag: xalan3
                        NodeSequence.java TypeOperations.java
                        XDTDuration.java XDTMSequence.java XDate.java
                        XDateTime.java XDecimal.java XDouble.java
                        XDuration.java XFloat.java XGDay.java XGMonth.java
                        XGMonthDay.java XGYearMonth.java XGYearObj.java
                        XInteger.java XJavaObject.java
                        XNodeSequenceSingleton.java XSequence.java
                        XSequenceCachedBase.java XSequenceEmpty.java
                        XSequenceImpl.java XSequenceMutable.java
                        XSequenceSingleton.java XTime.java XYMDuration.java
               java/src/org/apache/xpath/operations Tag: xalan3 Add.java
                        Follows.java FortranEq.java FortranGe.java
                        FortranGt.java FortranLe.java FortranLt.java
                        FortranNe.java GenericOpFunc.java GtGt.java
                        Idiv.java Is.java IsNot.java LtLt.java
                        OpFuncLookupTable.java OperationNormalized.java
                        OperationSimple.java Pos.java Precedes.java
                        Subtract.java
               java/src/org/apache/xpath/parser Tag: xalan3
                        ASCII_CharStream.java AnyKindTest.java
                        AtomicType.java CommentTest.java
                        ElemOrAttrType.java Empty.java ForClause.java
                        IfExpr.java In.java Instanceof.java ItemType.java
                        JJTXPathState.java KindTest.java
                        LbrackOrRbrack.java NCNameColonStar.java
                        NameTest.java Node.java NodeTest.java
                        NodeTestType.java NonExecutableExpression.java
                        OccurrenceIndicator.java OfType.java
                        ParseException.java PathExpr.java Pattern.java
                        PatternAxis.java Predicates.java
                        ProcessingInstructionTest.java QName.java
                        QuantifiedExpr.java Return.java RootOfRoot.java
                        RootOfRootPattern.java SchemaContext.java
                        SchemaContextStep.java SchemaGlobalContext.java
                        SchemaType.java SequenceType.java SimpleNode.java
                        SlashOrSlashSlash.java Star.java
                        StarColonNCName.java StepExpr.java
                        TempFunctionHolder.java TextTest.java Token.java
                        TokenMgrError.java UnaryExpr.java XPath.java
                        XPathConstants.java XPathTokenManager.java
                        XPathTreeConstants.java XPathVisitor.java
               java/src/org/apache/xpath/quantified Tag: xalan3 Every.java
                        In.java Satisfies.java Some.java
               java/src/org/apache/xpath/seqctor Tag: xalan3 Binding.java
                        ExprSequence.java ExprSequenceIter.java
                        FLWRExpr.java FLWRIter.java RangeExpr.java
                        RangeIter.java
               java/src/org/apache/xpath/types Tag: xalan3 Atomizer.java
                        InstanceofExpr.java Promoter.java
  Log:
  Xalan3 specific additions and updates
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.12.1  +2 -3      xml-xalan/java/src/org/apache/xpath/CachedXPathAPI.java
  
  Index: CachedXPathAPI.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/CachedXPathAPI.java,v
  retrieving revision 1.2
  retrieving revision 1.2.12.1
  diff -u -r1.2 -r1.2.12.1
  --- CachedXPathAPI.java	11 Dec 2001 17:13:31 -0000	1.2
  +++ CachedXPathAPI.java	14 Aug 2002 20:06:56 -0000	1.2.12.1
  @@ -65,7 +65,6 @@
   
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPath;
  -import org.apache.xpath.compiler.XPathParser;
   import org.apache.xpath.XPathContext;
   import org.apache.xml.utils.PrefixResolverDefault;
   import org.apache.xml.utils.PrefixResolver;
  @@ -319,7 +318,7 @@
         ? ((Document) namespaceNode).getDocumentElement() : namespaceNode);
   
       // Create the XPath object.
  -    XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);
  +    XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null, 1.0);
   
       // Execute the XPath, and have it return the result
       // return xpath.execute(xpathSupport, contextNode, prefixResolver);
  @@ -361,7 +360,7 @@
       //    because XPathContext is weak in a number of areas... perhaps
       //    XPathContext should be done away with.)
       // Create the XPath object.
  -    XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);
  +    XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null, 1.0);
   
       // Execute the XPath, and have it return the result
       XPathContext xpathSupport = new XPathContext();
  
  
  
  1.18.4.1  +44 -30    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.18
  retrieving revision 1.18.4.1
  diff -u -r1.18 -r1.18.4.1
  --- Expression.java	22 Mar 2002 01:04:42 -0000	1.18
  +++ Expression.java	14 Aug 2002 20:06:56 -0000	1.18.4.1
  @@ -57,25 +57,21 @@
   package org.apache.xpath;
   
   //import org.w3c.dom.Node;
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNodeSet;
  -import org.apache.xpath.res.XPATHErrorResources;
  -import org.apache.xalan.res.XSLMessages;
  +import java.io.Serializable;
  +import java.util.Vector;
   
  -import org.xml.sax.XMLReader;
  -import org.xml.sax.ContentHandler;
  -
  -import javax.xml.transform.TransformerConfigurationException;
  +import javax.xml.transform.ErrorListener;
   import javax.xml.transform.TransformerException;
  -
  -import org.apache.xml.utils.SAXSourceLocator;
  -import org.apache.xml.utils.PrefixResolver;
  -import org.apache.xml.utils.XMLString;
  -import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xalan.res.XSLMessages;
   import org.apache.xml.dtm.DTM;
  -
  -import javax.xml.transform.SourceLocator;
  -import javax.xml.transform.ErrorListener;
  +import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xml.utils.XMLString;
  +import org.apache.xpath.objects.XNodeSet;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.parser.SimpleNode;
  +import org.apache.xpath.res.XPATHErrorResources;
  +import org.xml.sax.ContentHandler;
  +import org.xml.sax.SAXException;
   
   /**
    * This abstract class serves as the base for all expression objects.  An
  @@ -86,8 +82,15 @@
    * and walkers, which must be cloned in order to be used -- the original must
    * still be immutable.
    */
  -public abstract class Expression implements java.io.Serializable, ExpressionNode, XPathVisitable
  +public abstract class Expression extends SimpleNode 
  +	implements java.io.Serializable, ExpressionNode, XPathVisitable
   {
  +	
  +  public Expression()
  +  {
  +  	super();
  +  }
  +  
   
     /**
      * The location where this expression was built from.  Need for diagnostic
  @@ -291,7 +294,8 @@
   
       try
       {
  -      xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
  +      xctxt.pushCurrentNode(contextNode);
  +      xctxt.pushCurrentExpressionNode(contextNode);
   
         return execute(xctxt).iter();
       }
  @@ -322,7 +326,8 @@
   
       try
       {
  -      xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
  +      xctxt.pushCurrentNode(contextNode);
  +      xctxt.pushCurrentExpressionNode(contextNode);
   
         XNodeSet nodeset = (XNodeSet)execute(xctxt);
         return nodeset.iterRaw();
  @@ -374,17 +379,10 @@
     }
   
     /**
  -   * This function is used to fixup variables from QNames to stack frame
  -   * indexes at stylesheet build time.
  -   * @param vars List of QNames that correspond to variables.  This list
  -   * should be searched backwards for the first qualified name that
  -   * corresponds to the variable reference qname.  The position of the
  -   * QName in the vector from the start of the vector will be its position
  -   * in the stack frame (but variables above the globalsTop value will need
  -   * to be offset to the current stack frame).
  -   * NEEDSDOC @param globalsSize
  +   * Fix up variables from QNames to stack frame
  +   * @param vcs Interface to variable stack composition interface.
      */
  -  public abstract void fixupVariables(java.util.Vector vars, int globalsSize);
  +  public abstract void fixupVariables(VariableComposeState vcs);
     
     /**
      * Compare this object with another object and see 
  @@ -464,7 +462,9 @@
           XPATHErrorResources.ER_INCORRECT_PROGRAMMER_ASSERTION,
           new Object[]{ msg });
   
  -      throw new RuntimeException(fMsg);
  +      RuntimeException a = new RuntimeException(fMsg);
  +      a.printStackTrace();
  +      throw a;
       }
     }
   
  @@ -531,6 +531,7 @@
     public void exprAddChild(ExpressionNode n, int i)
     {
     	assertion(false, "exprAddChild method not implemented!");
  +  	
     }
   
     /** This method returns a child node.  The children are numbered
  @@ -630,4 +631,17 @@
     	  return 0;
     	return m_parent.getColumnNumber();
     }
  +  
  +  /**
  +   * Clone this object, but make certian it is deep.  This is useful 
  +   * for derived classes that may want the default clone to be 
  +   * light weight, but then want to deep clone in some special cases.
  +   * @see java.lang.Object#clone()
  +   */
  +  public Object cloneDeep() throws CloneNotSupportedException
  +  {
  +    XNodeSet xns = (XNodeSet)clone();
  +    return xns;
  +  }
  +
   }
  
  
  
  1.1.4.1   +1 -2      xml-xalan/java/src/org/apache/xpath/ExpressionOwner.java
  
  Index: ExpressionOwner.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/ExpressionOwner.java,v
  retrieving revision 1.1
  retrieving revision 1.1.4.1
  diff -u -r1.1 -r1.1.4.1
  --- ExpressionOwner.java	22 Mar 2002 01:04:42 -0000	1.1
  +++ ExpressionOwner.java	14 Aug 2002 20:06:56 -0000	1.1.4.1
  @@ -19,7 +19,6 @@
      * @param exp the raw Expression object, which should not normally be null.
      */
     public void setExpression(Expression exp);
  -
  -
  +  
   }
   
  
  
  
  1.15.2.1  +6 -6      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.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- NodeSet.java	27 Jun 2002 14:50:12 -0000	1.15
  +++ NodeSet.java	14 Aug 2002 20:06:56 -0000	1.15.2.1
  @@ -307,7 +307,7 @@
   
       if (!m_cacheNodes)
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_CANNOT_ITERATE, null)); //"This NodeSet can not iterate to a previous node!");
  +        "This NodeSet can not iterate to a previous node!");
   
       if ((m_next - 1) > 0)
       {
  @@ -362,7 +362,7 @@
   
       if (!m_cacheNodes)
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_CANNOT_INDEX, null)); //"This NodeSet can not do indexing or counting functions!");
  +        "This NodeSet can not do indexing or counting functions!");
   
       if ((index >= 0) && (m_next < m_firstFree))
         m_next = index;
  @@ -785,7 +785,7 @@
   
       if (!m_cacheNodes)
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_CANNOT_INDEX, null)); //"This NodeSet can not do indexing or counting functions!");
  +        "This NodeSet can not do indexing or counting functions!");
   
       m_next = i;
     }
  @@ -802,7 +802,7 @@
   
       if (!m_cacheNodes)
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_CANNOT_INDEX, null)); //"This NodeSet can not do indexing or counting functions!");
  +        "This NodeSet can not do indexing or counting functions!");
   
       int saved = m_next;
       Node n = (m_next < m_firstFree) ? elementAt(m_next) : null;
  @@ -839,12 +839,12 @@
      * request caching after we've already begun stepping through the
      * nodes in this set.
     */
  -  public void setShouldCacheNodes(boolean b)
  +  public void setShouldCache(boolean b)
     {
   
       if (!isFresh())
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_CALL_SETSHOULDCACHENODE, null)); //"Can not call setShouldCacheNodes after nextNode has been called!");
  +        "Can not call setShouldCacheNodes after nextNode has been called!");
   
       m_cacheNodes = b;
       m_mutable = true;
  
  
  
  1.10.2.1  +5 -5      xml-xalan/java/src/org/apache/xpath/NodeSetDTM.java
  
  Index: NodeSetDTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/NodeSetDTM.java,v
  retrieving revision 1.10
  retrieving revision 1.10.2.1
  diff -u -r1.10 -r1.10.2.1
  --- NodeSetDTM.java	27 Jun 2002 14:50:12 -0000	1.10
  +++ NodeSetDTM.java	14 Aug 2002 20:06:57 -0000	1.10.2.1
  @@ -455,7 +455,7 @@
   
       if (!m_cacheNodes)
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_ITERATE, null)); //"This NodeSetDTM can not iterate to a previous node!");
  +        "This NodeSetDTM can not iterate to a previous node!");
   
       if ((m_next - 1) > 0)
       {
  @@ -522,7 +522,7 @@
   
       if (!m_cacheNodes)
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null)); //"This NodeSetDTM can not do indexing or counting functions!");
  +        "This NodeSetDTM can not do indexing or counting functions!");
   
       if ((index >= 0) && (m_next < m_firstFree))
         m_next = index;
  @@ -1174,7 +1174,7 @@
   
       if (!m_cacheNodes)
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null)); //"This NodeSetDTM can not do indexing or counting functions!");
  +        "This NodeSetDTM can not do indexing or counting functions!");
   
       m_next = i;
     }
  @@ -1235,12 +1235,12 @@
      * request caching after we've already begun stepping through the
      * nodes in this set.
     */
  -  public void setShouldCacheNodes(boolean b)
  +  public void setShouldCache(boolean b)
     {
   
       if (!isFresh())
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_CALL_SETSHOULDCACHENODE, null)); //"Can not call setShouldCacheNodes after nextNode has been called!");
  +        "Can not call setShouldCacheNodes after nextNode has been called!");
   
       m_cacheNodes = b;
       m_mutable = true;
  
  
  
  1.24.2.1  +209 -46   xml-xalan/java/src/org/apache/xpath/XPath.java
  
  Index: XPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPath.java,v
  retrieving revision 1.24
  retrieving revision 1.24.2.1
  diff -u -r1.24 -r1.24.2.1
  --- XPath.java	13 May 2002 18:43:38 -0000	1.24
  +++ XPath.java	14 Aug 2002 20:06:57 -0000	1.24.2.1
  @@ -57,21 +57,24 @@
   package org.apache.xpath;
   
   import java.io.Serializable;
  +import java.io.StringReader;
   import java.util.Vector;
   
   import javax.xml.transform.ErrorListener;
   import javax.xml.transform.SourceLocator;
   import javax.xml.transform.TransformerException;
  +
  +import org.apache.xalan.processor.StylesheetHandler;
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.utils.PrefixResolver;
  +import org.apache.xml.utils.QName;
   import org.apache.xml.utils.SAXSourceLocator;
   import org.apache.xml.utils.WrappedRuntimeException;
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.compiler.FunctionTable;
  -import org.apache.xpath.compiler.XPathParser;
   import org.apache.xpath.functions.Function;
  +import org.apache.xpath.objects.XNodeSequenceSingleton;
   import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.parser.ParseException;
   import org.apache.xpath.res.XPATHErrorResources;
   import org.w3c.dom.Node;
   
  @@ -108,9 +111,9 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    m_mainExp.fixupVariables(vars, globalsSize);
  +    m_mainExp.fixupVariables(vcs);
     }
   
     /**
  @@ -171,11 +174,13 @@
     /** Represents a match type expression.  */
     public static final int MATCH = 1;
   
  +  public static boolean DEBUG_DUMP_EXPRS = false;
  +  public static boolean DEBUG_CHECK_TREE_INTEGRITY = true; // leave as true for a while...
  +
     /**
  -   * Construct an XPath object.  
  -   *
  -   * (Needs review -sc) This method initializes an XPathParser/
  +   * Construct an XPath object. This method initializes an XPathParser/
      * Compiler and compiles the expression.
  +   * 
      * @param exprString The XPath expression.
      * @param locator The location of the expression, may be null.
      * @param prefixResolver A prefix resolver to use to resolve prefixes to 
  @@ -183,11 +188,12 @@
      * @param type one of {@link #SELECT} or {@link #MATCH}.
      * @param errorListener The error listener, or null if default should be used.
      *
  +   * @param version The version of XPath being used.
      * @throws javax.xml.transform.TransformerException if syntax or other error.
      */
     public XPath(
             String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type,
  -          ErrorListener errorListener)
  +          ErrorListener errorListener, double version)
               throws javax.xml.transform.TransformerException
     {      
       if(null == errorListener)
  @@ -195,18 +201,53 @@
       
       m_patternString = exprString;
   
  -    XPathParser parser = new XPathParser(errorListener, locator);
  -    Compiler compiler = new Compiler(errorListener, locator);
  -
  -    if (SELECT == type)
  -      parser.initXPath(compiler, exprString, prefixResolver);
  -    else if (MATCH == type)
  -      parser.initMatchPattern(compiler, exprString, prefixResolver);
  -    else
  -      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, new Object[]{Integer.toString(type)})); //"Can not deal with XPath type: " + type);
  -
  -    // System.out.println("----------------");
  -    Expression expr = compiler.compile(0);
  +    // TBD: Figure out what to do with errorListener and locator in new world.
  +    // errorListener, locator
  +    if(DEBUG_DUMP_EXPRS)
  +    	System.out.println("expr: "+exprString);
  +    	
  +    StringReader exprReader = new StringReader(exprString);
  +   
  +    org.apache.xpath.parser.XPath parser = new org.apache.xpath.parser.XPath(exprReader);
  +    
  +    if(DEBUG_CHECK_TREE_INTEGRITY)
  +    {   
  +      assertion(null != prefixResolver, 
  +                " prefixResolver can not be null!");
  +      assertion(!(prefixResolver instanceof StylesheetHandler), 
  +                " prefixResolver can not be a StylesheetHandler!");
  +    }
  +    parser.setPrefixResolver(prefixResolver);
  +    parser.setVersion(version);
  +    Expression rootOfRoot;
  +	try
  +	{
  +		if (SELECT == type)
  +    		rootOfRoot = (Expression)parser.XPath2();
  +    	else if (MATCH == type)
  +    		rootOfRoot = (Expression)parser.MatchPattern();
  +    	else
  +      		throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, new Object[]{Integer.toString(type)})); //"Can not deal with XPath type: " + type);
  +	}
  +	catch(org.apache.xpath.parser.ParseException pe)
  +	{
  +		TransformerException te = new TransformerException(pe);
  +		te.setLocator(locator);
  +		throw te;
  +	}
  +	Expression expr = (Expression)rootOfRoot.jjtGetChild(0);
  +	
  +	if(DEBUG_CHECK_TREE_INTEGRITY)
  +	{
  +		if(false == expr.checkTreeIntegrity())
  +		{
  +			System.err.println("Expression is NOT OK: "+m_patternString);
  +			expr.dump("| ");
  +		}
  +	}
  +	
  +	if(DEBUG_DUMP_EXPRS)
  +		expr.dump("| ");
   
       // System.out.println("expr: "+expr);
       this.setExpression(expr);
  @@ -218,25 +259,25 @@
   
     }
     
  -  /**
  -   * Construct an XPath object.  
  -   *
  -   * (Needs review -sc) This method initializes an XPathParser/
  -   * Compiler and compiles the expression.
  -   * @param exprString The XPath expression.
  -   * @param locator The location of the expression, may be null.
  -   * @param prefixResolver A prefix resolver to use to resolve prefixes to 
  -   *                       namespace URIs.
  -   * @param type one of {@link #SELECT} or {@link #MATCH}.
  -   *
  -   * @throws javax.xml.transform.TransformerException if syntax or other error.
  -   */
  -  public XPath(
  -          String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type)
  -            throws javax.xml.transform.TransformerException
  -  {  
  -    this(exprString, locator, prefixResolver, type, null);    
  -  }
  +//  /**
  +//   * Construct an XPath object.  
  +//   *
  +//   * (Needs review -sc) This method initializes an XPathParser/
  +//   * Compiler and compiles the expression.
  +//   * @param exprString The XPath expression.
  +//   * @param locator The location of the expression, may be null.
  +//   * @param prefixResolver A prefix resolver to use to resolve prefixes to 
  +//   *                       namespace URIs.
  +//   * @param type one of {@link #SELECT} or {@link #MATCH}.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException if syntax or other error.
  +//   */
  +//  public XPath(
  +//          String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type)
  +//            throws javax.xml.transform.TransformerException
  +//  {  
  +//    this(exprString, locator, prefixResolver, type, null);    
  +//  }
   
     /**
      * Construct an XPath object.
  @@ -276,7 +317,6 @@
             namespaceContext);
     }
     
  -
     /**
      * <meta name="usage" content="experimental"/>
      * Given an expression and a context, evaluate the XPath
  @@ -296,10 +336,109 @@
             XPathContext xctxt, int contextNode, PrefixResolver namespaceContext)
               throws javax.xml.transform.TransformerException
     {
  +    xctxt.pushNamespaceContext(namespaceContext);
  +    xctxt.pushCurrentNode(contextNode);
  +    xctxt.pushCurrentExpressionNode(contextNode);
  +    try
  +    {
  +      return execute(xctxt, namespaceContext);
  +    }
  +    finally
  +    {
  +      xctxt.popNamespaceContext();
  +
  +      xctxt.popCurrentNodeAndExpression();
  +    }
  +
  +  }
  +  
  +
  +  /**
  +   * <meta name="usage" content="experimental"/>
  +   * Given an expression, evaluate the XPath
  +   * and return the result. The method does not push the current context node!
  +   * 
  +   * @param xctxt The execution context.
  +   * @param namespaceContext The context in which namespaces in the
  +   * XPath are supposed to be expanded.
  +   * 
  +   * @throws TransformerException thrown if the active ProblemListener decides
  +   * the error condition is severe enough to halt processing.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public XObject execute(
  +          XPathContext xctxt, PrefixResolver namespaceContext)
  +            throws javax.xml.transform.TransformerException
  +  {
  +    XObject xobj = null;
  +
  +    try
  +    {
  +      xobj = m_mainExp.execute(xctxt);
  +    }
  +    catch (TransformerException te)
  +    {
  +      te.setLocator(this.getLocator());
  +      ErrorListener el = xctxt.getErrorListener();
  +      if(null != el) // defensive, should never happen.
  +      {
  +        el.error(te);
  +      }
  +      else
  +        throw te;
  +    }
  +    catch (Exception e)
  +    {
  +      while (e instanceof org.apache.xml.utils.WrappedRuntimeException)
  +      {
  +        e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
  +      }
  +      // e.printStackTrace();
  +
  +      String msg = e.getMessage();
  +      msg = (msg == null || msg.length()== 0)? "Unknown error in XPath" : msg;
  +      TransformerException te = new TransformerException(msg,
  +              getLocator(), e);
  +      ErrorListener el = xctxt.getErrorListener();
  +      // te.printStackTrace();
  +      if(null != el) // defensive, should never happen.
  +      {
  +        el.fatalError(te);
  +      }
  +      else
  +        throw te;
  +    }
  +
  +    return xobj;
  +  }
  +  
  +  /**
  +   * <meta name="usage" content="experimental"/>
  +   * Given an expression and a context, evaluate the XPath
  +   * and return the result.
  +   * 
  +   * @param xctxt The execution context.
  +   * @param contextNode The node that "." expresses.
  +   * @param namespaceContext The context in which namespaces in the
  +   * XPath are supposed to be expanded.
  +   * 
  +   * @throws TransformerException thrown if the active ProblemListener decides
  +   * the error condition is severe enough to halt processing.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public XObject execute(
  +          XPathContext xctxt, XObject contextItem, PrefixResolver namespaceContext)
  +            throws javax.xml.transform.TransformerException
  +  {
   
       xctxt.pushNamespaceContext(namespaceContext);
   
  -    xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
  +    xctxt.pushCurrentItem(contextItem);
  +    int node = contextItem.getNodeHandle();
  +    if(DTM.NULL != node)
  +      xctxt.pushCurrentExpressionNode(node);
   
       XObject xobj = null;
   
  @@ -343,11 +482,14 @@
       {
         xctxt.popNamespaceContext();
   
  -      xctxt.popCurrentNodeAndExpression();
  +      xctxt.popCurrentItem();
  +      if(DTM.NULL != node)
  +        xctxt.popCurrentExpressionNode();
       }
   
       return xobj;
     }
  +
     
     /**
      * <meta name="usage" content="experimental"/>
  @@ -371,8 +513,9 @@
   
       xctxt.pushNamespaceContext(namespaceContext);
   
  -    xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
  -
  +    xctxt.pushCurrentNode(contextNode);
  +    xctxt.pushCurrentExpressionNode(contextNode);
  +    
       try
       {
         return m_mainExp.bool(xctxt);
  @@ -453,6 +596,9 @@
                              + dtm.getNodeName(context) + " for xpath "
                              + this.getPatternString());
         }
  +      
  +      if(null == score)
  +        throw new RuntimeException("What??");
   
         return score.num();
       }
  @@ -474,8 +620,25 @@
      */
     public void installFunction(String name, int funcIndex, Function func)
     {
  -    FunctionTable.installFunction(func, funcIndex);
  +  	// TBD: Figure out proper construction of qname from name.
  +  	QName qname = new QName(name);
  +  	org.apache.xpath.parser.SimpleNode.m_builtInFunctions.put(name, func);
  +    // FunctionTable.installFunction(func, funcIndex);
  +  }
  +  
  +  /**
  +   * Install a built-in function.
  +   * @param name The unqualified name of the function; not currently used.
  +   * @param funcIndex The index of the function in the table.
  +   * @param func An Implementation of an XPath Function object.
  +   * @return the position of the function in the internal index.
  +   */
  +  public void installFunction(QName qname, Function func)
  +  {
  +  	org.apache.xpath.parser.SimpleNode.m_builtInFunctions.put(qname, func);
  +    // FunctionTable.installFunction(func, funcIndex);
     }
  +
   
     /**
      * Warn the user of an problem.
  
  
  
  1.14.12.1 +2 -3      xml-xalan/java/src/org/apache/xpath/XPathAPI.java
  
  Index: XPathAPI.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathAPI.java,v
  retrieving revision 1.14
  retrieving revision 1.14.12.1
  diff -u -r1.14 -r1.14.12.1
  --- XPathAPI.java	29 Nov 2001 16:30:47 -0000	1.14
  +++ XPathAPI.java	14 Aug 2002 20:06:57 -0000	1.14.12.1
  @@ -65,7 +65,6 @@
   
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPath;
  -import org.apache.xpath.compiler.XPathParser;
   import org.apache.xpath.XPathContext;
   import org.apache.xml.utils.PrefixResolverDefault;
   import org.apache.xml.utils.PrefixResolver;
  @@ -276,7 +275,7 @@
         ? ((Document) namespaceNode).getDocumentElement() : namespaceNode);
   
       // Create the XPath object.
  -    XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);
  +    XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null, 1.0);
   
       // Execute the XPath, and have it return the result
       // return xpath.execute(xpathSupport, contextNode, prefixResolver);
  @@ -318,7 +317,7 @@
       //    because XPathContext is weak in a number of areas... perhaps
       //    XPathContext should be done away with.)
       // Create the XPath object.
  -    XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);
  +    XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null, 1.0);
   
       // Execute the XPath, and have it return the result
       XPathContext xpathSupport = new XPathContext();
  
  
  
  1.40.2.1  +432 -43   xml-xalan/java/src/org/apache/xpath/XPathContext.java
  
  Index: XPathContext.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathContext.java,v
  retrieving revision 1.40
  retrieving revision 1.40.2.1
  diff -u -r1.40 -r1.40.2.1
  --- XPathContext.java	10 Jun 2002 19:24:42 -0000	1.40
  +++ XPathContext.java	14 Aug 2002 20:06:57 -0000	1.40.2.1
  @@ -71,17 +71,21 @@
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xml.utils.QName;
   import org.apache.xml.utils.NodeVector;
  +import org.apache.xml.utils.WrappedRuntimeException;
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.res.XPATHErrorResources;
   import org.apache.xpath.axes.ContextNodeList;
   import org.apache.xpath.axes.SubContextList;
  +import org.apache.xpath.objects.XNodeSequenceSingleton;
   import org.apache.xpath.objects.XObject;
   import org.apache.xpath.objects.XNodeSet;
  +import org.apache.xpath.objects.XSequence;
   import org.apache.xpath.objects.XString;
   
   import org.apache.xalan.extensions.ExpressionContext;
   
   // SAX2 imports
  +import org.w3c.dom.traversal.NodeIterator;
   import org.xml.sax.InputSource;
   import org.xml.sax.XMLReader;
   // import org.xml.sax.Locator;
  @@ -112,13 +116,19 @@
   import org.apache.xpath.axes.DescendantIterator;
   
   // For  handling.
  -import org.apache.xml.dtm.ref.sax2dtm.SAX2RTFDTM;
  +import org.apache.xml.dtm.ref.sax2dtm.SAX2DTM;
   
   /**
    * <meta name="usage" content="advanced"/>
    * Default class for the runtime execution context for XPath.
    * 
  - * <p>This class extends DTMManager but does not directly implement it.</p>
  + * <p>XPathContext has been enhanced to carry the proposed "static context"
  + * information for XPath 2.0. This sketch was initially based on
  + * http://www.w3.org/TR/2002/WD-xpath20-2002043
  + * </p> 
  + * 
  + * <p>This class extends DTMManager but does not directly implement it;
  + * instead, it operates as proxy for an actual DTMManager.</p>
    */
   public class XPathContext extends DTMManager // implements ExpressionContext
   {
  @@ -141,7 +151,7 @@
      * Most recent "reusable" DTM for Global Result Tree Fragments. No stack is
      * required since we're never going to pop these.
      */
  -  private SAX2RTFDTM m_global_rtfdtm=null;
  +  private SAX2DTM m_global_rtfdtm=null;
     
   	
     /**
  @@ -342,8 +352,8 @@
     public XPathContext()
     {
       m_prefixResolvers[m_prefixResolversTop++] = null;
  -    m_currentNodes[m_currentNodesFirstFree++] = DTM.NULL;
  -    m_currentNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
  +    m_currentItems[m_currentNodesFirstFree++] = XSequence.EMPTY;
  +    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
       m_saxLocations[m_saxLocationsTop++] = null;
     }
   
  @@ -360,8 +370,8 @@
       }
       catch (NoSuchMethodException nsme) {}
       m_prefixResolvers[m_prefixResolversTop++] = null;
  -    m_currentNodes[m_currentNodesFirstFree++] = DTM.NULL;
  -    m_currentNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
  +    m_currentItems[m_currentNodesFirstFree++] = XSequence.EMPTY;
  +    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
       m_saxLocations[m_saxLocationsTop++] = null;
     }
   
  @@ -392,7 +402,7 @@
   	m_contextNodeLists = new Stack();
   	m_currentExpressionNodes = new int[RECURSIONLIMIT];
   	m_currentExpressionNodesFirstFree = 0;
  -	m_currentNodes = new int[RECURSIONLIMIT];
  +	m_currentItems = new XObject[RECURSIONLIMIT];
   	m_currentNodesFirstFree = 0;
   	m_iteratorRoots = new NodeVector();
   	m_predicatePos = new IntStack();
  @@ -401,8 +411,8 @@
   	int m_prefixResolversTop = 0;
   	
   	m_prefixResolvers[m_prefixResolversTop++] = null;
  -    m_currentNodes[m_currentNodesFirstFree++] = DTM.NULL;
  -    m_currentNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
  +    m_currentItems[m_currentNodesFirstFree++] = XSequence.EMPTY;
  +    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = DTM.NULL;
       m_saxLocations[m_saxLocationsTop++] = null;
     }
   
  @@ -690,14 +700,51 @@
      * @return  the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
      * also refered to here as a <term>context node list</term>.
      */
  -  public final DTMIterator getContextNodeList()
  +  public final XSequence getContextSequence()
     {
   
       if (m_contextNodeLists.size() > 0)
  -      return (DTMIterator) m_contextNodeLists.peek();
  +      return (XSequence) m_contextNodeLists.peek();
       else
         return null;
     }
  +  
  +  /**
  +   * Get the current context node list.
  +   *
  +   * @return  the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
  +   * also refered to here as a <term>context node list</term>.
  +   */
  +  public final DTMIterator getContextNodeList()
  +  {
  +
  +    try
  +    {
  +      if (m_contextNodeLists.size() > 0)
  +      {
  +        Object contextSequence = m_contextNodeLists.peek();
  +        if (contextSequence instanceof DTMIterator)
  +        {
  +          return (DTMIterator) contextSequence;
  +        }
  +        else
  +          if (contextSequence instanceof XObject)
  +          {
  +            return ((XObject) contextSequence).iter();
  +          }
  +          else
  +          {
  +            return null; // or error
  +          }
  +      }
  +      else
  +        return null;
  +    }
  +    catch (TransformerException e)
  +    {
  +      throw new WrappedRuntimeException(e);
  +    }
  +  }
   
     /**
      * <meta name="usage" content="internal"/>
  @@ -706,22 +753,54 @@
      * @param nl the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
      * also refered to here as a <term>context node list</term>.
      */
  -  public final void pushContextNodeList(DTMIterator nl)
  +  public final void pushContextSequence(XSequence xseq)
     {
  -    m_contextNodeLists.push(nl);
  +    m_contextNodeLists.push(xseq);
     }
   
     /**
      * <meta name="usage" content="internal"/>
      * Pop the current context node list.
      */
  -  public final void popContextNodeList()
  +  public final void popContextSequence()
     {
     	if(m_contextNodeLists.isEmpty())
     	  System.err.println("Warning: popContextNodeList when stack is empty!");
     	else
         m_contextNodeLists.pop();
     }
  +  
  +/**
  +   * <meta name="usage" content="internal"/>
  +   * Set the current context node list.
  +   *
  +   * @param nl the <a href="http://www.w3.org/TR/xslt#dt-current-node-list">current node list</a>,
  +   * also refered to here as a <term>context node list</term>.
  +   */
  +  public final void pushContextNodeList(DTMIterator iterator)
  +  {
  +    if(iterator instanceof XSequence)
  +      m_contextNodeLists.push((XSequence)iterator);
  +    else
  +    {
  +      XNodeSet nodeset = new XNodeSet(iterator);
  +      nodeset.setCurrentPos(iterator.getCurrentPos());
  +      m_contextNodeLists.push(nodeset);
  +    }
  +  }
  +
  +  /**
  +   * <meta name="usage" content="internal"/>
  +   * Pop the current context node list.
  +   */
  +  public final void popContextNodeList()
  +  {
  +    if(m_contextNodeLists.isEmpty())
  +      System.err.println("Warning: popContextNodeList when stack is empty!");
  +    else
  +      m_contextNodeLists.pop();
  +  }
  +
   
     /**
      * The ammount to use for stacks that record information during the 
  @@ -733,13 +812,14 @@
      *  Not to be confused with the current node list.  %REVIEW% Note that there 
      *  are no bounds check and resize for this stack, so if it is blown, it's all 
      *  over.  */
  -  private int m_currentNodes[] = new int[RECURSIONLIMIT];
  +  private XObject m_currentItems[] = new XObject[RECURSIONLIMIT];
  +  
     protected int m_currentNodesFirstFree = 0;
      
   //  private NodeVector m_currentNodes = new NodeVector();
     
  -  public int[] getCurrentNodeStack() {return m_currentNodes; }
  -  public void setCurrentNodeStack(int[] nv) { m_currentNodes = nv; }
  +//  public XObject[] getCurrentItemStack() {return m_currentItems; }
  +  public void setCurrentNodeStack(XObject[] nv) { m_currentItems = nv; }
   
     /**
      * Get the current context node.
  @@ -748,7 +828,71 @@
      */
     public final int getCurrentNode()
     {
  -    return m_currentNodes[m_currentNodesFirstFree-1];
  +    XObject current = m_currentItems[m_currentNodesFirstFree - 1];
  +    if (current instanceof XNodeSequenceSingleton)
  +      return ((XNodeSequenceSingleton) current).getNodeHandle();
  +//    else if (current instanceof DTMIterator)
  +//      return ((DTMIterator) current).getCurrentNode();
  +    else
  +      return DTM.NULL;
  +  }
  +  
  +  /**
  +   * Get the current context node.
  +   *
  +   * @return the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  +   */
  +  public final XObject getCurrentItem()
  +  {
  +    return m_currentItems[m_currentNodesFirstFree - 1];
  +  }
  +  
  +  /**
  +   * Set the current context node.
  +   *
  +   * @param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  +   */
  +  public final void setCurrentItem(XObject cn)
  +  {
  +    m_currentItems[m_currentNodesFirstFree - 1] = cn;
  +  }
  +
  +  
  +  /**
  +   * Set the current context node.
  +   *
  +   * @param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  +   */
  +  public final void setCurrentNode(int cn)
  +  {
  +    DTM dtm = m_dtmManager.getDTM(cn);
  +    m_currentItems[m_currentNodesFirstFree - 1] = new XNodeSequenceSingleton(cn, dtm);
  +  }
  +
  +  
  +  /**
  +   * Set the current context node and expression node.
  +   *
  +   * @param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  +   * @param en the sub-expression context node.
  +   */
  +  public final void pushCurrentItemAndExpression(XObject cn, int en)
  +  {
  +    m_currentItems[m_currentNodesFirstFree++] = cn;
  +    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = en;
  +  }
  +  
  +  /**
  +   * Set the current context node and expression node.
  +   *
  +   * @param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  +   * @param en the sub-expression context node.
  +   * @deprecated
  +   */
  +  public final void pushCurrentItemAndExpression(int cn, int en)
  +  {
  +    pushCurrentNode(cn);
  +    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = en;
     }
     
     /**
  @@ -756,13 +900,16 @@
      *
      * @param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
      * @param en the sub-expression context node.
  +   * @deprecated
      */
     public final void pushCurrentNodeAndExpression(int cn, int en)
     {
  -    m_currentNodes[m_currentNodesFirstFree++] = cn;
  -    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = cn;
  +    pushCurrentNode(cn);
  +    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = en;
     }
   
  +
  +
     /**
      * Set the current context node.
      */
  @@ -779,12 +926,28 @@
      * @param en the sub-expression context node.
      * @param nc the namespace context (prefix resolver.
      */
  +  public final void pushExpressionState(XObject cn, int en, PrefixResolver nc)
  +  {
  +    m_currentItems[m_currentNodesFirstFree++] = cn;
  +    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = en;
  +    m_prefixResolvers[m_prefixResolversTop++] = nc;
  +  }
  +  
  +  /**
  +   * Push the current context node, expression node, and prefix resolver.
  +   *
  +   * @param cn the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  +   * @param en the sub-expression context node.
  +   * @param nc the namespace context (prefix resolver.
  +   * @deprecated
  +   */
     public final void pushExpressionState(int cn, int en, PrefixResolver nc)
     {
  -    m_currentNodes[m_currentNodesFirstFree++] = cn;
  -    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = cn;
  +    pushCurrentNode(cn);
  +    m_currentExpressionNodes[m_currentExpressionNodesFirstFree++] = en;
       m_prefixResolvers[m_prefixResolversTop++] = nc;
     }
  +
     
     /**
      * Pop the current context node, expression node, and prefix resolver.
  @@ -796,31 +959,79 @@
       m_prefixResolversTop--;
     }
   
  -
  -
     /**
      * Set the current context node.
      *
      * @param n the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  +   * @deprecated
      */
  -  public final void pushCurrentNode(int n)
  +  public final void pushCurrentNode(int nodeHandle)
     {
  -    m_currentNodes[m_currentNodesFirstFree++] = n;
  +    DTM dtm = getDTM(nodeHandle);
  +    XNodeSequenceSingleton xseq = new XNodeSequenceSingleton(nodeHandle, dtm);
  +    // xseq.next(); // so get current will work.  Is this right? -sb
  +    m_currentItems[m_currentNodesFirstFree++] = xseq;
     }
     
  -  public int getCurrentNodeFirstFree()
  +  /**
  +   * Pop the current context node.
  +   * @deprecated
  +   */
  +  public final void popCurrentNode()
     {
  -    return m_currentNodesFirstFree;
  +    m_currentNodesFirstFree--;
     }
   
     /**
  +   * Set the current context node.
  +   *
  +   * @param n the <a href="http://www.w3.org/TR/xslt#dt-current-node">current node</a>.
  +   */
  +  public final void pushCurrentItem(XObject xobj)
  +  {
  +    m_currentItems[m_currentNodesFirstFree++] = xobj;
  +  }
  +  
  +  /**
      * Pop the current context node.
      */
  -  public final void popCurrentNode()
  +  public final void popCurrentItem()
     {
       m_currentNodesFirstFree--;
     }
     
  +  public int getCurrentNodeFirstFree()
  +  {
  +    return m_currentNodesFirstFree;
  +  }	
  +	 /**
  +   * The current group. 
  +   * The current group will only be non-empty when an
  +   * xsl-for-each-group instruction is being evaluated. 
  +   */
  +  private XSequence m_currentGroup ; 
  +  
  +  /**
  +   * Return the current group or and empty NodeSet
  +   * if one is not found. 
  +   */
  +  public XSequence getCurrentGroup()
  +  {
  +  	if (m_currentGroup == null)
  +  	  m_currentGroup = XSequence.EMPTY;
  +  	return m_currentGroup;
  +  }
  +  
  +  /**
  +   * Set the current group.
  +   * The current group will only be non-empty when an
  +   * xsl-for-each-group instruction is being evaluated.
  +   */
  +  public void setCurrentGroup(XSequence currentGroup)
  +  {
  +  	m_currentGroup = currentGroup;
  +  }
  +  
     /**
      * Set the current predicate root.
      */
  @@ -1071,15 +1282,19 @@
      * @return An iterator for the current context list, as
      * defined in XSLT.
      */
  -  public final DTMIterator getContextNodes()
  +  public final XSequence getContextNodes()
     {
   
       try
       {
  -      DTMIterator cnl = getContextNodeList();
  +      XSequence cnl = getContextSequence();
   
         if (null != cnl)
  -        return cnl.cloneWithReset();
  +      {
  +        cnl = (XSequence)cnl.clone();
  +        cnl.reset();
  +        return cnl;
  +      }
         else
           return null;  // for now... this might ought to be an empty iterator.
       }
  @@ -1144,6 +1359,7 @@
        */
       public org.w3c.dom.traversal.NodeIterator getContextNodes()
       {
  +      DTMIterator iterator = getContextNodeList();
         return new org.apache.xml.dtm.ref.DTMNodeIterator(getContextNodeList());
       }
     
  @@ -1223,7 +1439,7 @@
   	// the latter will ever arise, but I'd rather be just a bit paranoid..
   	if( m_global_rtfdtm==null || m_global_rtfdtm.isTreeIncomplete() )
   	{
  -  		m_global_rtfdtm=(SAX2RTFDTM)m_dtmManager.getDTM(null,true,null,false,false);
  +  		m_global_rtfdtm=(SAX2DTM)m_dtmManager.getDTM(null,true,null,false,false);
   	}
       return m_global_rtfdtm;
     }
  @@ -1242,7 +1458,7 @@
      */
     public DTM getRTFDTM()
     {
  -  	SAX2RTFDTM rtfdtm;
  +  	SAX2DTM rtfdtm;
   
     	// We probably should _NOT_ be applying whitespace filtering at this stage!
     	//
  @@ -1257,17 +1473,17 @@
   	if(m_rtfdtm_stack==null)
   	{
   		m_rtfdtm_stack=new Vector();
  -  		rtfdtm=(SAX2RTFDTM)m_dtmManager.getDTM(null,true,null,false,false);
  +  		rtfdtm=(SAX2DTM)m_dtmManager.getDTM(null,true,null,false,false);
       m_rtfdtm_stack.addElement(rtfdtm);
   		++m_which_rtfdtm;
   	}
   	else if(m_which_rtfdtm<0)
   	{
  -		rtfdtm=(SAX2RTFDTM)m_rtfdtm_stack.elementAt(++m_which_rtfdtm);
  +		rtfdtm=(SAX2DTM)m_rtfdtm_stack.elementAt(++m_which_rtfdtm);
   	}
   	else
   	{
  -		rtfdtm=(SAX2RTFDTM)m_rtfdtm_stack.elementAt(m_which_rtfdtm);
  +		rtfdtm=(SAX2DTM)m_rtfdtm_stack.elementAt(m_which_rtfdtm);
     		
   	  	// It might already be under construction -- the classic example would be
    	 	// an xsl:variable which uses xsl:call-template as part of its value. To
  @@ -1278,10 +1494,10 @@
     		if(rtfdtm.isTreeIncomplete())
   	  	{
   	  		if(++m_which_rtfdtm < m_rtfdtm_stack.size())
  -				rtfdtm=(SAX2RTFDTM)m_rtfdtm_stack.elementAt(m_which_rtfdtm);
  +				rtfdtm=(SAX2DTM)m_rtfdtm_stack.elementAt(m_which_rtfdtm);
   	  		else
   	  		{
  -		  		rtfdtm=(SAX2RTFDTM)m_dtmManager.getDTM(null,true,null,false,false);
  +		  		rtfdtm=(SAX2DTM)m_dtmManager.getDTM(null,true,null,false,false);
             m_rtfdtm_stack.addElement(rtfdtm); 	
   	  		}
    	 	}
  @@ -1298,7 +1514,7 @@
     {
     	m_last_pushed_rtfdtm.push(m_which_rtfdtm);
     	if(null!=m_rtfdtm_stack)
  -	  	((SAX2RTFDTM)(getRTFDTM())).pushRewindMark();
  +	  	((SAX2DTM)(getRTFDTM())).pushRewindMark();
     }
     
     /** Pop the RTFDTM's context mark. This discards any RTFs added after the last
  @@ -1325,7 +1541,7 @@
     	{
     		if(previous>=0) // guard against none-active
     		{
  -	  		boolean isEmpty=((SAX2RTFDTM)(m_rtfdtm_stack.elementAt(previous))).popRewindMark();
  +	  		boolean isEmpty=((SAX2DTM)(m_rtfdtm_stack.elementAt(previous))).popRewindMark();
     		}
     	}
     	else while(m_which_rtfdtm!=previous)
  @@ -1333,8 +1549,181 @@
     		// Empty each DTM before popping, so it's ready for reuse
     		// _DON'T_ pop the previous, since it's still open (which is why we
     		// stacked up more of these) and did not receive a mark.
  -  		boolean isEmpty=((SAX2RTFDTM)(m_rtfdtm_stack.elementAt(m_which_rtfdtm))).popRewindMark();
  +  		boolean isEmpty=((SAX2DTM)(m_rtfdtm_stack.elementAt(m_which_rtfdtm))).popRewindMark();
     		--m_which_rtfdtm; 
     	}
     }
  + 
  + 
  +   //================================================================
  +   // XPath 2.0 PRELIMINARY: Static Context
  +   
  +   /** XPATH2: Type Exception Policy: If "strict", type compatability errors
  +    * should be reported as such. If "flexible", "fallback conversions" will
  +    * be invoked and only if they fail will an error be reported.
  +    * */
  +   private boolean m2_typeExceptionPolicyStrict=true;
  + 
  +   /** XPATH2: Type Exception Policy: If _strict_, type compatability errors
  +    * should be reported as such. If _flexible_, "fallback conversions" will
  +    * be invoked and only if they fail will an error be reported.
  +    *
  +    * @param strict True for strict type checking, false for flexible
  +    * interpretation (attempt fallback).
  +    * */
  +   public void setTypeExceptionPolicyStrict(boolean strict)
  +   {
  +     m2_typeExceptionPolicyStrict=strict;
  +   }
  + 
  +   /** XPATH2: Type Exception Policy: If _strict_, type compatability errors
  +    * should be reported as such. If _flexible_, "fallback conversions" will
  +    * be invoked and only if they fail will an error be reported.
  +    *
  +    * @returns True for strict type checking, false for flexible
  +    * interpretation (attempt fallback).
  +    * */
  +   public boolean isTypeExceptionPolicyStrict()
  +   {
  +     return m2_typeExceptionPolicyStrict;
  +   }
  + 
  +   /* XPATH2: In-Scope Namespaces: See setNamespaceContext. */
  + 
  +   /** XPATH2: Default Namespace: Namespace URI to be presumed for
  +    * any unprefixed QName appearing where an element or type name is
  +    * expected. If null, the default is "no namespace".
  +    *  
  +    *  %REVIEW% What about attr names?
  +    * */
  +   private String m2_defaultNamespaceURI=null;
  +   
  +   /** XPATH2: Default Namespace: Namespace URI to be presumed for
  +    * any unprefixed QName appearing where an element or type name is
  +    * expected.
  +    *  
  +    *  %REVIEW% What about attr names?
  +    *
  +    * @param uri URI to be use. If null, the default is "no namespace".
  +    * Empty string is currently treated as a real but poorly formed URI;
  +    * we can quibble about that...
  +    * */
  +   public void setDefaultNamespaceURI(String uri)
  +   {
  +     m2_defaultNamespaceURI=uri;
  +   }
  +   
  +   /** XPATH2: Default Namespace: Namespace URI to be presumed for
  +    * any unprefixed QName appearing where an element or type name is
  +    * expected.
  +    *  
  +    *  %REVIEW% What about attr names?
  +    *
  +    * @returns uri URI to be use. If null, the default is "no namespace".
  +    * Empty string is currently treated as a real but poorly formed URI;
  +    * we can quibble about that...
  +    * */
  +   public String getDefaultNamespaceURI()
  +   {
  +     return m2_defaultNamespaceURI;
  +   }
  +   
  +   /** XPATH2: Default Function Namespace: Namespace URI to be presumed for
  +    * any unprefixed QName appearing where a function name is
  +    * expected. If null, the default is "no namespace".
  +    * */
  +   private String m2_defaultFunctionNamespaceURI=null;
  +   
  +   /** XPATH2: Default Function Namespace: Namespace URI to be presumed for
  +    * any unprefixed QName appearing where a function name is
  +    * expected. If null, the default is "no namespace".
  +    *
  +    * @param uri URI to be use. If null, the default is "no namespace".
  +    * Empty string is currently treated as a real but poorly formed URI;
  +    * we can quibble about that...
  +    * */
  +   public void setDefaultFunctionNamespaceURI(String uri)
  +   {
  +     m2_defaultFunctionNamespaceURI=uri;
  +   }
  +   
  +   /** XPATH2: Default Function Namespace: Namespace URI to be presumed for
  +    * any unprefixed QName appearing where a function name is
  +    * expected. If null, the default is "no namespace".
  +    *
  +    * @returns uri URI to be use. If null, the default is "no namespace".
  +    * Empty string is currently treated as a real but poorly formed URI;
  +    * we can quibble about that...
  +    * */
  +   public String getDefaultFunctionNamespaceURI()
  +   {
  +     return m2_defaultFunctionNamespaceURI;
  +   }
  +   
  +   /* XPATH2: In-Scope Variables: See getVarStack, getVariableOrParam....
  +      %REVIEW% In XPath2 variables have type, and static variables have
  +      static type; make sure it's retrievable.
  +    */
  +   
  +   /** XPATH2: In-Scope Schema Definitions: Set of (QName,type definition)
  +       pairs, defining the types available for reference in the expression.
  +       Includes the built-in schema types, all globally-declared types in
  +       explicitly imported schemas -- but, significantly, does NOT necessarily
  +       include the types referenced by any given instance document!
  + 
  + 	%ISSUE% Xerces dependencies are very roughly encapsulated, but
  + 	this is EXTREMELY ugly architecturally.
  +   */
  +   private org.apache.xml.dtm.ref.xni2dtm.AbstractSchema m2_issd=null;
  +   
  +   public void addInScopeSchemaDefinitions(String publicID, String systemID)
  +   {
  +   	if(m2_issd == null)
  +   		m2_issd=new org.apache.xml.dtm.ref.xni2dtm.AbstractSchema();
  +   		
  +   	m2_issd.appendSchema(publicID, systemID, getBaseURI());
  +   }
  +   
  +   public org.apache.xml.dtm.ref.xni2dtm.AbstractSchema getInScopeSchemaDefinitions()
  +   {
  +   	return m2_issd;
  +   }
  +   
  +   /** XPATH2: Base URI. Should be used by the document() function. Seems
  +    * to be needed by other operations as well, though XPath doesn't make this
  +    * clear -- eg, resolving import-schema URI references.
  +    * 
  +    * The definition here is swiped from FuncDocument, and _should_ yield the
  +    * base URI of the stylesheet node currently being executed. I'm not 110%
  +    * sure it works in all cases. %REVIEW%
  +    * */
  +   public String getBaseURI()
  +   {
  +   	return getNamespaceContext().getBaseIdentifier();
  +   }
  +
  +	/** XPATH2 support: We need a central place to ask which version we're
  +	 * currently trying to support, since some behaviors may change.
  +	 * 
  +	 * We know where to look if called from a stylesheet. 
  +	 * 
  +	 * I'm not sure where to look if we're using the XPath API; we
  +	 * may need to define an API for that purpose.
  +	 * 
  +	 * @return String containing "1.0", "2.0", etc. If someone wants to
  +	 * compare sub-fields of this string... we don't currently help them.
  +	 * */   
  +   public String getXPathVersion()
  +   {
  +   	try
  +   	{
  +   		return ((org.apache.xalan.transformer.TransformerImpl)m_owner).getStylesheet().getVersion();
  +   	}
  +   	catch(Exception e)
  +   	{
  +   		// %REVIEW% %TODO% Where does a bare XPath get this info?
  +   		return "1.0";
  +   	}
  +   	
  +   }
   }
  
  
  
  1.1.4.1   +14 -0     xml-xalan/java/src/org/apache/xpath/XPathVisitor.java
  
  Index: XPathVisitor.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathVisitor.java,v
  retrieving revision 1.1
  retrieving revision 1.1.4.1
  diff -u -r1.1 -r1.1.4.1
  --- XPathVisitor.java	22 Mar 2002 01:04:42 -0000	1.1
  +++ XPathVisitor.java	14 Aug 2002 20:06:57 -0000	1.1.4.1
  @@ -57,6 +57,7 @@
   package org.apache.xpath;
   
   import org.apache.xpath.patterns.NodeTest;
  +import org.apache.xpath.types.InstanceofExpr;
   import org.apache.xpath.axes.LocPathIterator;
   import org.apache.xpath.axes.UnionPathIterator;
   import org.apache.xpath.functions.Function;
  @@ -233,6 +234,19 @@
   	{
   		return true;
   	}
  +  
  +  /**
  +   * Visit a number literal.
  +   * @param owner The owner of the expression, to which the expression can 
  +   *              be reset if rewriting takes place.
  +   * @param num The number literal object.
  +   * @return true if the sub expressions should be traversed.
  +   */
  +  public boolean visitInstanceOf(ExpressionOwner owner, InstanceofExpr num)
  +  {
  +    return true;
  +  }
  +
   
   
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +141 -0    xml-xalan/java/src/org/apache/xpath/Attic/VariableComposeState.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.4.1  +6 -13     xml-xalan/java/src/org/apache/xpath/axes/AttributeIterator.java
  
  Index: AttributeIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/AttributeIterator.java,v
  retrieving revision 1.10
  retrieving revision 1.10.4.1
  diff -u -r1.10 -r1.10.4.1
  --- AttributeIterator.java	22 Mar 2002 01:04:42 -0000	1.10
  +++ AttributeIterator.java	14 Aug 2002 20:06:57 -0000	1.10.4.1
  @@ -57,15 +57,9 @@
   package org.apache.xpath.axes;
   
   import javax.xml.transform.TransformerException;
  -
  -import org.apache.xpath.XPathContext;
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.patterns.NodeTest;
  -import org.apache.xpath.objects.XObject;
  -
  +import org.apache.xml.dtm.Axis;
   import org.apache.xml.dtm.DTM;
  -import org.apache.xml.dtm.DTMIterator;
  -import org.apache.xml.dtm.DTMFilter;
  +import org.apache.xpath.parser.StepExpr;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -79,16 +73,15 @@
     /**
      * Create a AttributeIterator object.
      *
  -   * @param compiler A reference to the Compiler that contains the op map.
  -   * @param opPos The position within the op map, which contains the
  -   * location path expression for this itterator.
  +   * @param stepExpr The step expression from the parser.
  +   * @param analysis The analysis bits for the total path expression.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  AttributeIterator(Compiler compiler, int opPos, int analysis)
  +  AttributeIterator(StepExpr stepExpr, int analysis)
             throws javax.xml.transform.TransformerException
     {
  -    super(compiler, opPos, analysis);
  +    super(stepExpr, analysis);    
     }
       
     /**
  
  
  
  1.24.2.1  +62 -11    xml-xalan/java/src/org/apache/xpath/axes/AxesWalker.java
  
  Index: AxesWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/AxesWalker.java,v
  retrieving revision 1.24
  retrieving revision 1.24.2.1
  diff -u -r1.24 -r1.24.2.1
  --- AxesWalker.java	27 Jun 2002 14:50:54 -0000	1.24
  +++ AxesWalker.java	14 Aug 2002 20:06:57 -0000	1.24.2.1
  @@ -66,11 +66,8 @@
   import org.apache.xpath.ExpressionOwner;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.patterns.NodeTest;
  -
  -import org.apache.xpath.res.XPATHErrorResources;
  -import org.apache.xalan.res.XSLMessages;
  +import org.apache.xpath.parser.Node;
  +import org.apache.xpath.parser.StepExpr;
   
   /**
    * Serves as common interface for axes Walkers, and stores common
  @@ -106,13 +103,11 @@
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  public void init(Compiler compiler, int opPos, int stepType)
  +  public void init(org.apache.xpath.parser.StepExpr stepExpr)
             throws javax.xml.transform.TransformerException
     {
   
  -    initPredicateInfo(compiler, opPos);
  -
  -    // int testType = compiler.getOp(nodeTestOpPos);
  +    initPredicateInfo(stepExpr);
     }
   
     /**
  @@ -264,7 +259,7 @@
       if (DTM.NULL == root)
       {
         throw new RuntimeException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_SETTING_WALKER_ROOT_TO_NULL, null)); //"\n !!!! Error! Setting the root of a walker to null!!!");
  +        "\n !!!! Error! Setting the root of a walker to null!!!");
       }
   
       resetProximityPositions();
  @@ -623,5 +618,61 @@
     protected int m_axis = -1;
   
     /** The DTM inner traversal class, that corresponds to the super axis. */
  -  protected DTMAxisTraverser m_traverser; 
  +  protected DTMAxisTraverser m_traverser; 
  +  
  +  public Node jjtGetChild(int i) 
  +  {
  +    if((null != m_nextWalker) && i == 0)
  +    	return m_nextWalker;
  +    else
  +    	return null;
  +  }
  +
  +  public int jjtGetNumChildren() 
  +  {
  +  	
  +    return ((null == m_nextWalker) ? 0 : 1);
  +  }
  +
  +  public String toString()
  +  {
  +  	String namespace = getNamespace();
  +  	String localname = getLocalName();
  +  	return org.apache.xml.dtm.Axis.names[m_axis]+"::"+
  +  		((null != namespace) ? (namespace+":") : "")+
  +  		((null != localname) ? localname : "node()")+
  +  		" "+super.toString();
  +  }
  
   }
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  
  
  
  1.2.4.1   +8 -31     xml-xalan/java/src/org/apache/xpath/axes/BasicTestIterator.java
  
  Index: BasicTestIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/BasicTestIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.2.4.1
  diff -u -r1.2 -r1.2.4.1
  --- BasicTestIterator.java	22 Mar 2002 01:04:42 -0000	1.2
  +++ BasicTestIterator.java	14 Aug 2002 20:06:57 -0000	1.2.4.1
  @@ -6,7 +6,7 @@
   import org.apache.xml.dtm.DTMIterator;
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.VariableStack;
  -import org.apache.xpath.compiler.Compiler;
  +import org.apache.xpath.parser.StepExpr;
   
   /**
    * Base for iterators that handle predicates.  Does the basic next 
  @@ -50,13 +50,12 @@
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
  +  protected BasicTestIterator(StepExpr stepExpr, int analysis)
             throws javax.xml.transform.TransformerException
     {
  -    super(compiler, opPos, analysis, false);
  +    super(stepExpr.getParser().getPrefixResolver());
       
  -    int firstStepPos = compiler.getFirstChildPos(opPos);
  -    int whatToShow = compiler.getWhatToShow(firstStepPos);
  +    int whatToShow = stepExpr.getWhatToShow();
   
       if ((0 == (whatToShow
                  & (DTMFilter.SHOW_ATTRIBUTE 
  @@ -67,34 +66,11 @@
         initNodeTest(whatToShow);
       else
       {
  -      initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
  -                              compiler.getStepLocalName(firstStepPos));
  +      initNodeTest(whatToShow, stepExpr.getNamespaceURI(),
  +                              stepExpr.getLocalName());
       }
  -    initPredicateInfo(compiler, firstStepPos);
  +    initPredicateInfo(stepExpr);
     }
  -
  -  /**
  -   * Create a LocPathIterator object, including creation
  -   * of step walkers from the opcode list, and call back
  -   * into the Compiler to create predicate expressions.
  -   *
  -   * @param compiler The Compiler which is creating
  -   * this expression.
  -   * @param opPos The position of this iterator in the
  -   * opcode list from the compiler.
  -   * @param shouldLoadWalkers True if walkers should be
  -   * loaded, or false if this is a derived iterator and
  -   * it doesn't wish to load child walkers.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  protected BasicTestIterator(
  -          Compiler compiler, int opPos, int analysis, boolean shouldLoadWalkers)
  -            throws javax.xml.transform.TransformerException
  -  {
  -    super(compiler, opPos, analysis, shouldLoadWalkers);
  -  }
  -
   	
     /**
      * Get the next node via getNextXXX.  Bottlenecked for derived class override.
  @@ -197,6 +173,7 @@
   
       return clone;
     }
  +  
   
   
   }
  
  
  
  1.10.4.1  +23 -16    xml-xalan/java/src/org/apache/xpath/axes/ChildIterator.java
  
  Index: ChildIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ChildIterator.java,v
  retrieving revision 1.10
  retrieving revision 1.10.4.1
  diff -u -r1.10 -r1.10.4.1
  --- ChildIterator.java	22 Mar 2002 01:04:42 -0000	1.10
  +++ ChildIterator.java	14 Aug 2002 20:06:57 -0000	1.10.4.1
  @@ -57,16 +57,10 @@
   package org.apache.xpath.axes;
   
   import javax.xml.transform.TransformerException;
  -
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.patterns.NodeTest;
  -import org.apache.xpath.XPathContext;
  -import org.apache.xml.utils.PrefixResolver;
  -
  -//import org.w3c.dom.Node;
  -//import org.w3c.dom.DOMException;
  +import org.apache.xml.dtm.Axis;
   import org.apache.xml.dtm.DTM;
  -import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xpath.XPathContext;
  +import org.apache.xpath.parser.StepExpr;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -77,22 +71,35 @@
    */
   public class ChildIterator extends LocPathIterator
   {
  -
     /**
      * Create a ChildIterator object.
      *
  -   * @param compiler A reference to the Compiler that contains the op map.
  -   * @param opPos The position within the op map, which contains the
  -   * location path expression for this itterator.
  -   * @param analysis Analysis bits of the entire pattern.
  +   * @param stepExpr The step expression from the parser.
  +   * @param analysis The analysis bits for the total path expression.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  ChildIterator(Compiler compiler, int opPos, int analysis)
  +  ChildIterator(StepExpr stepExpr, int analysis)
             throws javax.xml.transform.TransformerException
     {
  -    super(compiler, opPos, analysis, false);
     }
  +
  +
  +//  /**
  +//   * Create a ChildIterator object.
  +//   *
  +//   * @param compiler A reference to the Compiler that contains the op map.
  +//   * @param opPos The position within the op map, which contains the
  +//   * location path expression for this itterator.
  +//   * @param analysis Analysis bits of the entire pattern.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  ChildIterator(Compiler compiler, int opPos, int analysis)
  +//          throws javax.xml.transform.TransformerException
  +//  {
  +//    super(compiler, opPos, analysis, false);
  +//  }
     
     /**
      * Return the first node out of the nodeset, if this expression is 
  
  
  
  1.14.4.1  +21 -13    xml-xalan/java/src/org/apache/xpath/axes/ChildTestIterator.java
  
  Index: ChildTestIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ChildTestIterator.java,v
  retrieving revision 1.14
  retrieving revision 1.14.4.1
  diff -u -r1.14 -r1.14.4.1
  --- ChildTestIterator.java	22 Mar 2002 01:04:42 -0000	1.14
  +++ ChildTestIterator.java	14 Aug 2002 20:06:57 -0000	1.14.4.1
  @@ -57,16 +57,11 @@
   package org.apache.xpath.axes;
   
   import javax.xml.transform.TransformerException;
  -
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.patterns.NodeTest;
  -import org.apache.xpath.objects.XObject;
  -
  +import org.apache.xml.dtm.Axis;
   import org.apache.xml.dtm.DTM;
  -import org.apache.xml.dtm.DTMIterator;
  -import org.apache.xml.dtm.DTMFilter;
   import org.apache.xml.dtm.DTMAxisTraverser;
  -import org.apache.xml.dtm.Axis;
  +import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xpath.parser.StepExpr;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -86,17 +81,30 @@
     /**
      * Create a ChildTestIterator object.
      *
  -   * @param compiler A reference to the Compiler that contains the op map.
  -   * @param opPos The position within the op map, which contains the
  -   * location path expression for this itterator.
  +   * @param stepExpr The step expression from the parser.
  +   * @param analysis The analysis bits for the total path expression.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  ChildTestIterator(Compiler compiler, int opPos, int analysis)
  +  ChildTestIterator(StepExpr stepExpr, int analysis)
             throws javax.xml.transform.TransformerException
     {
  -    super(compiler, opPos, analysis);
  +    super(stepExpr, analysis);    
     }
  +
  +  /**
  +   * Create a ChildTestIterator object.
  +   *
  +   * @param traverser Traverser that tells how the KeyIterator is to be handled.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public ChildTestIterator()
  +  {
  +
  +    super();
  +  }
  +  
     
     /**
      * Create a ChildTestIterator object.
  
  
  
  1.6.14.1  +1 -1      xml-xalan/java/src/org/apache/xpath/axes/ContextNodeList.java
  
  Index: ContextNodeList.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ContextNodeList.java,v
  retrieving revision 1.6
  retrieving revision 1.6.14.1
  diff -u -r1.6 -r1.6.14.1
  --- ContextNodeList.java	15 Jun 2001 05:15:30 -0000	1.6
  +++ ContextNodeList.java	14 Aug 2002 20:06:57 -0000	1.6.14.1
  @@ -99,7 +99,7 @@
      *
      * @param b true if the nodes should be cached.
      */
  -  public void setShouldCacheNodes(boolean b);
  +  public void setShouldCache(boolean b);
   
     /**
      * If an index is requested, NodeSetDTM will call this method
  
  
  
  1.15.4.1  +7 -63     xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java
  
  Index: DescendantIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java,v
  retrieving revision 1.15
  retrieving revision 1.15.4.1
  diff -u -r1.15 -r1.15.4.1
  --- DescendantIterator.java	22 Mar 2002 01:04:42 -0000	1.15
  +++ DescendantIterator.java	14 Aug 2002 20:06:57 -0000	1.15.4.1
  @@ -65,8 +65,7 @@
   import org.apache.xpath.Expression;
   import org.apache.xpath.VariableStack;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.compiler.OpCodes;
  +import org.apache.xpath.parser.StepExpr;
   import org.apache.xpath.patterns.NodeTest;
   
   /**
  @@ -86,68 +85,14 @@
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  DescendantIterator(Compiler compiler, int opPos, int analysis)
  +  DescendantIterator(StepExpr stepExpr)
             throws javax.xml.transform.TransformerException
     {
   
  -    super(compiler, opPos, analysis, false);
  -
  -    int ops[] = compiler.getOpMap();
  -    int firstStepPos = compiler.getFirstChildPos(opPos);
  -    int stepType = ops[firstStepPos];
  -
  -    boolean orSelf = (OpCodes.FROM_DESCENDANTS_OR_SELF == stepType);
  -    boolean fromRoot = false;
  -    if (OpCodes.FROM_SELF == stepType)
  -    {
  -      orSelf = true;
  -      // firstStepPos += 8;
  -    }
  -    else if(OpCodes.FROM_ROOT == stepType)
  -    {
  -      fromRoot = true;
  -      // Ugly code... will go away when AST work is done.
  -      int nextStepPos = compiler.getNextStepPos(firstStepPos);
  -      if(ops[nextStepPos] == OpCodes.FROM_DESCENDANTS_OR_SELF)
  -        orSelf = true;
  -      // firstStepPos += 8;
  -    }
  -    
  -    // Find the position of the last step.
  -    int nextStepPos = firstStepPos;
  -    while(true)
  -    {
  -      nextStepPos = compiler.getNextStepPos(nextStepPos);
  -      if(nextStepPos > 0)
  -      {
  -        int stepOp = compiler.getOp(nextStepPos);
  -        if(OpCodes.ENDOP != stepOp)
  -          firstStepPos = nextStepPos;
  -        else
  -          break;
  -      }
  -      else
  -        break;
  +    super();
  +    m_axis = stepExpr.getAxis();
         
  -    }
  -    
  -    // Fix for http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1336
  -    if((analysis & WalkerFactory.BIT_CHILD) != 0)
  -      orSelf = false;
  -      
  -    if(fromRoot)
  -    {
  -      if(orSelf)
  -        m_axis = Axis.DESCENDANTSORSELFFROMROOT;
  -      else
  -        m_axis = Axis.DESCENDANTSFROMROOT;
  -    }
  -    else if(orSelf)
  -      m_axis = Axis.DESCENDANTORSELF;
  -    else
  -      m_axis = Axis.DESCENDANT;
  -
  -    int whatToShow = compiler.getWhatToShow(firstStepPos);
  +    int whatToShow = stepExpr.getWhatToShow();
   
       if ((0 == (whatToShow
                  & (DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_ELEMENT
  @@ -156,10 +101,9 @@
         initNodeTest(whatToShow);
       else
       {
  -      initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
  -                              compiler.getStepLocalName(firstStepPos));
  +      initNodeTest(whatToShow, stepExpr.getNamespaceURI(), stepExpr.getLocalName());
       }
  -    initPredicateInfo(compiler, firstStepPos);
  +    initPredicateInfo(stepExpr);
     }
     
     /**
  
  
  
  1.2.4.1   +45 -6     xml-xalan/java/src/org/apache/xpath/axes/FilterExprIterator.java
  
  Index: FilterExprIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/FilterExprIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.2.4.1
  diff -u -r1.2 -r1.2.4.1
  --- FilterExprIterator.java	22 Mar 2002 01:04:42 -0000	1.2
  +++ FilterExprIterator.java	14 Aug 2002 20:06:57 -0000	1.2.4.1
  @@ -1,12 +1,18 @@
   package org.apache.xpath.axes;
   
  +import java.io.PrintStream;
   import java.util.Vector;
   
   import org.apache.xml.dtm.DTM;
   import org.apache.xpath.Expression;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathVisitor;
   import org.apache.xpath.objects.XNodeSet;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.objects.XSequence;
  +import org.apache.xpath.objects.XSequenceSingleton;
  +import org.apache.xpath.parser.Node;
   
   public class FilterExprIterator extends BasicTestIterator
   {
  @@ -15,7 +21,7 @@
     private Expression m_expr;
   
     /** The result of executing m_expr.  Needs to be deep cloned on clone op.  */
  -  transient private XNodeSet m_exprObj;
  +  transient private XSequence m_exprObj;
   
     private boolean m_mustHardReset = false;
     private boolean m_canDetachNodeset = true;
  @@ -70,7 +76,11 @@
     {
       if (null != m_exprObj)
       {
  -      m_lastFetched = m_exprObj.nextNode();
  +      XObject item = m_exprObj.next();
  +      if(item != null && item != XSequence.EMPTY)
  +        m_lastFetched = item.getNodeHandle();
  +      else
  +        m_lastFetched = DTM.NULL;
       }
       else
         m_lastFetched = DTM.NULL;
  @@ -100,10 +110,10 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  -    m_expr.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
  +    m_expr.fixupVariables(vcs);
     }
   
     /**
  @@ -145,7 +155,12 @@
      */
     public boolean isDocOrdered()
     {
  -    return m_exprObj.isDocOrdered();
  +    if(m_exprObj instanceof XNodeSet)
  +      return ((XNodeSet)m_exprObj).isDocOrdered();
  +    else if(m_exprObj instanceof XSequenceSingleton)
  +      return true;
  +    else
  +      return false;
     }
   
     class filterExprOwner implements ExpressionOwner
  @@ -199,5 +214,29 @@
   
       return true;
     }
  +  
  +//  /**
  +//   * @see org.apache.xpath.parser.Node#jjtGetChild(int)
  +//   */
  +//  public Node jjtGetChild(int i)
  +//  {
  +//    return (0 == i) ? m_expr : null;
  +//  }
  +//
  +//  /**
  +//   * @see org.apache.xpath.parser.Node#jjtGetNumChildren()
  +//   */
  +//  public int jjtGetNumChildren()
  +//  {
  +//    return (null != m_expr) ? 1 : 0;
  +//  }
  +//
  +//  /**
  +//   * @see org.apache.xpath.parser.SimpleNode#dump(String, PrintStream)
  +//   */
  +//  public void dump(String prefix, PrintStream ps)
  +//  {
  +//    super.dump(prefix, ps);
  +//  }
   
   }
  
  
  
  1.2.4.1   +40 -15    xml-xalan/java/src/org/apache/xpath/axes/FilterExprIteratorSimple.java
  
  Index: FilterExprIteratorSimple.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/FilterExprIteratorSimple.java,v
  retrieving revision 1.2
  retrieving revision 1.2.4.1
  diff -u -r1.2 -r1.2.4.1
  --- FilterExprIteratorSimple.java	22 Mar 2002 01:04:42 -0000	1.2
  +++ FilterExprIteratorSimple.java	14 Aug 2002 20:06:57 -0000	1.2.4.1
  @@ -1,17 +1,21 @@
   package org.apache.xpath.axes;
   
  -import java.util.Vector;
  -
   import javax.xml.transform.TransformerException;
  +
   import org.apache.xml.dtm.Axis;
   import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMIterator;
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.Expression;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.VariableStack;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
   import org.apache.xpath.objects.XNodeSet;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.objects.XSequence;
  +import org.apache.xpath.objects.XSequenceSingleton;
   
   /**
    * Class to use for one-step iteration that doesn't have a predicate, and 
  @@ -24,7 +28,7 @@
     private Expression m_expr;
   
     /** The result of executing m_expr.  Needs to be deep cloned on clone op.  */
  -  transient private XNodeSet m_exprObj;
  +  transient private XSequence m_exprObj;
   
     private boolean m_mustHardReset = false;
     private boolean m_canDetachNodeset = true;
  @@ -72,7 +76,7 @@
      * Execute the expression.  Meant for reuse by other FilterExpr iterators 
      * that are not derived from this object.
      */
  -  public static XNodeSet executeFilterExpr(int context, XPathContext xctxt, 
  +  public static XSequence executeFilterExpr(int context, XPathContext xctxt, 
     												PrefixResolver prefixResolver,
     												boolean isTopLevel,
     												int stackFrame,
  @@ -80,7 +84,7 @@
       throws org.apache.xml.utils.WrappedRuntimeException
     {
       PrefixResolver savedResolver = xctxt.getNamespaceContext();
  -    XNodeSet result = null;
  +    XSequence result = null;
   
       try
       {
  @@ -101,14 +105,26 @@
           int savedStart = vars.getStackFrame();
           vars.setStackFrame(stackFrame);
   
  -        result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
  -        result.setShouldCacheNodes(true);
  +        result = (XSequence) expr.execute(xctxt);
  +        result.setShouldCache(true);
   
           // These two statements need to be combined into one operation.
           vars.setStackFrame(savedStart);
         }
         else
  -          result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
  +          result = (XNodeSet) expr.execute(xctxt);
  +         
  +      /* %REVIEW% %OPT%
  +      	Unfortunately, not all variables can be statically resolved into either
  +      	definitely RTF or definitely not RTF. 
  +      	
  +      	%REVIEW% FIX: Should be using standardized error strings.
  +      */ 
  +      if(result instanceof org.apache.xpath.objects.XRTreeFrag
  +      		&& "1.0".equals(xctxt.getXPathVersion())
  +      		)
  +      		xctxt.getErrorListener().error(new TransformerException(
  +      			"Result Tree Fragments/Temporary Trees are not Nodesets in XSLT 1.0. Switch version to 2.0 or use the nodeset() extension"));
   
       }
       catch (javax.xml.transform.TransformerException se)
  @@ -142,7 +158,11 @@
   
       if (null != m_exprObj)
       {
  -      m_lastFetched = next = m_exprObj.nextNode();
  +      XObject item = m_exprObj.next();
  +      if(item != null && item != XSequence.EMPTY)
  +        m_lastFetched = next = item.getNodeHandle();
  +      else
  +        m_lastFetched = next = DTM.NULL;
       }
       else
         m_lastFetched = next = DTM.NULL;
  @@ -186,10 +206,10 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  -    m_expr.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
  +    m_expr.fixupVariables(vcs);
     }
   
     /**
  @@ -231,7 +251,12 @@
      */
     public boolean isDocOrdered()
     {
  -    return m_exprObj.isDocOrdered();
  +    if(m_exprObj instanceof XNodeSet)
  +      return ((XNodeSet)m_exprObj).isDocOrdered();
  +    else if(m_exprObj instanceof XSequenceSingleton)
  +      return true;
  +    else
  +      return false;
     }
   
     class filterExprOwner implements ExpressionOwner
  @@ -294,8 +319,8 @@
      */
     public int getAxis()
     {
  -  	if(null != m_exprObj)
  -    	return m_exprObj.getAxis();
  +  	if(null != m_exprObj && m_exprObj instanceof XNodeSet)
  +    	return ((XNodeSet)m_exprObj).getAxis();
       else
       	return Axis.FILTEREDLIST;
     }
  
  
  
  1.20.4.1  +218 -114  xml-xalan/java/src/org/apache/xpath/axes/FilterExprWalker.java
  
  Index: FilterExprWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/FilterExprWalker.java,v
  retrieving revision 1.20
  retrieving revision 1.20.4.1
  diff -u -r1.20 -r1.20.4.1
  --- FilterExprWalker.java	22 Mar 2002 01:04:42 -0000	1.20
  +++ FilterExprWalker.java	14 Aug 2002 20:06:57 -0000	1.20.4.1
  @@ -56,22 +56,21 @@
    */
   package org.apache.xpath.axes;
   
  -import java.util.Vector;
  -
  -import javax.xml.transform.TransformerException;
  -import org.apache.xalan.templates.FuncKey;
   import org.apache.xml.dtm.Axis;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  -import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.Expression;
   import org.apache.xpath.ExpressionOwner;
  -import org.apache.xpath.VariableStack;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.compiler.OpCodes;
  +import org.apache.xpath.functions.Function;
   import org.apache.xpath.objects.XNodeSet;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.objects.XSequence;
  +import org.apache.xpath.objects.XSequenceSingleton;
  +import org.apache.xpath.parser.Node;
  +import org.apache.xpath.parser.PathExpr;
   
   /**
    * Walker for the OP_VARIABLE, or OP_EXTFUNCTION, or OP_FUNCTION, or OP_GROUP,
  @@ -94,64 +93,93 @@
     /**
      * Init a FilterExprWalker.
      *
  -   * @param compiler non-null reference to the Compiler that is constructing.
  -   * @param opPos positive opcode position for this step.
  -   * @param stepType The type of step.
  +   * @param stepExpr The FilterExpr's expression.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  public void init(Compiler compiler, int opPos, int stepType)
  -          throws javax.xml.transform.TransformerException
  +  public void init(org.apache.xpath.parser.StepExpr stepExpr)
  +    throws javax.xml.transform.TransformerException
     {
  -
  -    super.init(compiler, opPos, stepType);
  -
  -    // Smooth over an anomily in the opcode map...
  -    switch (stepType)
  +    int childCount = stepExpr.jjtGetNumChildren();
  +    if (childCount > 0)
       {
  -    case OpCodes.OP_FUNCTION :
  -    case OpCodes.OP_EXTFUNCTION :
  -    	m_mustHardReset = true;
  -    case OpCodes.OP_GROUP :
  -    case OpCodes.OP_VARIABLE :
  -      m_expr = compiler.compile(opPos);
  -      m_expr.exprSetParent(this);
  -      if((OpCodes.OP_FUNCTION == stepType) && (m_expr instanceof org.apache.xalan.templates.FuncKey))
  +      Node child = stepExpr.jjtGetChild(0);
  +      m_expr = (Expression) child;
  +      // Not sure if this is still needed.  Probably not. -sb
  +      if (m_expr instanceof WalkingIterator)
         {
  -      	// hack/temp workaround
  -      	m_canDetachNodeset = false;
  +        WalkingIterator wi = (WalkingIterator) m_expr;
  +        if (wi.getFirstWalker() instanceof FilterExprWalker)
  +        {
  +          FilterExprWalker fw = (FilterExprWalker) wi.getFirstWalker();
  +          if (null == fw.getNextWalker())
  +          {
  +            m_expr = fw.m_expr;
  +            m_expr.exprSetParent(this);
  +          }
  +        }
  +
  +      }
  +      if (m_expr instanceof Function)
  +      {
  +        m_mustHardReset = true;
  +      }
  +      if (m_expr instanceof org.apache.xalan.templates.FuncKey)
  +      {
  +        // hack/temp workaround
  +        m_canDetachNodeset = false;
         }
  -      break;
  -    default :
  -      m_expr = compiler.compile(opPos + 2);
         m_expr.exprSetParent(this);
  +
       }
  -//    if(m_expr instanceof WalkingIterator)
  -//    {
  -//      WalkingIterator wi = (WalkingIterator)m_expr;
  -//      if(wi.getFirstWalker() instanceof FilterExprWalker)
  -//      {
  -//      	FilterExprWalker fw = (FilterExprWalker)wi.getFirstWalker();
  -//      	if(null == fw.getNextWalker())
  -//      	{
  -//      		m_expr = fw.m_expr;
  -//      		m_expr.exprSetParent(this);
  -//      	}
  -//      }
  -//      		
  -//    }
  +    super.init(stepExpr);
  +
  +    // Smooth over an anomily in the opcode map...
  +    //    switch (stepType)
  +    //    {
  +    //    case OpCodes.OP_FUNCTION :
  +    //    case OpCodes.OP_EXTFUNCTION :
  +    //    	m_mustHardReset = true;
  +    //    case OpCodes.OP_GROUP :
  +    //    case OpCodes.OP_VARIABLE :
  +    //      m_expr = compiler.compile(opPos);
  +    //      m_expr.exprSetParent(this);
  +    //      if((OpCodes.OP_FUNCTION == stepType) && (m_expr instanceof org.apache.xalan.templates.FuncKey))
  +    //      {
  +    //      	// hack/temp workaround
  +    //      	m_canDetachNodeset = false;
  +    //      }
  +    //      break;
  +    //    default :
  +    //      m_expr = compiler.compile(opPos + 2);
  +    //      m_expr.exprSetParent(this);
  +    //    }
  +    //    if(m_expr instanceof WalkingIterator)
  +    //    {
  +    //      WalkingIterator wi = (WalkingIterator)m_expr;
  +    //      if(wi.getFirstWalker() instanceof FilterExprWalker)
  +    //      {
  +    //      	FilterExprWalker fw = (FilterExprWalker)wi.getFirstWalker();
  +    //      	if(null == fw.getNextWalker())
  +    //      	{
  +    //      		m_expr = fw.m_expr;
  +    //      		m_expr.exprSetParent(this);
  +    //      	}
  +    //      }
  +    //      		
  +    //    }
     }
  -  
  +
     /**
      * Detaches the walker from the set which it iterated over, releasing
      * any computational resources and placing the iterator in the INVALID
      * state.
      */
     public void detach()
  -  {  
  -  	super.detach();
  -  	m_exprObj.detach();
  -  	m_exprObj = null;
  +  {
  +    super.detach();
  +    m_exprObj.detach();
  +    m_exprObj = null;
     }
   
     /**
  @@ -165,9 +193,14 @@
   
       super.setRoot(root);
   
  -  	m_exprObj = FilterExprIteratorSimple.executeFilterExpr(root, 
  -  	                  m_lpi.getXPathContext(), m_lpi.getPrefixResolver(), 
  -  	                  m_lpi.getIsTopLevel(), m_lpi.m_stackFrame, m_expr);
  +    m_exprObj =
  +      FilterExprIteratorSimple.executeFilterExpr(
  +        root,
  +        m_lpi.getXPathContext(),
  +        m_lpi.getPrefixResolver(),
  +        m_lpi.getIsTopLevel(),
  +        m_lpi.m_stackFrame,
  +        m_expr);
   
     }
   
  @@ -189,7 +222,7 @@
   
       return clone;
     }
  -  
  +
     /**
      * This method needs to override AxesWalker.acceptNode because FilterExprWalkers
      * don't need to, and shouldn't, do a node test.
  @@ -232,13 +265,21 @@
   
       if (null != m_exprObj)
       {
  -       int next = m_exprObj.nextNode();
  -       return next;
  +      int next;
  +      XObject item = m_exprObj.next();
  +      if(item != null && item != XSequence.EMPTY)
  +        next = item.getNodeHandle();
  +      else
  +      {
  +        m_exprObj.reset();
  +        next = DTM.NULL;
  +      }
  +      return next;
       }
       else
         return DTM.NULL;
     }
  -  
  +
     /**
      * Get the index of the last node that can be itterated to.
      *
  @@ -251,14 +292,14 @@
     {
       return m_exprObj.getLength();
     }
  -  
  +
     /** The contained expression. Should be non-null.
      *  @serial   */
     private Expression m_expr;
   
     /** The result of executing m_expr.  Needs to be deep cloned on clone op.  */
  -  transient private XNodeSet m_exprObj;
  -  
  +  transient private XSequence m_exprObj;
  +
     private boolean m_mustHardReset = false;
     private boolean m_canDetachNodeset = true;
   
  @@ -272,43 +313,42 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  -    m_expr.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
  +    m_expr.fixupVariables(vcs);
     }
  -  
  +
     /**
      * Get the inner contained expression of this filter.
      */
     public Expression getInnerExpression()
     {
  -  	return m_expr;
  +    return m_expr;
     }
  -  
  +
     /**
      * Set the inner contained expression of this filter.
      */
     public void setInnerExpression(Expression expr)
     {
  -  	expr.exprSetParent(this);
  -  	m_expr = expr;
  +    expr.exprSetParent(this);
  +    m_expr = expr;
     }
   
  -  
     /** 
      * Get the analysis bits for this walker, as defined in the WalkerFactory.
      * @return One of WalkerFactory#BIT_DESCENDANT, etc.
      */
     public int getAnalysisBits()
     {
  -      if (null != m_expr && m_expr instanceof PathComponent)
  -      {
  -        return ((PathComponent) m_expr).getAnalysisBits();
  -      }
  -      return WalkerFactory.BIT_FILTER;
  +    if (null != m_expr && m_expr instanceof PathComponent)
  +    {
  +      return ((PathComponent) m_expr).getAnalysisBits();
  +    }
  +    return WalkerFactory.BIT_FILTER;
     }
  -  
  +
     /**
      * Returns true if all the nodes in the iteration well be returned in document 
      * order.
  @@ -318,9 +358,14 @@
      */
     public boolean isDocOrdered()
     {
  -    return m_exprObj.isDocOrdered();
  +    if(m_exprObj instanceof XNodeSet)
  +      return ((XNodeSet)m_exprObj).isDocOrdered();
  +    else if(m_exprObj instanceof XSequenceSingleton)
  +      return true;
  +    else
  +      return false;
     }
  -  
  +
     /**
      * Returns the axis being iterated, if it is known.
      * 
  @@ -329,61 +374,120 @@
      */
     public int getAxis()
     {
  -    return m_exprObj.getAxis();
  +    if(null != m_exprObj && m_exprObj instanceof XNodeSet)
  +      return ((XNodeSet)m_exprObj).getAxis();
  +    else
  +      return Axis.FILTEREDLIST;
     }
  -  
  +
     class filterExprOwner implements ExpressionOwner
     {
  -      /**
  -     * @see ExpressionOwner#getExpression()
  -     */
  +    /**
  +    * @see ExpressionOwner#getExpression()
  +    */
       public Expression getExpression()
       {
         return m_expr;
       }
  -
  +
       /**
        * @see ExpressionOwner#setExpression(Expression)
        */
       public void setExpression(Expression exp)
       {
  -    	exp.exprSetParent(FilterExprWalker.this);
  -    	m_expr = exp;
  -    }
  +      exp.exprSetParent(FilterExprWalker.this);
  +      m_expr = exp;
  +    }
  +
     }
  -  
  -	/**
  -	 * This will traverse the heararchy, calling the visitor for 
  -	 * each member.  If the called visitor method returns 
  -	 * false, the subtree should not be called.
  -	 * 
  -	 * @param owner The owner of the visitor, where that path may be 
  -	 *              rewritten if needed.
  -	 * @param visitor The visitor whose appropriate method will be called.
  -	 */
  -	public void callPredicateVisitors(XPathVisitor visitor)
  -	{
  -	  m_expr.callVisitors(new filterExprOwner(), visitor);
  -	  
  -	  super.callPredicateVisitors(visitor);
  -	} 
   
  +  /**
  +   * This will traverse the heararchy, calling the visitor for 
  +   * each member.  If the called visitor method returns 
  +   * false, the subtree should not be called.
  +   * 
  +   * @param owner The owner of the visitor, where that path may be 
  +   *              rewritten if needed.
  +   * @param visitor The visitor whose appropriate method will be called.
  +   */
  +  public void callPredicateVisitors(XPathVisitor visitor)
  +  {
  +    m_expr.callVisitors(new filterExprOwner(), visitor);
   
  -    /**
  -     * @see Expression#deepEquals(Expression)
  -     */
  -    public boolean deepEquals(Expression expr)
  -    {
  -      if (!super.deepEquals(expr))
  -                return false;
  +    super.callPredicateVisitors(visitor);
  +  }
   
  -      FilterExprWalker walker = (FilterExprWalker)expr;
  -      if(!m_expr.deepEquals(walker.m_expr))
  -      	return false;
  +  /**
  +   * @see Expression#deepEquals(Expression)
  +   */
  +  public boolean deepEquals(Expression expr)
  +  {
  +    if (!super.deepEquals(expr))
  +      return false;
   
  -      return true;
  +    FilterExprWalker walker = (FilterExprWalker) expr;
  +    if (!m_expr.deepEquals(walker.m_expr))
  +      return false;
  +
  +    return true;
  +  }
  +
  +  public void jjtAddChild(Node n, int i)
  +  {
  +    if (n instanceof AxesWalker)
  +    {
  +      super.jjtAddChild(n, i);
  +    }
  +    else // Do we care about i?
  +      {
  +      n = fixupPrimarys(n);
  +      m_expr = (Expression) n;
       }
   
  -	
  +  }
  +
  +  public Node jjtGetChild(int i)
  +  {
  +    if (i == 0)
  +      return m_expr;
  +    else
  +      if ((null != m_nextWalker) && i == 1)
  +        return m_nextWalker;
  +      else
  +        return null;
  +  }
  +
  +  public int jjtGetNumChildren()
  +  {
  +    return ((null == m_nextWalker) ? 0 : 1) + ((null == m_expr) ? 0 : 1);
  +  }
  +
  +  /**
  +   * This function checks the integrity of the tree, after it has been fully built and 
  +   * is ready for execution.  Derived classes can overload this function to check 
  +   * their own assumptions.
  +   */
  +  public boolean checkTreeIntegrity(
  +    int levelCount,
  +    int childNumber,
  +    boolean isOK)
  +  {
  +    if (null == m_expr)
  +      isOK =
  +        flagProblem(
  +          toString()
  +            + " the expression for FilterExpr can not be null at this point!");
  +    return super.checkTreeIntegrity(levelCount, childNumber, isOK);
  +  }
  +  
  +  /**
  +   * @see org.apache.xpath.parser.SimpleNode#isPathExpr()
  +   */
  +  public boolean isPathExpr()
  +  {
  +    // keep it from reducing if not a nodeset expression.
  +    return (m_expr instanceof DTMIterator) ? true : 
  +      (m_expr instanceof PathExpr) ? true : false; 
  +  }
   
   }
  
  
  
  1.2.4.1   +4 -4      xml-xalan/java/src/org/apache/xpath/axes/HasPositionalPredChecker.java
  
  Index: HasPositionalPredChecker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/HasPositionalPredChecker.java,v
  retrieving revision 1.2
  retrieving revision 1.2.4.1
  diff -u -r1.2 -r1.2.4.1
  --- HasPositionalPredChecker.java	22 Mar 2002 01:04:42 -0000	1.2
  +++ HasPositionalPredChecker.java	14 Aug 2002 20:06:57 -0000	1.2.4.1
  @@ -8,10 +8,10 @@
   import org.apache.xpath.functions.Function;
   import org.apache.xpath.objects.XNumber;
   import org.apache.xpath.operations.Div;
  -import org.apache.xpath.operations.Minus;
  +import org.apache.xpath.operations.Subtract;
   import org.apache.xpath.operations.Mod;
   import org.apache.xpath.operations.Mult;
  -import org.apache.xpath.operations.Plus;
  +import org.apache.xpath.operations.Add;
   import org.apache.xpath.operations.Quo;
   import org.apache.xpath.operations.Variable;
   
  @@ -81,8 +81,8 @@
         if((pred instanceof Variable) || 
            (pred instanceof XNumber) ||
            (pred instanceof Div) ||
  -         (pred instanceof Plus) ||
  -         (pred instanceof Minus) ||
  +         (pred instanceof Add) ||
  +         (pred instanceof Subtract) ||
            (pred instanceof Mod) ||
            (pred instanceof Quo) ||
            (pred instanceof Mult) ||
  
  
  
  1.35.2.1  +38 -49    xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java
  
  Index: LocPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java,v
  retrieving revision 1.35
  retrieving revision 1.35.2.1
  diff -u -r1.35 -r1.35.2.1
  --- LocPathIterator.java	27 Jun 2002 14:50:54 -0000	1.35
  +++ LocPathIterator.java	14 Aug 2002 20:06:57 -0000	1.35.2.1
  @@ -70,11 +70,9 @@
   import org.apache.xpath.ExpressionOwner;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.compiler.Compiler;
   import org.apache.xpath.objects.XNodeSet;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.res.XPATHErrorResources;
  -import org.apache.xalan.res.XSLMessages;
  +import org.apache.xpath.parser.Node;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
   
  @@ -102,6 +100,7 @@
      */
     protected LocPathIterator()
     {
  +    setLocPathIterator(this);
     }
   
   
  @@ -115,48 +114,10 @@
     {
   
       setLocPathIterator(this);
  -    m_prefixResolver = nscontext;
  -  }
   
  -  /**
  -   * Create a LocPathIterator object, including creation
  -   * of step walkers from the opcode list, and call back
  -   * into the Compiler to create predicate expressions.
  -   *
  -   * @param compiler The Compiler which is creating
  -   * this expression.
  -   * @param opPos The position of this iterator in the
  -   * opcode list from the compiler.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  protected LocPathIterator(Compiler compiler, int opPos, int analysis)
  -          throws javax.xml.transform.TransformerException
  -  {
  -    this(compiler, opPos, analysis, true);
  +    m_prefixResolver = nscontext;
     }
   
  -  /**
  -   * Create a LocPathIterator object, including creation
  -   * of step walkers from the opcode list, and call back
  -   * into the Compiler to create predicate expressions.
  -   *
  -   * @param compiler The Compiler which is creating
  -   * this expression.
  -   * @param opPos The position of this iterator in the
  -   * opcode list from the compiler.
  -   * @param shouldLoadWalkers True if walkers should be
  -   * loaded, or false if this is a derived iterator and
  -   * it doesn't wish to load child walkers.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  protected LocPathIterator(
  -          Compiler compiler, int opPos, int analysis, boolean shouldLoadWalkers)
  -            throws javax.xml.transform.TransformerException
  -  {
  -    setLocPathIterator(this);
  -  }
     
     /** 
      * Get the analysis bits for this walker, as defined in the WalkerFactory.
  @@ -233,7 +194,10 @@
      */
     public DTMManager getDTMManager()
     {
  -    return m_execContext.getDTMManager();
  +    if(null != m_execContext)
  +      return m_execContext.getDTMManager();
  +    else
  +      return null;
     }
     
     /**
  @@ -253,8 +217,12 @@
     {
   
       XNodeSet iter = new XNodeSet((LocPathIterator)m_clones.getInstance());
  -
  -    iter.setRoot(xctxt.getCurrentNode(), xctxt);
  +    int nodeHandle = xctxt.getCurrentNode();
  +    if(nodeHandle == DTM.NULL)
  +    {
  +      throw new RuntimeException("Can not execute path expression without a current node being active!");
  +    }
  +    iter.setRoot(nodeHandle, xctxt);
   
       return iter;
     }
  @@ -460,10 +428,10 @@
      *
      * @param b True if this iterator should cache nodes.
      */
  -  public void setShouldCacheNodes(boolean b)
  +  public void setShouldCache(boolean b)
     {
   
  -    assertion(false, "setShouldCacheNodes not supported by this iterater!");
  +    assertion(false, "setShouldCache not supported by this iterater!");
     }
     
     /**
  @@ -619,7 +587,7 @@
     public int previousNode()
     {
       throw new RuntimeException(
  -      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_ITERATE, null)); //"This NodeSetDTM can not iterate to a previous node!");
  +      "This NodeSetDTM can not iterate to a previous node!");
     }
   
     /**
  @@ -1063,5 +1031,26 @@
     {
       return getLength();
     }
  -
  +
  +  /**
  +   * @see java.lang.Object#toString()
  +   */
  +  public String toString()
  +  {
  +  	String namespace = getNamespace();
  +  	String localname = getLocalName();
  +  	if(getAxis() >= 0)
  +  	{
  +	  	return org.apache.xml.dtm.Axis.names[getAxis()]+"::"+
  +	  		((null != namespace) ? (namespace+":") : "")+
  +	  		((null != localname) ? localname : "node()")+
  +	  		" "+super.toString();
  +  	}
  +  	else
  +  	{
  +  		return super.toString();
  +  	}
  +  }
  +
  +  
   }
  
  
  
  1.4.4.1   +91 -93    xml-xalan/java/src/org/apache/xpath/axes/MatchPatternIterator.java
  
  Index: MatchPatternIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/MatchPatternIterator.java,v
  retrieving revision 1.4
  retrieving revision 1.4.4.1
  diff -u -r1.4 -r1.4.4.1
  --- MatchPatternIterator.java	22 Mar 2002 01:04:42 -0000	1.4
  +++ MatchPatternIterator.java	14 Aug 2002 20:06:57 -0000	1.4.4.1
  @@ -63,8 +63,6 @@
   import org.apache.xpath.XPathContext;
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.axes.SubContextList;
  -import org.apache.xpath.compiler.PsuedoNames;
  -import org.apache.xpath.compiler.Compiler;
   import org.apache.xpath.patterns.StepPattern;
   import org.apache.xpath.VariableStack;
   import org.apache.xpath.patterns.NodeTest;
  @@ -100,97 +98,97 @@
     
   //  protected int m_nsElemBase = DTM.NULL;
   
  -  /**
  -   * Create a LocPathIterator object, including creation
  -   * of step walkers from the opcode list, and call back
  -   * into the Compiler to create predicate expressions.
  -   *
  -   * @param compiler The Compiler which is creating
  -   * this expression.
  -   * @param opPos The position of this iterator in the
  -   * opcode list from the compiler.
  -   * @param analysis Analysis bits that give general information about the 
  -   * LocationPath.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  MatchPatternIterator(Compiler compiler, int opPos, int analysis)
  -          throws javax.xml.transform.TransformerException
  -  {
  -
  -    super(compiler, opPos, analysis, false);
  -
  -    int firstStepPos = compiler.getFirstChildPos(opPos);
  -
  -    m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0); 
  -
  -    boolean fromRoot = false;
  -    boolean walkBack = false;
  -    boolean walkDescendants = false;
  -    boolean walkAttributes = false;
  -
  -    if (0 != (analysis & (WalkerFactory.BIT_ROOT | 
  -                          WalkerFactory.BIT_ANY_DESCENDANT_FROM_ROOT)))
  -      fromRoot = true;
  -      
  -    if (0 != (analysis
  -              & (WalkerFactory.BIT_ANCESTOR
  -                 | WalkerFactory.BIT_ANCESTOR_OR_SELF
  -                 | WalkerFactory.BIT_PRECEDING
  -                 | WalkerFactory.BIT_PRECEDING_SIBLING 
  -                 | WalkerFactory.BIT_FOLLOWING
  -                 | WalkerFactory.BIT_FOLLOWING_SIBLING
  -                 | WalkerFactory.BIT_PARENT | WalkerFactory.BIT_FILTER)))
  -      walkBack = true;
  -
  -    if (0 != (analysis
  -              & (WalkerFactory.BIT_DESCENDANT_OR_SELF
  -                 | WalkerFactory.BIT_DESCENDANT
  -                 | WalkerFactory.BIT_CHILD)))
  -      walkDescendants = true;
  -
  -    if (0 != (analysis
  -              & (WalkerFactory.BIT_ATTRIBUTE | WalkerFactory.BIT_NAMESPACE)))
  -      walkAttributes = true;
  -      
  -    if(false || DEBUG)
  -    {
  -      System.out.print("analysis: "+Integer.toBinaryString(analysis));
  -      System.out.println(", "+WalkerFactory.getAnalysisString(analysis));
  -    }
  -      
  -    if(fromRoot || walkBack)
  -    {
  -      if(walkAttributes)
  -      {
  -        m_superAxis = Axis.ALL;
  -      }
  -      else
  -      {
  -        m_superAxis = Axis.DESCENDANTSFROMROOT;
  -      }
  -    }
  -    else if(walkDescendants)
  -    {
  -      if(walkAttributes)
  -      {
  -        m_superAxis = Axis.ALLFROMNODE;
  -      }
  -      else
  -      {
  -        m_superAxis = Axis.DESCENDANTORSELF;
  -      }
  -    }
  -    else
  -    {
  -      m_superAxis = Axis.ALL;
  -    }
  -    if(false || DEBUG)
  -    {
  -      System.out.println("axis: "+Axis.names[m_superAxis]);
  -    }
  -    
  -  }
  +//  /**
  +//   * Create a LocPathIterator object, including creation
  +//   * of step walkers from the opcode list, and call back
  +//   * into the Compiler to create predicate expressions.
  +//   *
  +//   * @param compiler The Compiler which is creating
  +//   * this expression.
  +//   * @param opPos The position of this iterator in the
  +//   * opcode list from the compiler.
  +//   * @param analysis Analysis bits that give general information about the 
  +//   * LocationPath.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  MatchPatternIterator(Compiler compiler, int opPos, int analysis)
  +//          throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    super(compiler, opPos, analysis, false);
  +//
  +//    int firstStepPos = compiler.getFirstChildPos(opPos);
  +//
  +//    m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0); 
  +//
  +//    boolean fromRoot = false;
  +//    boolean walkBack = false;
  +//    boolean walkDescendants = false;
  +//    boolean walkAttributes = false;
  +//
  +//    if (0 != (analysis & (WalkerFactory.BIT_ROOT | 
  +//                          WalkerFactory.BIT_ANY_DESCENDANT_FROM_ROOT)))
  +//      fromRoot = true;
  +//      
  +//    if (0 != (analysis
  +//              & (WalkerFactory.BIT_ANCESTOR
  +//                 | WalkerFactory.BIT_ANCESTOR_OR_SELF
  +//                 | WalkerFactory.BIT_PRECEDING
  +//                 | WalkerFactory.BIT_PRECEDING_SIBLING 
  +//                 | WalkerFactory.BIT_FOLLOWING
  +//                 | WalkerFactory.BIT_FOLLOWING_SIBLING
  +//                 | WalkerFactory.BIT_PARENT | WalkerFactory.BIT_FILTER)))
  +//      walkBack = true;
  +//
  +//    if (0 != (analysis
  +//              & (WalkerFactory.BIT_DESCENDANT_OR_SELF
  +//                 | WalkerFactory.BIT_DESCENDANT
  +//                 | WalkerFactory.BIT_CHILD)))
  +//      walkDescendants = true;
  +//
  +//    if (0 != (analysis
  +//              & (WalkerFactory.BIT_ATTRIBUTE | WalkerFactory.BIT_NAMESPACE)))
  +//      walkAttributes = true;
  +//      
  +//    if(false || DEBUG)
  +//    {
  +//      System.out.print("analysis: "+Integer.toBinaryString(analysis));
  +//      System.out.println(", "+WalkerFactory.getAnalysisString(analysis));
  +//    }
  +//      
  +//    if(fromRoot || walkBack)
  +//    {
  +//      if(walkAttributes)
  +//      {
  +//        m_superAxis = Axis.ALL;
  +//      }
  +//      else
  +//      {
  +//        m_superAxis = Axis.DESCENDANTSFROMROOT;
  +//      }
  +//    }
  +//    else if(walkDescendants)
  +//    {
  +//      if(walkAttributes)
  +//      {
  +//        m_superAxis = Axis.ALLFROMNODE;
  +//      }
  +//      else
  +//      {
  +//        m_superAxis = Axis.DESCENDANTORSELF;
  +//      }
  +//    }
  +//    else
  +//    {
  +//      m_superAxis = Axis.ALL;
  +//    }
  +//    if(false || DEBUG)
  +//    {
  +//      System.out.println("axis: "+Axis.names[m_superAxis]);
  +//    }
  +//    
  +//  }
     
     
     /**
  
  
  
  1.8.4.1   +6 -8      xml-xalan/java/src/org/apache/xpath/axes/OneStepIterator.java
  
  Index: OneStepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/OneStepIterator.java,v
  retrieving revision 1.8
  retrieving revision 1.8.4.1
  diff -u -r1.8 -r1.8.4.1
  --- OneStepIterator.java	22 Mar 2002 01:04:43 -0000	1.8
  +++ OneStepIterator.java	14 Aug 2002 20:06:57 -0000	1.8.4.1
  @@ -7,7 +7,7 @@
   import org.apache.xml.dtm.DTMIterator;
   import org.apache.xpath.Expression;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.compiler.Compiler;
  +import org.apache.xpath.parser.StepExpr;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -26,19 +26,17 @@
     /**
      * Create a OneStepIterator object.
      *
  -   * @param compiler A reference to the Compiler that contains the op map.
  -   * @param opPos The position within the op map, which contains the
  -   * location path expression for this itterator.
  +   * @param stepExpr The step expression from the parser.
  +   * @param analysis The analysis bits for the total path expression.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  OneStepIterator(Compiler compiler, int opPos, int analysis)
  +  OneStepIterator(StepExpr stepExpr, int analysis)
             throws javax.xml.transform.TransformerException
     {
  -    super(compiler, opPos, analysis);
  -    int firstStepPos = compiler.getFirstChildPos(opPos);
  +    super(stepExpr, analysis);
       
  -    m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);
  +    m_axis = stepExpr.getAxis();
       
     }
     
  
  
  
  1.5.4.1   +7 -9      xml-xalan/java/src/org/apache/xpath/axes/OneStepIteratorForward.java
  
  Index: OneStepIteratorForward.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/OneStepIteratorForward.java,v
  retrieving revision 1.5
  retrieving revision 1.5.4.1
  diff -u -r1.5 -r1.5.4.1
  --- OneStepIteratorForward.java	22 Mar 2002 01:04:43 -0000	1.5
  +++ OneStepIteratorForward.java	14 Aug 2002 20:06:57 -0000	1.5.4.1
  @@ -4,7 +4,7 @@
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMFilter;
   import org.apache.xpath.Expression;
  -import org.apache.xpath.compiler.Compiler;
  +import org.apache.xpath.parser.StepExpr;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -20,21 +20,19 @@
     protected int m_axis = -1;
   
     /**
  -   * Create a OneStepIterator object.
  +   * Create a OneStepIteratorForward object.
      *
  -   * @param compiler A reference to the Compiler that contains the op map.
  -   * @param opPos The position within the op map, which contains the
  -   * location path expression for this itterator.
  +   * @param stepExpr The step expression from the parser.
  +   * @param analysis The analysis bits for the total path expression.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  OneStepIteratorForward(Compiler compiler, int opPos, int analysis)
  +  OneStepIteratorForward(StepExpr stepExpr, int analysis)
             throws javax.xml.transform.TransformerException
     {
  -    super(compiler, opPos, analysis);
  -    int firstStepPos = compiler.getFirstChildPos(opPos);
  +    super(stepExpr, analysis);
       
  -    m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);
  +    m_axis = stepExpr.getAxis();
       
     }
       
  
  
  
  1.11.2.1  +81 -18    xml-xalan/java/src/org/apache/xpath/axes/PredicatedNodeTest.java
  
  Index: PredicatedNodeTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/PredicatedNodeTest.java,v
  retrieving revision 1.11
  retrieving revision 1.11.2.1
  diff -u -r1.11 -r1.11.2.1
  --- PredicatedNodeTest.java	6 May 2002 21:57:45 -0000	1.11
  +++ PredicatedNodeTest.java	14 Aug 2002 20:06:57 -0000	1.11.2.1
  @@ -10,10 +10,13 @@
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.Expression;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.compiler.Compiler;
   import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.parser.Node;
  +import org.apache.xpath.parser.Predicates;
  +import org.apache.xpath.parser.StepExpr;
   import org.apache.xpath.patterns.NodeTest;
   
   public abstract class PredicatedNodeTest extends NodeTest implements SubContextList
  @@ -140,22 +143,24 @@
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  protected void initPredicateInfo(Compiler compiler, int opPos)
  +  protected void initPredicateInfo(StepExpr stepExpr)
             throws javax.xml.transform.TransformerException
     {
  -
  -    int pos = compiler.getFirstPredicateOpPos(opPos);
  -
  -    if(pos > 0)
  +    Expression lastChild = (Expression)stepExpr.jjtGetChild(stepExpr.jjtGetNumChildren()-1);
  +    if(lastChild instanceof Predicates)
       {
  -      m_predicates = compiler.getCompiledPredicates(pos);
  -      if(null != m_predicates)
  -      {
  -      	for(int i = 0; i < m_predicates.length; i++)
  -      	{
  -      		m_predicates[i].exprSetParent(this);
  -      	}
  -      }
  +    	Predicates preds = (Predicates)lastChild;
  +    	int numPreds = preds.jjtGetNumChildren();
  +    	if(numPreds > 0)
  +    	{
  +    		m_predicates = new Expression[numPreds];
  +	      	for(int i = 0; i < m_predicates.length; i++)
  +	      	{
  +	      		Expression pred = (Expression)preds.jjtGetChild(i);
  +	      		m_predicates[i] = pred;
  +	      		pred.exprSetParent(this);
  +	      	}
  +    	}
       }
     }
   
  @@ -393,15 +398,15 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
   
       int nPredicates = getPredicateCount();
   
       for (int i = 0; i < nPredicates; i++)
       {
  -      m_predicates[i].fixupVariables(vars, globalsSize);
  +      m_predicates[i].fixupVariables(vcs);
       }
     }
   
  @@ -624,5 +629,63 @@
       	m_predicates[m_index] = exp;
       }
     }
  -    
  +  
  +  public String toString()
  +  {
  +  	int myCount = (null == m_predicates) ? 0 : m_predicates.length;
  +  	String str = "";
  +  	
  +  	for(int i = 0; i < myCount; i++)
  +  	{
  +  		// java.io.StringWriter sw = new java.io.StringWriter();
  +  		char buf[] = new char[1024*32];
  +  		java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
  +  		java.io.PrintStream ps = new java.io.PrintStream(baos);
  +  		
  +  		m_predicates[i].dump("", ps);
  +  		ps.flush();
  +  		String predString = baos.toString().trim();
  +  		
  +  		str += "["+predString+"]";
  +  	}
  +  	str += " "+super.toString();
  +  	return str;
  +  }
  +
  +  
  +//  public Node jjtGetChild(int i) 
  +//  {
  +//    int superclassChildCount = super.jjtGetNumChildren();
  +//  	int myCount = (null == m_predicates) ? 0 : m_predicates.length;
  +//    if(i < myCount)
  +//    	return m_predicates[i];
  +//    else
  +//    	return super.jjtGetChild(i-myCount);
  +//  }
  +//
  +//  public int jjtGetNumChildren() 
  +//  {
  +//  	int myCount = (null == m_predicates) ? 0 : m_predicates.length;
  +//    return super.jjtGetNumChildren()+myCount;
  +//  }
  +
  +  /**
  +   * Tell if this node is part of a PathExpr chain.  For instance:
  +   * <pre>
  +   * 	|UnaryExpr
  +   * 	|   PathExpr
  +   * 	|      StepExpr
  +   * 	|         AxisChild child::
  +   * 	|         NodeTest
  +   * 	|            NameTest
  +   * 	|               QName foo
  +   * 	|         Predicates   * 
  +   * </pre><br/>
  +   * In this example, UnaryExpr, PathExpr, and StepExpr should all return true.
  +   */
  +  public boolean isPathExpr()
  +  {
  +  	return true;
  +  }
  +
   }
  
  
  
  1.1.2.1   +7 -8      xml-xalan/java/src/org/apache/xpath/axes/RTFIterator.java
  
  Index: RTFIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/RTFIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- RTFIterator.java	18 Jun 2002 15:31:02 -0000	1.1
  +++ RTFIterator.java	14 Aug 2002 20:06:57 -0000	1.1.2.1
  @@ -7,17 +7,16 @@
   package org.apache.xpath.axes;
   
   import javax.xml.transform.TransformerException;
  -import org.apache.xpath.compiler.Compiler;
   
   public class RTFIterator extends OneStepIteratorForward {
   
  -	/**
  -	 * Constructor for RTFIterator
  -	 */
  -	RTFIterator(Compiler compiler, int opPos, int analysis)
  -		throws TransformerException {
  -		super(compiler, opPos, analysis);
  -	}
  +//	/**
  +//	 * Constructor for RTFIterator
  +//	 */
  +//	RTFIterator(Compiler compiler, int opPos, int analysis)
  +//		throws TransformerException {
  +//		super(compiler, opPos, analysis);
  +//	}
   
   	/**
   	 * Constructor for RTFIterator
  
  
  
  1.10.4.1  +0 -1      xml-xalan/java/src/org/apache/xpath/axes/ReverseAxesWalker.java
  
  Index: ReverseAxesWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ReverseAxesWalker.java,v
  retrieving revision 1.10
  retrieving revision 1.10.4.1
  diff -u -r1.10 -r1.10.4.1
  --- ReverseAxesWalker.java	22 Mar 2002 01:04:43 -0000	1.10
  +++ ReverseAxesWalker.java	14 Aug 2002 20:06:57 -0000	1.10.4.1
  @@ -61,7 +61,6 @@
   import org.apache.xpath.axes.LocPathIterator;
   import org.apache.xpath.XPath;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.compiler.OpCodes;
   import org.apache.xpath.objects.XObject;
   
   import javax.xml.transform.TransformerException;
  
  
  
  1.6.4.1   +31 -10    xml-xalan/java/src/org/apache/xpath/axes/SelfIteratorNoPredicate.java
  
  Index: SelfIteratorNoPredicate.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/SelfIteratorNoPredicate.java,v
  retrieving revision 1.6
  retrieving revision 1.6.4.1
  diff -u -r1.6 -r1.6.4.1
  --- SelfIteratorNoPredicate.java	22 Mar 2002 01:04:43 -0000	1.6
  +++ SelfIteratorNoPredicate.java	14 Aug 2002 20:06:57 -0000	1.6.4.1
  @@ -2,7 +2,8 @@
   
   import javax.xml.transform.TransformerException;
   
  -import org.apache.xpath.compiler.Compiler;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.objects.XSequence;
   import org.apache.xpath.patterns.NodeTest;
   import org.apache.xpath.XPathContext;
   import org.apache.xml.utils.PrefixResolver;
  @@ -20,6 +21,22 @@
   public class SelfIteratorNoPredicate extends LocPathIterator
   {
   
  +//  /**
  +//   * Create a SelfIteratorNoPredicate object.
  +//   *
  +//   * @param compiler A reference to the Compiler that contains the op map.
  +//   * @param opPos The position within the op map, which contains the
  +//   * location path expression for this itterator.
  +//   * @param analysis Analysis bits.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  SelfIteratorNoPredicate(Compiler compiler, int opPos, int analysis)
  +//          throws javax.xml.transform.TransformerException
  +//  {
  +//    super(compiler, opPos, analysis, false);
  +//  }
  +  
     /**
      * Create a SelfIteratorNoPredicate object.
      *
  @@ -30,27 +47,31 @@
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  SelfIteratorNoPredicate(Compiler compiler, int opPos, int analysis)
  +  public SelfIteratorNoPredicate()
             throws javax.xml.transform.TransformerException
     {
  -    super(compiler, opPos, analysis, false);
  +    super(null);
     }
     
     /**
  -   * Create a SelfIteratorNoPredicate object.
  +   * Execute this iterator, meaning create a clone that can
  +   * store state, and initialize it for fast execution from
  +   * the current runtime state.  When this is called, no actual
  +   * query from the current context node is performed.
      *
  -   * @param compiler A reference to the Compiler that contains the op map.
  -   * @param opPos The position within the op map, which contains the
  -   * location path expression for this itterator.
  -   * @param analysis Analysis bits.
  +   * @param xctxt The XPath execution context.
  +   *
  +   * @return An XNodeSet reference that holds this iterator.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  public SelfIteratorNoPredicate()
  +  public XObject execute(XPathContext xctxt)
             throws javax.xml.transform.TransformerException
     {
  -    super(null);
  +    XObject item = xctxt.getCurrentItem();
  +    return item;
     }
  +
   
   
     /**
  
  
  
  1.26.4.1  +226 -272  xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java
  
  Index: UnionPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java,v
  retrieving revision 1.26
  retrieving revision 1.26.4.1
  diff -u -r1.26 -r1.26.4.1
  --- UnionPathIterator.java	22 Mar 2002 01:04:43 -0000	1.26
  +++ UnionPathIterator.java	14 Aug 2002 20:06:57 -0000	1.26.4.1
  @@ -56,20 +56,15 @@
    */
   package org.apache.xpath.axes;
   
  -import java.io.IOException;
  -import java.io.ObjectInputStream;
  -import java.io.Serializable;
  -import java.util.Vector;
  -
  -import javax.xml.transform.TransformerException;
  -import org.apache.xml.dtm.Axis;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
   import org.apache.xpath.Expression;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.compiler.OpCodes;
  +import org.apache.xpath.functions.Function;
  +import org.apache.xpath.operations.Variable;
  +import org.apache.xpath.parser.Node;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -79,8 +74,9 @@
    * As each node is iterated via nextNode(), the node is also stored
    * in the NodeVector, so that previousNode() can easily be done.
    */
  -public class UnionPathIterator extends LocPathIterator
  -        implements Cloneable, DTMIterator, java.io.Serializable, PathComponent
  +public class UnionPathIterator
  +  extends LocPathIterator
  +  implements Cloneable, DTMIterator, java.io.Serializable, PathComponent
   {
   
     /**
  @@ -114,7 +110,7 @@
         {
           int n = m_exprs.length;
           DTMIterator newIters[] = new DTMIterator[n];
  -  
  +
           for (int i = 0; i < n; i++)
           {
             DTMIterator iter = m_exprs[i].asIterator(m_execContext, context);
  @@ -124,12 +120,12 @@
           m_iterators = newIters;
         }
       }
  -    catch(Exception e)
  +    catch (Exception e)
       {
         throw new org.apache.xml.utils.WrappedRuntimeException(e);
       }
     }
  -  
  +
     /**
      * Add an iterator to the union list.
      *
  @@ -157,10 +153,10 @@
         m_iterators[len] = expr;
       }
       expr.nextNode();
  -    if(expr instanceof Expression)
  -    	((Expression)expr).exprSetParent(this);
  +    if (expr instanceof Expression)
  +       ((Expression) expr).exprSetParent(this);
     }
  -  
  +
     /**
      *  Detaches the iterator from the set which it iterated over, releasing
      * any computational resources and placing the iterator in the INVALID
  @@ -169,102 +165,85 @@
      * exception INVALID_STATE_ERR.
      */
     public void detach()
  -  {    
  -    if(null != m_iterators)
  +  {
  +    if (null != m_iterators)
       {
  -    	int n = m_iterators.length;
  -    	for(int i = 0; i < n; i++)
  -    	{
  -    		m_iterators[i].detach();
  -    	}
  -    	m_iterators = null;
  +      int n = m_iterators.length;
  +      for (int i = 0; i < n; i++)
  +      {
  +        m_iterators[i].detach();
  +      }
  +      m_iterators = null;
       }
     }
   
  -
     /**
  -   * Create a UnionPathIterator object, including creation 
  -   * of location path iterators from the opcode list, and call back 
  -   * into the Compiler to create predicate expressions.
  -   *
  -   * @param compiler The Compiler which is creating 
  -   * this expression.
  -   * @param opPos The position of this iterator in the 
  -   * opcode list from the compiler.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * @see org.apache.xpath.parser.Node#jjtAddChild(Node, int)
      */
  -  public UnionPathIterator(Compiler compiler, int opPos)
  -          throws javax.xml.transform.TransformerException
  +  public void jjtAddChild(Node n, int i)
     {
  +    if (n instanceof UnionPathIterator)
  +    {
  +      int nChildren = n.jjtGetNumChildren();
  +      for (int j = 0; j < nChildren; j++)
  +      {
  +        Node child = n.jjtGetChild(j);
  +        child.jjtSetParent(this);
  +        if (j == 0)
  +          jjtAddChild(child, i);
  +        else
  +          jjtAddChild(child, m_exprs.length); // order doesn't matter!
  +      }
  +      return;
  +    }
  +    if (null == m_exprs)
  +    {
  +      m_exprs = new LocPathIterator[i + 1];
  +    }
  +    else
  +      if (i >= m_exprs.length)
  +      {
   
  -    super();
  +        // Slow but space conservative.
  +        LocPathIterator[] exprs = new LocPathIterator[m_exprs.length + 1];
   
  -    opPos = compiler.getFirstChildPos(opPos);
  +        System.arraycopy(m_exprs, 0, exprs, 0, m_exprs.length);
  +
  +        m_exprs = exprs;
  +      }
  +    n = fixupPrimarys(n);
   
  -    loadLocationPaths(compiler, opPos, 0);
  +    // If a function or variable has been reduced from a path 
  +    // expression, essentially 
  +    // we need to turn it back into a path expression here!  There 
  +    // might be a way to do this a bit earlier.  -sb
  +    // if(!(((SimpleNode)n).isPathExpr()))
  +    if(n instanceof Variable || n instanceof Function)
  +    {
  +      FilterExprIteratorSimple feis =
  +        new FilterExprIteratorSimple((Expression) n);
  +      feis.jjtSetParent(this);
  +      n = feis;
  +    }
  +    m_exprs[i] = (LocPathIterator) n;
     }
  -  
  +
     /**
  -   * This will return an iterator capable of handling the union of paths given.
  -   * 
  -   * @param compiler The Compiler which is creating 
  -   * this expression.
  -   * @param opPos The position of this iterator in the 
  -   * opcode list from the compiler.
  -   * 
  -   * @return Object that is derived from LocPathIterator.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * @see org.apache.xpath.parser.Node#jjtGetChild(int)
      */
  -  public static LocPathIterator createUnionIterator(Compiler compiler, int opPos)
  -          throws javax.xml.transform.TransformerException
  +  public Node jjtGetChild(int i)
     {
  -  	// For the moment, I'm going to first create a full UnionPathIterator, and 
  -  	// then see if I can reduce it to a UnionChildIterator.  It would obviously 
  -  	// be more effecient to just test for the conditions for a UnionChildIterator, 
  -  	// and then create that directly.
  -  	UnionPathIterator upi = new UnionPathIterator(compiler, opPos);
  -  	int nPaths = upi.m_exprs.length;
  -  	boolean isAllChildIterators = true;
  -  	for(int i = 0; i < nPaths; i++)
  -  	{
  -  		LocPathIterator lpi = upi.m_exprs[i];
  -  		
  -  		if(lpi.getAxis() != Axis.CHILD)
  -  		{
  -  			isAllChildIterators = false;
  -  			break;
  -  		}
  -  		else
  -  		{
  -  			// check for positional predicates or position function, which won't work.
  -  			if(HasPositionalPredChecker.check(lpi))
  -  			{
  -  				isAllChildIterators = false;
  -  				break;
  -  			}
  -  		}
  -  	}
  -  	if(isAllChildIterators)
  -  	{
  -  		UnionChildIterator uci = new UnionChildIterator();
  -  		
  -	  	for(int i = 0; i < nPaths; i++)
  -	  	{
  -	  		PredicatedNodeTest lpi = upi.m_exprs[i];
  -	  		// I could strip the lpi down to a pure PredicatedNodeTest, but 
  -	  		// I don't think it's worth it.  Note that the test can be used 
  -	  		// as a static object... so it doesn't have to be cloned.
  -	  		uci.addNodeTest(lpi);
  -	  	}
  -	  	return uci;
  -  		
  -  	}
  -  	else
  -  		return upi;
  +    return m_exprs[i];
     }
  -  
  +
  +  /**
  +   * @see org.apache.xpath.parser.Node#jjtGetNumChildren()
  +   */
  +  public int jjtGetNumChildren()
  +  {
  +    return m_exprs.length;
  +  }
  +
     /** 
      * Get the analysis bits for this walker, as defined in the WalkerFactory.
      * @return One of WalkerFactory#BIT_DESCENDANT, etc.
  @@ -272,21 +251,21 @@
     public int getAnalysisBits()
     {
       int bits = 0;
  -    
  +
       if (m_exprs != null)
       {
         int n = m_exprs.length;
   
         for (int i = 0; i < n; i++)
         {
  -      	int bit = m_exprs[i].getAnalysisBits();
  +        int bit = m_exprs[i].getAnalysisBits();
           bits |= bit;
         }
       }
   
       return bits;
     }
  -  
  +
     /**
      * Read the object from a serialization stream.
      *
  @@ -296,12 +275,12 @@
      * @throws javax.xml.transform.TransformerException
      */
     private void readObject(java.io.ObjectInputStream stream)
  -          throws java.io.IOException, javax.xml.transform.TransformerException
  +    throws java.io.IOException, javax.xml.transform.TransformerException
     {
       try
       {
         stream.defaultReadObject();
  -      m_clones =  new IteratorPool(this);
  +      m_clones = new IteratorPool(this);
       }
       catch (ClassNotFoundException cnfe)
       {
  @@ -321,109 +300,56 @@
     {
   
       UnionPathIterator clone = (UnionPathIterator) super.clone();
  -//    if (m_iterators != null)
  -//    {
  -//      int n = m_iterators.length;
  -//
  -//      clone.m_iterators = new LocPathIterator[n];
  -//
  -//      for (int i = 0; i < n; i++)
  -//      {
  -//        clone.m_iterators[i] = (LocPathIterator)m_iterators[i].clone();
  -//      }
  -//    }
   
  +    // %REVIEW% Not 100% sure this clone should be done here! -sb
  +    if(clone.m_iterators == m_iterators && null != m_iterators)
  +    {
  +      DTMIterator[] clonedIters = new DTMIterator[m_iterators.length];
  +      clone.m_iterators = clonedIters;
  +      for (int i = 0; i < m_iterators.length; i++)
  +      {
  +        clonedIters[i] = (DTMIterator)((Expression)m_iterators[i]).cloneDeep();
  +      }
  +    }  
  +    
       return clone;
     }
  -  
  -  
  -  /**
  -   * Create a new location path iterator.
  -   *
  -   * @param compiler The Compiler which is creating 
  -   * this expression.
  -   * @param opPos The position of this iterator in the 
  -   *
  -   * @return New location path iterator.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  protected LocPathIterator createDTMIterator(
  -          Compiler compiler, int opPos) throws javax.xml.transform.TransformerException
  -  {
  -    LocPathIterator lpi = (LocPathIterator)WalkerFactory.newDTMIterator(compiler, opPos, 
  -                                      (compiler.getLocationPathDepth() <= 0));
  -    return lpi;
  -  }
   
     /**
  -   * Initialize the location path iterators.  Recursive.
  -   *
  -   * @param compiler The Compiler which is creating 
  -   * this expression.
  -   * @param opPos The position of this iterator in the 
  -   * opcode list from the compiler.
  -   * @param count The insert position of the iterator.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   *  Get a cloned Iterator that is reset to the beginning
  +   *  of the query.
  +   * 
  +   *  @return A cloned NodeIterator set of the start of the query.
  +   * 
  +   *  @throws CloneNotSupportedException
      */
  -  protected void loadLocationPaths(Compiler compiler, int opPos, int count)
  -          throws javax.xml.transform.TransformerException
  +  public DTMIterator cloneWithReset() throws CloneNotSupportedException
     {
   
  -    // TODO: Handle unwrapped FilterExpr
  -    int steptype = compiler.getOpMap()[opPos];
  +    UnionPathIterator clone = (UnionPathIterator) super.cloneWithReset();
   
  -    if (steptype == OpCodes.OP_LOCATIONPATH)
  -    {
  -      loadLocationPaths(compiler, compiler.getNextOpPos(opPos), count + 1);
  -
  -      m_exprs[count] = createDTMIterator(compiler, opPos);
  -      m_exprs[count].exprSetParent(this);
  -    }
  -    else
  -    {
  +    clone.resetProximityPositions();
   
  -      // Have to check for unwrapped functions, which the LocPathIterator
  -      // doesn't handle. 
  -      switch (steptype)
  -      {
  -      case OpCodes.OP_VARIABLE :
  -      case OpCodes.OP_EXTFUNCTION :
  -      case OpCodes.OP_FUNCTION :
  -      case OpCodes.OP_GROUP :
  -        loadLocationPaths(compiler, compiler.getNextOpPos(opPos), count + 1);
  -
  -        WalkingIterator iter =
  -          new WalkingIterator(compiler.getNamespaceContext());
  -        iter.exprSetParent(this);
  -          
  -        if(compiler.getLocationPathDepth() <= 0)
  -          iter.setIsTopLevel(true);
  -
  -        iter.m_firstWalker = new org.apache.xpath.axes.FilterExprWalker(iter);
  -
  -        iter.m_firstWalker.init(compiler, opPos, steptype);
  -
  -        m_exprs[count] = iter;
  -        break;
  -      default :
  -        m_exprs = new LocPathIterator[count];
  -      }
  -    }
  +    return clone;
     }
   
     /**
      *  Returns the next node in the set and advances the position of the
      * iterator in the set. After a DTMIterator is created, the first call
      * to nextNode() returns the first node in the set.
  +   * 
      * @return  The next <code>Node</code> in the set being iterated over, or
      *   <code>null</code> if there are no more members in that set.
      */
     public int nextNode()
     {
  -  	if(m_foundLast)
  -  		return DTM.NULL;
  +    if (m_foundLast)
  +      return DTM.NULL;
  +
  +    if (DTM.NULL == m_lastFetched)
  +    {
  +      resetProximityPositions();
  +    }
   
       // Loop through the iterators getting the current fetched 
       // node, and get the earliest occuring in document order
  @@ -433,42 +359,70 @@
       {
         int n = m_iterators.length;
         int iteratorUsed = -1;
  +      int savedIteratorUsed = -1;
  +      int savedEarliestNode = DTM.NULL;
   
  -      for (int i = 0; i < n; i++)
  +      while (true)
         {
  -        int node = m_iterators[i].getCurrentNode();
  -
  -        if (DTM.NULL == node)
  -          continue;
  -        else if (DTM.NULL == earliestNode)
  +        for (int i = 0; i < n; i++)
           {
  -          iteratorUsed = i;
  -          earliestNode = node;
  +          int node = m_iterators[i].getCurrentNode();
  +
  +          if (DTM.NULL == node)
  +            continue;
  +          else
  +            if (DTM.NULL == earliestNode)
  +            {
  +              iteratorUsed = i;
  +              earliestNode = node;
  +            }
  +            else
  +            {
  +              if (node == earliestNode)
  +              {
  +
  +                // Found a duplicate, so skip past it.
  +                // %REVIEW% Make sure this is really what we 
  +                // want to do for XPath 2.0.
  +                m_iterators[i].nextNode();
  +              }
  +              else
  +              {
  +                DTM dtm = getDTM(node);
  +
  +                if (dtm.isNodeAfter(node, earliestNode))
  +                {
  +                  iteratorUsed = i;
  +                  earliestNode = node;
  +                }
  +              }
  +            }
           }
  +
  +        if (DTM.NULL == earliestNode)
  +          break;
  +
           else
  -        {
  -          if (node == earliestNode)
  +          if (getPredicateCount() == 0)
             {
  -
  -            // Found a duplicate, so skip past it.
  -            m_iterators[i].nextNode();
  +            m_iterators[iteratorUsed].nextNode();
  +            break;
             }
             else
             {
  -            DTM dtm = getDTM(node);
  +            m_iterators[iteratorUsed].nextNode();
  +            int acceptence = acceptNode(earliestNode);
   
  -            if (dtm.isNodeAfter(node, earliestNode))
  -            {
  -              iteratorUsed = i;
  -              earliestNode = node;
  -            }
  +            if (DTMIterator.FILTER_ACCEPT == acceptence)
  +              break;
  +              
  +            earliestNode = DTM.NULL;
             }
  -        }
         }
   
         if (DTM.NULL != earliestNode)
         {
  -        m_iterators[iteratorUsed].nextNode();
  +        // m_iterators[iteratorUsed].nextNode();
   
           incrementCurrentPos();
         }
  @@ -480,10 +434,11 @@
   
       return earliestNode;
     }
  -            
  +
     /**
      * This function is used to fixup variables from QNames to stack frame 
      * indexes at stylesheet build time.
  +   * 
      * @param vars List of QNames that correspond to variables.  This list 
      * should be searched backwards for the first qualified name that 
      * corresponds to the variable reference qname.  The position of the 
  @@ -491,15 +446,15 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    for (int i = 0; i < m_exprs.length; i++) 
  +    for (int i = 0; i < m_exprs.length; i++)
       {
  -      m_exprs[i].fixupVariables(vars, globalsSize);
  +      m_exprs[i].fixupVariables(vcs);
       }
  -    
  +
     }
  -  
  +
     /**
      * The location path iterators, one for each
      * <a href="http://www.w3.org/TR/xpath#NT-LocationPath">location
  @@ -508,7 +463,6 @@
      */
     protected LocPathIterator[] m_exprs;
   
  -    
     /**
      * The location path iterators, one for each
      * <a href="http://www.w3.org/TR/xpath#NT-LocationPath">location
  @@ -516,7 +470,7 @@
      * @serial
      */
     protected DTMIterator[] m_iterators;
  -      
  +
     /**
      * Returns the axis being iterated, if it is known.
      * 
  @@ -528,16 +482,16 @@
       // Could be smarter.
       return -1;
     }
  -  
  +
     class iterOwner implements ExpressionOwner
     {
  -  	int m_index;
  -  	
  -  	iterOwner(int index)
  -  	{
  -  		m_index = index;
  -  	}
  -  	
  +    int m_index;
  +
  +    iterOwner(int index)
  +    {
  +      m_index = index;
  +    }
  +
       /**
        * @see ExpressionOwner#getExpression()
        */
  @@ -545,31 +499,31 @@
       {
         return m_exprs[m_index];
       }
  -
  +
       /**
        * @see ExpressionOwner#setExpression(Expression)
        */
       public void setExpression(Expression exp)
       {
  -    	
  -    	if(!(exp instanceof LocPathIterator))
  -    	{
  -    		// Yuck.  Need FilterExprIter.  Or make it so m_exprs can be just 
  -    		// plain expressions?
  -    		WalkingIterator wi = new WalkingIterator(getPrefixResolver());
  -    		FilterExprWalker few = new FilterExprWalker(wi);
  -    		wi.setFirstWalker(few);
  -    		few.setInnerExpression(exp);
  -    		wi.exprSetParent(UnionPathIterator.this);
  -    		few.exprSetParent(wi);
  -    		exp.exprSetParent(few);
  -    		exp = wi;
  -    	}
  -    	else
  -    		exp.exprSetParent(UnionPathIterator.this);
  -    	m_exprs[m_index] = (LocPathIterator)exp;
  +
  +      if (!(exp instanceof LocPathIterator))
  +      {
  +        // Yuck.  Need FilterExprIter.  Or make it so m_exprs can be just 
  +        // plain expressions?
  +        WalkingIterator wi = new WalkingIterator(getPrefixResolver());
  +        FilterExprWalker few = new FilterExprWalker(wi);
  +        wi.setFirstWalker(few);
  +        few.setInnerExpression(exp);
  +        wi.exprSetParent(UnionPathIterator.this);
  +        few.exprSetParent(wi);
  +        exp.exprSetParent(few);
  +        exp = wi;
  +      }
  +      else
  +        exp.exprSetParent(UnionPathIterator.this);
  +      m_exprs[m_index] = (LocPathIterator) exp;
       }
  -
  +
     }
   
     /**
  @@ -577,49 +531,49 @@
      */
     public void callVisitors(ExpressionOwner owner, XPathVisitor visitor)
     {
  -  	 	if(visitor.visitUnionPath(owner, this))
  -  	 	{
  -  	 		if(null != m_exprs)
  -  	 		{
  -  	 			int n = m_exprs.length;
  -  	 			for(int i = 0; i < n; i++)
  -  	 			{
  -  	 				m_exprs[i].callVisitors(new iterOwner(i), visitor);
  -  	 			}
  -  	 		}
  -  	 	}
  -  }
  -  
  -    /**
  -     * @see Expression#deepEquals(Expression)
  -     */
  -    public boolean deepEquals(Expression expr)
  +    if (visitor.visitUnionPath(owner, this))
       {
  -      if (!super.deepEquals(expr))
  -            return false;
  -
  -      UnionPathIterator upi = (UnionPathIterator) expr;
  -
         if (null != m_exprs)
         {
           int n = m_exprs.length;
  -        
  -        if((null == upi.m_exprs) || (upi.m_exprs.length != n))
  -        	return false;
  -        
           for (int i = 0; i < n; i++)
           {
  -          if(!m_exprs[i].deepEquals(upi.m_exprs[i]))
  -          	return false;
  +          m_exprs[i].callVisitors(new iterOwner(i), visitor);
           }
         }
  -      else if (null != upi.m_exprs)
  +    }
  +  }
  +
  +  /**
  +   * @see Expression#deepEquals(Expression)
  +   */
  +  public boolean deepEquals(Expression expr)
  +  {
  +    if (!super.deepEquals(expr))
  +      return false;
  +
  +    UnionPathIterator upi = (UnionPathIterator) expr;
  +
  +    if (null != m_exprs)
  +    {
  +      int n = m_exprs.length;
  +
  +      if ((null == upi.m_exprs) || (upi.m_exprs.length != n))
  +        return false;
  +
  +      for (int i = 0; i < n; i++)
         {
  +        if (!m_exprs[i].deepEquals(upi.m_exprs[i]))
             return false;
         }
  -
  -      return true;
       }
  +    else
  +      if (null != upi.m_exprs)
  +      {
  +        return false;
  +      }
   
  +    return true;
  +  }
   
   }
  
  
  
  1.23.2.1  +3000 -1588xml-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.23
  retrieving revision 1.23.2.1
  diff -u -r1.23 -r1.23.2.1
  --- WalkerFactory.java	13 May 2002 02:03:58 -0000	1.23
  +++ WalkerFactory.java	14 Aug 2002 20:06:57 -0000	1.23.2.1
  @@ -56,133 +56,339 @@
    */
   package org.apache.xpath.axes;
   
  -import org.apache.xpath.compiler.OpCodes;
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xpath.compiler.FunctionTable;
  -import org.apache.xpath.patterns.NodeTest;
  -import org.apache.xpath.patterns.StepPattern;
  -import org.apache.xpath.patterns.ContextMatchStepPattern;
  -import org.apache.xpath.patterns.FunctionPattern;
  -import org.apache.xpath.Expression;
  -import org.apache.xpath.objects.XNumber;
  +import javax.xml.transform.TransformerException;
   import org.apache.xalan.res.XSLMessages;
  -import org.apache.xpath.res.XPATHErrorResources;
  -
  +import org.apache.xml.dtm.Axis;
   import org.apache.xml.dtm.DTMFilter;
   import org.apache.xml.dtm.DTMIterator;
  -import org.apache.xml.dtm.Axis;
  +import org.apache.xpath.Expression;
  +import org.apache.xpath.functions.FuncLast;
  +import org.apache.xpath.functions.FuncPosition;
  +import org.apache.xpath.functions.Function;
  +import org.apache.xpath.objects.XNumber;
  +import org.apache.xpath.operations.Variable;
  +import org.apache.xpath.parser.Node;
  +import org.apache.xpath.parser.NodeTest;
  +import org.apache.xpath.parser.PathExpr;
  +import org.apache.xpath.parser.PatternAxis;
  +import org.apache.xpath.parser.Predicates;
  +import org.apache.xpath.parser.StepExpr;
  +import org.apache.xpath.res.XPATHErrorResources;
   
  -/**
  - * This class is both a factory for XPath location path expressions,
  - * which are built from the opcode map output, and an analysis engine
  - * for the location path expressions in order to provide optimization hints.
  - */
   public class WalkerFactory
   {
  +  public static boolean isSet(int analysis, int bits)
  +  {
  +    return (0 != (analysis & bits));
  +  }
   
     /**
  -   * <meta name="usage" content="advanced"/>
  -   * This method is for building an array of possible levels
  -   * where the target element(s) could be found for a match.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  +   * Get a corresponding BIT_XXX from an axis.
  +   * @param axis One of Axis.ANCESTOR, etc.
  +   * @return One of BIT_ANCESTOR, etc.
  +   */
  +  static public int getAnalysisBitFromAxes(int axis)
  +  {
  +    switch (axis) // Generate new traverser
  +    {
  +      case Axis.ANCESTOR :
  +        return BIT_ANCESTOR;
  +      case Axis.ANCESTORORSELF :
  +        return BIT_ANCESTOR_OR_SELF;
  +      case Axis.ATTRIBUTE :
  +        return BIT_ATTRIBUTE;
  +      case Axis.CHILD :
  +        return BIT_CHILD;
  +      case Axis.DESCENDANT :
  +        return BIT_DESCENDANT;
  +      case Axis.DESCENDANTORSELF :
  +        return BIT_DESCENDANT_OR_SELF;
  +      case Axis.FOLLOWING :
  +        return BIT_FOLLOWING;
  +      case Axis.FOLLOWINGSIBLING :
  +        return BIT_FOLLOWING_SIBLING;
  +      case Axis.NAMESPACE :
  +      case Axis.NAMESPACEDECLS :
  +        return BIT_NAMESPACE;
  +      case Axis.PARENT :
  +        return BIT_PARENT;
  +      case Axis.PRECEDING :
  +        return BIT_PRECEDING;
  +      case Axis.PRECEDINGSIBLING :
  +        return BIT_PRECEDING_SIBLING;
  +      case Axis.SELF :
  +        return BIT_SELF;
  +      case Axis.ALLFROMNODE :
  +        return BIT_DESCENDANT_OR_SELF;
  +        // case Axis.PRECEDINGANDANCESTOR :
  +      case Axis.DESCENDANTSFROMROOT :
  +      case Axis.ALL :
  +      case Axis.DESCENDANTSORSELFFROMROOT :
  +        return BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF | BIT_ANY_DESCENDANT_FROM_ROOT;
  +      case Axis.ROOT :
  +        return BIT_ROOT;
  +      case Axis.FILTEREDLIST :
  +        return BIT_FILTER;
  +      default :
  +        return BIT_FILTER;
  +    }
  +  }
  +
  +  /**
  +   * Tell if the given axis goes downword.  Bogus name, if you can think of 
  +   * a better one, please do tell.  This really has to do with inverting 
  +   * attribute axis.
  +   * @param axis One of Axis.XXX.
  +   * @return true if the axis is not a child axis and does not go up from 
  +   * the axis root.
  +   */
  +  public static boolean isDownwardAxisOfMany(int axis)
  +  {
  +    return (
  +      (Axis.DESCENDANTORSELF == axis)
  +      || (Axis.DESCENDANT == axis)
  +      || (Axis.FOLLOWING == axis)
  +    //          || (Axis.FOLLOWINGSIBLING == axis) 
  +    || (Axis.PRECEDING == axis)
  +    //          || (Axis.PRECEDINGSIBLING == axis)
  +    );
  +  }
  +
  +  /**
  +   * First 8 bits are the number of top-level location steps.  Hopefully
  +   *  there will never be more that 255 location steps!!!
  +   */
  +  public static final int BITS_COUNT = 0x000000FF;
  +
  +  /** 4 bits are reserved for future use. */
  +  public static final int BITS_RESERVED = 0x00000F00;
  +
  +  /** Bit is on if the expression contains a top-level predicate. */
  +  public static final int BIT_PREDICATE = (0x00001000);
  +
  +  /** Bit is on if any of the walkers contain an ancestor step. */
  +  public static final int BIT_ANCESTOR = (0x00001000 << 1);
  +
  +  /** Bit is on if any of the walkers contain an ancestor-or-self step. */
  +  public static final int BIT_ANCESTOR_OR_SELF = (0x00001000 << 2);
  +
  +  /** Bit is on if any of the walkers contain an attribute step. */
  +  public static final int BIT_ATTRIBUTE = (0x00001000 << 3);
  +
  +  /** Bit is on if any of the walkers contain a child step. */
  +  public static final int BIT_CHILD = (0x00001000 << 4);
  +
  +  /** Bit is on if any of the walkers contain a descendant step. */
  +  public static final int BIT_DESCENDANT = (0x00001000 << 5);
  +
  +  /** Bit is on if any of the walkers contain a descendant-or-self step. */
  +  public static final int BIT_DESCENDANT_OR_SELF = (0x00001000 << 6);
  +
  +  /** Bit is on if any of the walkers contain a following step. */
  +  public static final int BIT_FOLLOWING = (0x00001000 << 7);
  +
  +  /** Bit is on if any of the walkers contain a following-sibiling step. */
  +  public static final int BIT_FOLLOWING_SIBLING = (0x00001000 << 8);
  +
  +  /** Bit is on if any of the walkers contain a namespace step. */
  +  public static final int BIT_NAMESPACE = (0x00001000 << 9);
  +
  +  /** Bit is on if any of the walkers contain a parent step. */
  +  public static final int BIT_PARENT = (0x00001000 << 10);
  +
  +  /** Bit is on if any of the walkers contain a preceding step. */
  +  public static final int BIT_PRECEDING = (0x00001000 << 11);
  +
  +  /** Bit is on if any of the walkers contain a preceding-sibling step. */
  +  public static final int BIT_PRECEDING_SIBLING = (0x00001000 << 12);
  +
  +  /** Bit is on if any of the walkers contain a self step. */
  +  public static final int BIT_SELF = (0x00001000 << 13);
  +
  +  /**
  +   * Bit is on if any of the walkers contain a filter (i.e. id(), extension
  +   *  function, etc.) step.
  +   */
  +  public static final int BIT_FILTER = (0x00001000 << 14);
  +
  +  /** Bit is on if any of the walkers contain a root step. */
  +  public static final int BIT_ROOT = (0x00001000 << 15);
  +
  +  /**
  +   * If any of these bits are on, the expression may likely traverse outside
  +   *  the given subtree.
  +   */
  +    public static final int BITMASK_TRAVERSES_OUTSIDE_SUBTREE =
  +      (BIT_NAMESPACE // ??
  +    | BIT_PRECEDING_SIBLING
  +    | BIT_PRECEDING
  +    | BIT_FOLLOWING_SIBLING
  +    | BIT_FOLLOWING
  +    | BIT_PARENT // except parent of attrs.
  +  | BIT_ANCESTOR_OR_SELF | BIT_ANCESTOR | BIT_FILTER | BIT_ROOT);
  +
  +  /**
  +   * Bit is on if any of the walkers can go backwards in document
  +   *  order from the context node.
  +   */
  +  public static final int BIT_BACKWARDS_SELF = (0x00001000 << 16);
  +
  +  /** Found "//foo" pattern */
  +  public static final int BIT_ANY_DESCENDANT_FROM_ROOT = (0x00001000 << 17);
  +
  +  /**
  +   * Bit is on if any of the walkers contain an node() test.  This is
  +   *  really only useful if the count is 1.
  +   */
  +  public static final int BIT_NODETEST_ANY = (0x00001000 << 18);
  +
  +  // can't go higher than 18!
  +
  +  /** Bit is on if the expression is a match pattern. */
  +  public static final int BIT_MATCH_PATTERN = (0x00001000 << 19);
  +
  +  /**
  +   * Analyze a step and give information about it's predicates.  Right now this
  +   * just returns true or false if the step has a predicate.
      *
  -   * @param lpi The owning location path iterator.
      * @param compiler non-null reference to compiler object that has processed
      *                 the XPath operations into an opcode map.
  -   * @param stepOpCodePos The opcode position for the step.
  +   * @param opPos The opcode position for the step.
  +   * @param stepType The type of step, one of OP_GROUP, etc.
      *
  -   * @return non-null AxesWalker derivative.
  +   * @return true if step has a predicate.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  static AxesWalker loadOneWalker(
  -          WalkingIterator lpi, Compiler compiler, int stepOpCodePos)
  -            throws javax.xml.transform.TransformerException
  +  static boolean analyzePredicate(StepExpr stepExpr)
  +    throws javax.xml.transform.TransformerException
     {
   
  -    AxesWalker firstWalker = null;
  -    int stepType = compiler.getOpMap()[stepOpCodePos];
  -
  -    if (stepType != OpCodes.ENDOP)
  +    int childCount = stepExpr.jjtGetNumChildren();
  +    Node lastChild = stepExpr.jjtGetChild(childCount - 1);
  +    if (lastChild instanceof Predicates)
       {
  -
  -      // m_axesWalkers = new AxesWalker[1];
  -      // As we unwind from the recursion, create the iterators.
  -      firstWalker = createDefaultWalker(compiler, stepType, lpi, 0);
  -
  -      firstWalker.init(compiler, stepOpCodePos, stepType);
  +      if (lastChild.jjtGetNumChildren() > 0)
  +      {
  +        return true;
  +      }
       }
  -
  -    return firstWalker;
  +    return false;
     }
   
     /**
  -   * <meta name="usage" content="advanced"/>
  -   * This method is for building an array of possible levels
  -   * where the target element(s) could be found for a match.
  -   * @param xpath The xpath that is executing.
  -   * @param context The current source tree context node.
  +   * Analyze the location path and return 32 bits that give information about
  +   * the location path as a whole.  See the BIT_XXX constants for meaning about
  +   * each of the bits.
      *
  -   * @param lpi The owning location path iterator object.
      * @param compiler non-null reference to compiler object that has processed
      *                 the XPath operations into an opcode map.
      * @param stepOpCodePos The opcode position for the step.
      * @param stepIndex The top-level step index withing the iterator.
      *
  -   * @return non-null AxesWalker derivative.
  +   * @return 32 bits as an integer that give information about the location
  +   * path as a whole.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  static AxesWalker loadWalkers(
  -          WalkingIterator lpi, Compiler compiler, int stepOpCodePos, int stepIndex)
  -            throws javax.xml.transform.TransformerException
  +  private static int analyze(PathExpr pathExpr, int stepIndex)
  +    throws javax.xml.transform.TransformerException
     {
  +    int numSteps = pathExpr.jjtGetNumChildren();
  +    int analysisResult = 0x00000000; // 32 bits of analysis
   
  -    int stepType;
  -    AxesWalker firstWalker = null;
  -    AxesWalker walker, prevWalker = null;
  -    int ops[] = compiler.getOpMap();
  -    int analysis = analyze(compiler, stepOpCodePos, stepIndex);
  -
  -    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  +    for (int i = stepIndex; i < numSteps; i++)
       {
  -      walker = createDefaultWalker(compiler, stepOpCodePos, lpi, analysis);
  +      StepExpr stepExpr = (StepExpr) pathExpr.jjtGetChild(i);
   
  -      walker.init(compiler, stepOpCodePos, stepType);
  -      walker.exprSetParent(lpi);
  +      boolean predAnalysis = analyzePredicate(stepExpr);
   
  -      // walker.setAnalysis(analysis);
  -      if (null == firstWalker)
  +      if (predAnalysis)
  +        analysisResult |= BIT_PREDICATE;
  +
  +      Node firstChild = stepExpr.jjtGetChild(0);
  +      if (firstChild instanceof PatternAxis)
         {
  -        firstWalker = walker;
  +        int axis = ((PatternAxis) firstChild).getAxis();
  +        switch (axis)
  +        {
  +          case Axis.ROOT :
  +            analysisResult |= BIT_ROOT;
  +            break;
  +          case Axis.DESCENDANTSORSELFFROMROOT :
  +          case Axis.DESCENDANTSFROMROOT :
  +            analysisResult |= (BIT_ROOT | BIT_ANY_DESCENDANT_FROM_ROOT);
  +            break;
  +          case Axis.ANCESTOR :
  +            analysisResult |= BIT_ANCESTOR;
  +            break;
  +          case Axis.ANCESTORORSELF :
  +            analysisResult |= BIT_ANCESTOR_OR_SELF;
  +            break;
  +          case Axis.ATTRIBUTE :
  +            analysisResult |= BIT_ATTRIBUTE;
  +            break;
  +          case Axis.NAMESPACE :
  +            analysisResult |= BIT_NAMESPACE;
  +            break;
  +          case Axis.CHILD :
  +            analysisResult |= BIT_CHILD;
  +            break;
  +          case Axis.DESCENDANT :
  +            analysisResult |= BIT_DESCENDANT;
  +            break;
  +          case Axis.DESCENDANTORSELF :
  +            analysisResult |= BIT_DESCENDANT_OR_SELF;
  +            break;
  +          case Axis.FOLLOWING :
  +            analysisResult |= BIT_FOLLOWING;
  +            break;
  +          case Axis.FOLLOWINGSIBLING :
  +            analysisResult |= BIT_FOLLOWING_SIBLING;
  +            break;
  +          case Axis.PRECEDING :
  +            analysisResult |= BIT_PRECEDING;
  +            break;
  +          case Axis.PRECEDINGSIBLING :
  +            analysisResult |= BIT_PRECEDING_SIBLING;
  +            break;
  +          case Axis.PARENT :
  +            analysisResult |= BIT_PARENT;
  +            break;
  +          case Axis.SELF :
  +            analysisResult |= BIT_SELF;
  +            break;
  +          default :
  +            // TBD: Change the wording of this expression.
  +            throw new RuntimeException(
  +              XSLMessages.createXPATHMessage(
  +                XPATHErrorResources.ER_NULL_ERROR_HANDLER,
  +                new Object[] { firstChild.getClass().getName()}));
  +            //"Programmer's assertion: unknown opcode: "
  +            //+ stepType);
  +        }
  +        Node secondChild = stepExpr.jjtGetChild(1);
  +        if (secondChild instanceof org.apache.xpath.parser.NodeTest)
  +        {
  +          org.apache.xpath.parser.NodeTest nt =
  +            (org.apache.xpath.parser.NodeTest) secondChild;
  +          if (nt.getWhatToShow() == org.apache.xml.dtm.DTMFilter.SHOW_ALL)
  +          {
  +            analysisResult |= BIT_NODETEST_ANY;
  +          }
  +        }
  +
         }
         else
         {
  -        prevWalker.setNextWalker(walker);
  -        walker.setPrevWalker(prevWalker);
  +        analysisResult |= BIT_FILTER;
         }
   
  -      prevWalker = walker;
  -      stepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  -
  -      if (stepOpCodePos < 0)
  -        break;
       }
   
  -    return firstWalker;
  -  }
  -  
  -  public static boolean isSet(int analysis, int bits)
  -  {
  -    return (0 != (analysis & bits));
  -  }
  -  
  -  public static void diagnoseIterator(String name, int analysis, Compiler compiler)
  -  {
  -    System.out.println(compiler.toString()+", "+name+", "
  -                             + Integer.toBinaryString(analysis) + ", "
  -                             + getAnalysisString(analysis));
  +    analysisResult |= (numSteps & BITS_COUNT);
  +
  +    return analysisResult;
     }
   
     /**
  @@ -198,81 +404,92 @@
      * @throws javax.xml.transform.TransformerException
      */
     public static DTMIterator newDTMIterator(
  -          Compiler compiler, int opPos,
  -          boolean isTopLevel)
  -            throws javax.xml.transform.TransformerException
  +    PathExpr pathExpr,
  +    boolean isTopLevel)
  +    throws javax.xml.transform.TransformerException
     {
   
  -    int firstStepPos = compiler.getFirstChildPos(opPos);
  -    int analysis = analyze(compiler, firstStepPos, 0);
  +    int analysis = analyze(pathExpr, 0);
       boolean isOneStep = isOneStep(analysis);
  -    DTMIterator iter;
  -
  +    DTMIterator iter = getPossibleUnion(pathExpr, isTopLevel, isOneStep);
  +    
  +    if(null != iter)
  +      return iter;
  +    
       // Is the iteration a one-step attribute pattern (i.e. select="@foo")?
  -    if (isOneStep && walksSelfOnly(analysis) && 
  -        isWild(analysis) && !hasPredicate(analysis))
  +    if (isOneStep
  +      && walksSelfOnly(analysis)
  +      && isWild(analysis)
  +      && !hasPredicate(analysis))
       {
         if (DEBUG_ITERATOR_CREATION)
  -        diagnoseIterator("SelfIteratorNoPredicate", analysis, compiler);
  +        diagnoseIterator("SelfIteratorNoPredicate", analysis, pathExpr);
   
         // Then use a simple iteration of the attributes, with node test 
         // and predicate testing.
  -      iter = new SelfIteratorNoPredicate(compiler, opPos, analysis);
  +      iter = new SelfIteratorNoPredicate();
       }
       // Is the iteration exactly one child step?
  -    else if (walksChildrenOnly(analysis) && isOneStep)
  -    {
  -
  -      // Does the pattern specify *any* child with no predicate? (i.e. select="child::node()".
  -      if (isWild(analysis) && !hasPredicate(analysis))
  +    else
  +      if (walksChildrenOnly(analysis) && isOneStep)
         {
  -        if (DEBUG_ITERATOR_CREATION)
  -          diagnoseIterator("ChildIterator", analysis, compiler);
   
  -        // Use simple child iteration without any test.
  -        iter = new ChildIterator(compiler, opPos, analysis);
  -      }
  -      else
  -      {
  -        if (DEBUG_ITERATOR_CREATION)
  -          diagnoseIterator("ChildTestIterator", analysis, compiler);
  +        // Does the pattern specify *any* child with no predicate? (i.e. select="child::node()".
  +        if (isWild(analysis) && !hasPredicate(analysis))
  +        {
  +          if (DEBUG_ITERATOR_CREATION)
  +            diagnoseIterator("ChildIterator", analysis, pathExpr);
  +
  +          // Use simple child iteration without any test.
  +          StepExpr stepExpr = (StepExpr) pathExpr.jjtGetChild(0);
  +          iter = new ChildIterator(stepExpr, analysis);
  +        }
  +        else
  +        {
  +          if (DEBUG_ITERATOR_CREATION)
  +            diagnoseIterator("ChildTestIterator", analysis, pathExpr);
   
  -        // Else use simple node test iteration with predicate test.
  -        iter = new ChildTestIterator(compiler, opPos, analysis);
  +          // Else use simple node test iteration with predicate test.
  +          StepExpr stepExpr = (StepExpr) pathExpr.jjtGetChild(0);
  +          iter = new ChildTestIterator(stepExpr, analysis);
  +        }
         }
  -    }
       // Is the iteration a one-step attribute pattern (i.e. select="@foo")?
  -    else if (isOneStep && walksAttributes(analysis))
  -    {
  -      if (DEBUG_ITERATOR_CREATION)
  -        diagnoseIterator("AttributeIterator", analysis, compiler);
  -
  -      // Then use a simple iteration of the attributes, with node test 
  -      // and predicate testing.
  -      iter = new AttributeIterator(compiler, opPos, analysis);
  -    }
  -    else if(isOneStep && !walksFilteredList(analysis))
  -    {
  -      if( !walksNamespaces(analysis) 
  -      && (walksInDocOrder(analysis) || isSet(analysis, BIT_PARENT)))
  +    else
  +      if (isOneStep && walksAttributes(analysis))
         {
  -        if (false || DEBUG_ITERATOR_CREATION)
  -          diagnoseIterator("OneStepIteratorForward", analysis, compiler);
  -  
  +        if (DEBUG_ITERATOR_CREATION)
  +          diagnoseIterator("AttributeIterator", analysis, pathExpr);
  +
           // Then use a simple iteration of the attributes, with node test 
           // and predicate testing.
  -        iter = new OneStepIteratorForward(compiler, opPos, analysis);
  +        StepExpr stepExpr = (StepExpr) pathExpr.jjtGetChild(0);
  +        iter = new AttributeIterator(stepExpr, analysis);
         }
         else
  -      {
  -        if (false || DEBUG_ITERATOR_CREATION)
  -          diagnoseIterator("OneStepIterator", analysis, compiler);
  -  
  -        // Then use a simple iteration of the attributes, with node test 
  -        // and predicate testing.
  -        iter = new OneStepIterator(compiler, opPos, analysis);
  -      }
  -    }
  +        if (isOneStep && !walksFilteredList(analysis))
  +        {
  +          StepExpr stepExpr = (StepExpr) pathExpr.jjtGetChild(0);
  +          if (!walksNamespaces(analysis)
  +            && (walksInDocOrder(analysis) || isSet(analysis, BIT_PARENT)))
  +          {
  +            if (false || DEBUG_ITERATOR_CREATION)
  +              diagnoseIterator("OneStepIteratorForward", analysis, pathExpr);
  +
  +            // Then use a simple iteration of the attributes, with node test 
  +            // and predicate testing.
  +            iter = new OneStepIteratorForward(stepExpr, analysis);
  +          }
  +          else
  +          {
  +            if (false || DEBUG_ITERATOR_CREATION)
  +              diagnoseIterator("OneStepIterator", analysis, pathExpr);
  +
  +            // Then use a simple iteration of the attributes, with node test 
  +            // and predicate testing.
  +            iter = new OneStepIterator(stepExpr, analysis);
  +          }
  +        }
   
       // Analysis of "//center":
       // bits: 1001000000001010000000000000011
  @@ -286,915 +503,777 @@
       // "//table[3]", because this has to be analyzed as 
       // "/descendant-or-self::node()/table[3]" in order for the indexes 
       // to work right.
  -    else if (isOptimizableForDescendantIterator(compiler, firstStepPos, 0)
  -              // && getStepCount(analysis) <= 3 
  -              // && walksDescendants(analysis) 
  -              // && walksSubtreeOnlyFromRootOrContext(analysis)
  -             )
  -    {
  -      if (DEBUG_ITERATOR_CREATION)
  -        diagnoseIterator("DescendantIterator", analysis, compiler);
  -
  -      iter = new DescendantIterator(compiler, opPos, analysis);
  -    }
       else
  -    { 
  -      if(isNaturalDocOrder(compiler, firstStepPos, 0, analysis))
  +      if (isOptimizableForDescendantIterator(pathExpr,
  +        0) // && getStepCount(analysis) <= 3 
  +      // && walksDescendants(analysis) 
  +      // && walksSubtreeOnlyFromRootOrContext(analysis)
  +      )
         {
  -        if (false || DEBUG_ITERATOR_CREATION)
  +        if (DEBUG_ITERATOR_CREATION)
  +          diagnoseIterator("DescendantIterator", analysis, pathExpr);
  +        StepExpr stepExpr;
  +        if (pathExpr.jjtGetNumChildren() == 2)
           {
  -          diagnoseIterator("WalkingIterator", analysis, compiler);
  +          stepExpr = (StepExpr) pathExpr.jjtGetChild(1);
  +          PatternAxis axisExpr = stepExpr.getAxisExpr();
  +          axisExpr.setAxis(org.apache.xml.dtm.Axis.DESCENDANTSFROMROOT);
           }
  -  
  -        iter = new WalkingIterator(compiler, opPos, analysis, true);
  +        else
  +          stepExpr = (StepExpr) pathExpr.jjtGetChild(0);
  +        iter = new DescendantIterator(stepExpr);
         }
         else
         {
  -//        if (DEBUG_ITERATOR_CREATION)
  -//          diagnoseIterator("MatchPatternIterator", analysis, compiler);
  -//
  -//        return new MatchPatternIterator(compiler, opPos, analysis);
  -        if (DEBUG_ITERATOR_CREATION)
  -          diagnoseIterator("WalkingIteratorSorted", analysis, compiler);
  -
  -        iter = new WalkingIteratorSorted(compiler, opPos, analysis, true);
  +        if (isNaturalDocOrder(pathExpr, 0, analysis))
  +        {
  +          if (false || DEBUG_ITERATOR_CREATION)
  +          {
  +            diagnoseIterator("WalkingIterator", analysis, pathExpr);
  +          }
  +
  +          iter =
  +            new WalkingIterator(
  +              pathExpr.getParser().getPrefixResolver(),
  +              pathExpr);
  +        }
  +        else
  +        {
  +          //        if (DEBUG_ITERATOR_CREATION)
  +          //          diagnoseIterator("MatchPatternIterator", analysis, compiler);
  +          //
  +          //        return new MatchPatternIterator(compiler, opPos, analysis);
  +          if (DEBUG_ITERATOR_CREATION)
  +            diagnoseIterator("WalkingIteratorSorted", analysis, pathExpr);
  +
  +          iter =
  +            new WalkingIteratorSorted(
  +              pathExpr.getParser().getPrefixResolver(),
  +              pathExpr);
  +        }
         }
  -    }
  -    if(iter instanceof LocPathIterator)
  -      ((LocPathIterator)iter).setIsTopLevel(isTopLevel);
  -      
  +    if (iter instanceof LocPathIterator)
  +       ((LocPathIterator) iter).setIsTopLevel(isTopLevel);
  +
       return iter;
     }
  -  
  +
     /**
  -   * Special purpose function to see if we can optimize the pattern for 
  -   * a DescendantIterator.
  -   *
  -   * @param compiler non-null reference to compiler object that has processed
  -   *                 the XPath operations into an opcode map.
  -   * @param stepOpCodePos The opcode position for the step.
  -   * @param stepIndex The top-level step index withing the iterator.
  -   *
  -   * @return 32 bits as an integer that give information about the location
  -   * path as a whole.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * Check to see if we have a UnionPathIterator contained by a 
  +   * StepExpr and possibly a predicate, contained in a PathExpr.
  +   * If this is the case, we just want the UnionPathIterator and 
  +   * any predicates it may have.
  +   * It's likely that this reduction should be done somewhere else.
  +   * 
  +   * @param pathExpr The path construction node that holds the subtree.
  +   * @param isTopLevel True if this expression is at the top-level.
  +   * @param isOneStep True if this expression only has one step.
  +   * @return DTMIterator The reduced union iterator, or null if not a union.
  +   * @throws TransformerException
      */
  -  public static int getAxisFromStep(
  -          Compiler compiler, int stepOpCodePos)
  -            throws javax.xml.transform.TransformerException
  -  {
  -
  -    int ops[] = compiler.getOpMap();
  -    int stepType = ops[stepOpCodePos];
  -
  -    switch (stepType)
  -    {
  -    case OpCodes.FROM_FOLLOWING :
  -      return Axis.FOLLOWING;
  -    case OpCodes.FROM_FOLLOWING_SIBLINGS :
  -      return Axis.FOLLOWINGSIBLING;
  -    case OpCodes.FROM_PRECEDING :
  -      return Axis.PRECEDING;
  -    case OpCodes.FROM_PRECEDING_SIBLINGS :
  -      return Axis.PRECEDINGSIBLING;
  -    case OpCodes.FROM_PARENT :
  -      return Axis.PARENT;
  -    case OpCodes.FROM_NAMESPACE :
  -      return Axis.NAMESPACE;
  -    case OpCodes.FROM_ANCESTORS :
  -      return Axis.ANCESTOR;
  -    case OpCodes.FROM_ANCESTORS_OR_SELF :
  -      return Axis.ANCESTORORSELF;
  -    case OpCodes.FROM_ATTRIBUTES :
  -      return Axis.ATTRIBUTE;
  -    case OpCodes.FROM_ROOT :
  -      return Axis.ROOT;
  -    case OpCodes.FROM_CHILDREN :
  -      return Axis.CHILD;
  -    case OpCodes.FROM_DESCENDANTS_OR_SELF :
  -      return Axis.DESCENDANTORSELF;
  -    case OpCodes.FROM_DESCENDANTS :
  -      return Axis.DESCENDANT;
  -    case OpCodes.FROM_SELF :
  -      return Axis.SELF;
  -    case OpCodes.OP_EXTFUNCTION :
  -    case OpCodes.OP_FUNCTION :
  -    case OpCodes.OP_GROUP :
  -    case OpCodes.OP_VARIABLE :
  -      return Axis.FILTEREDLIST;
  -    }
  -
  -    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  -                               //+ stepType);
  -   }
  -    
  -    /**
  -     * Get a corresponding BIT_XXX from an axis.
  -     * @param axis One of Axis.ANCESTOR, etc.
  -     * @return One of BIT_ANCESTOR, etc.
  -     */
  -    static public int getAnalysisBitFromAxes(int axis)
  +  private static DTMIterator getPossibleUnion(
  +    PathExpr pathExpr,
  +    boolean isTopLevel,
  +    boolean isOneStep)
  +    throws TransformerException
  +  {
  +    Node n;
  +    if(isOneStep && 
  +      (n = pathExpr.jjtGetChild(0).jjtGetChild(0)) instanceof UnionPathIterator)
       {
  -      switch (axis) // Generate new traverser
  -        {
  -        case Axis.ANCESTOR :
  -          return BIT_ANCESTOR;
  -        case Axis.ANCESTORORSELF :
  -          return BIT_ANCESTOR_OR_SELF;
  -        case Axis.ATTRIBUTE :
  -          return BIT_ATTRIBUTE;
  -        case Axis.CHILD :
  -          return BIT_CHILD;
  -        case Axis.DESCENDANT :
  -          return BIT_DESCENDANT;
  -        case Axis.DESCENDANTORSELF :
  -          return BIT_DESCENDANT_OR_SELF;
  -        case Axis.FOLLOWING :
  -          return BIT_FOLLOWING;
  -        case Axis.FOLLOWINGSIBLING :
  -          return BIT_FOLLOWING_SIBLING;
  -        case Axis.NAMESPACE :
  -        case Axis.NAMESPACEDECLS :
  -          return BIT_NAMESPACE;
  -        case Axis.PARENT :
  -          return BIT_PARENT;
  -        case Axis.PRECEDING :
  -          return BIT_PRECEDING;
  -        case Axis.PRECEDINGSIBLING :
  -          return BIT_PRECEDING_SIBLING;
  -        case Axis.SELF :
  -          return BIT_SELF;
  -        case Axis.ALLFROMNODE :
  -          return BIT_DESCENDANT_OR_SELF;
  -          // case Axis.PRECEDINGANDANCESTOR :
  -        case Axis.DESCENDANTSFROMROOT :
  -        case Axis.ALL :
  -        case Axis.DESCENDANTSORSELFFROMROOT :
  -          return BIT_ANY_DESCENDANT_FROM_ROOT;
  -        case Axis.ROOT :
  -          return BIT_ROOT;
  -        case Axis.FILTEREDLIST :
  -          return BIT_FILTER;
  -        default :
  -          return BIT_FILTER;
  -      }
  +      UnionPathIterator upi = (UnionPathIterator)n;
  +      StepExpr se = (StepExpr)pathExpr.jjtGetChild(0);
  +      
  +      upi.initPredicateInfo(se);
  +      upi.setWhatToShow(DTMFilter.SHOW_ALL);
  +        
  +      upi.setIsTopLevel(isTopLevel);
  +      return upi;
       }
  -  
  -  static boolean functionProximateOrContainsProximate(Compiler compiler, 
  -                                                      int opPos)
  -  {
  -    int endFunc = opPos + compiler.getOp(opPos + 1) - 1;
  -    opPos = compiler.getFirstChildPos(opPos);
  -    int funcID = compiler.getOp(opPos);
  -    //  System.out.println("funcID: "+funcID);
  -    //  System.out.println("opPos: "+opPos);
  -    //  System.out.println("endFunc: "+endFunc);
  -    switch(funcID)
  -    {
  -      case FunctionTable.FUNC_LAST:
  -      case FunctionTable.FUNC_POSITION:
  -        return true;
  -      default:
  -        opPos++;
  -        int i = 0;
  -        for (int p = opPos; p < endFunc; p = compiler.getNextOpPos(p), i++)
  -        {
  -          int innerExprOpPos = p+2;
  -          int argOp = compiler.getOp(innerExprOpPos);
  -          boolean prox = isProximateInnerExpr(compiler, innerExprOpPos);
  -          if(prox)
  -            return true;
  -        }
  +    else
  +      return null;
  +  }
   
  -    }
  -    return false;
  +  public static void diagnoseIterator(
  +    String name,
  +    int analysis,
  +    PathExpr pathExpr)
  +  {
  +    System.out.println(
  +      pathExpr.toString()
  +        + ", "
  +        + name
  +        + ", "
  +        + Integer.toBinaryString(analysis)
  +        + ", "
  +        + getAnalysisString(analysis));
     }
  -  
  -  static boolean isProximateInnerExpr(Compiler compiler, int opPos)
  +
  +  public static String getAnalysisString(int analysis)
     {
  -    int op = compiler.getOp(opPos);
  -    int innerExprOpPos = opPos+2;
  -    switch(op)
  +    StringBuffer buf = new StringBuffer();
  +    buf.append("count: " + getStepCount(analysis) + " ");
  +    if ((analysis & BIT_NODETEST_ANY) != 0)
       {
  -      case OpCodes.OP_ARGUMENT:
  -        if(isProximateInnerExpr(compiler, innerExprOpPos))
  -          return true;
  -        break;
  -      case OpCodes.OP_VARIABLE:
  -      case OpCodes.OP_NUMBERLIT:
  -      case OpCodes.OP_LITERAL:
  -      case OpCodes.OP_LOCATIONPATH:
  -        break; // OK
  -      case OpCodes.OP_FUNCTION:
  -        boolean isProx = functionProximateOrContainsProximate(compiler, opPos);
  -        if(isProx)
  -          return true;
  -        break;
  -      case OpCodes.OP_GT:
  -      case OpCodes.OP_GTE:
  -      case OpCodes.OP_LT:
  -      case OpCodes.OP_LTE:
  -      case OpCodes.OP_EQUALS:
  -        int leftPos = compiler.getFirstChildPos(op);
  -        int rightPos = compiler.getNextOpPos(leftPos);
  -        isProx = isProximateInnerExpr(compiler, leftPos);
  -        if(isProx)
  -          return true;
  -        isProx = isProximateInnerExpr(compiler, rightPos);
  -        if(isProx)
  -          return true;
  -        break;
  -      default:
  -        return true; // be conservative...
  +      buf.append("NTANY|");
       }
  -    return false;
  -  }
  -    
  -  /**
  -   * Tell if the predicates need to have proximity knowledge.
  -   */
  -  public static boolean mightBeProximate(Compiler compiler, int opPos, int stepType)
  -          throws javax.xml.transform.TransformerException
  -  {
  -
  -    boolean mightBeProximate = false;
  -    int argLen;
  -
  -    switch (stepType)
  +    if ((analysis & BIT_PREDICATE) != 0)
  +    {
  +      buf.append("PRED|");
  +    }
  +    if ((analysis & BIT_ANCESTOR) != 0)
  +    {
  +      buf.append("ANC|");
  +    }
  +    if ((analysis & BIT_ANCESTOR_OR_SELF) != 0)
  +    {
  +      buf.append("ANCOS|");
  +    }
  +    if ((analysis & BIT_ATTRIBUTE) != 0)
  +    {
  +      buf.append("ATTR|");
  +    }
  +    if ((analysis & BIT_CHILD) != 0)
  +    {
  +      buf.append("CH|");
  +    }
  +    if ((analysis & BIT_DESCENDANT) != 0)
  +    {
  +      buf.append("DESC|");
  +    }
  +    if ((analysis & BIT_DESCENDANT_OR_SELF) != 0)
  +    {
  +      buf.append("DESCOS|");
  +    }
  +    if ((analysis & BIT_FOLLOWING) != 0)
  +    {
  +      buf.append("FOL|");
  +    }
  +    if ((analysis & BIT_FOLLOWING_SIBLING) != 0)
       {
  -    case OpCodes.OP_VARIABLE :
  -    case OpCodes.OP_EXTFUNCTION :
  -    case OpCodes.OP_FUNCTION :
  -    case OpCodes.OP_GROUP :
  -      argLen = compiler.getArgLength(opPos);
  -      break;
  -    default :
  -      argLen = compiler.getArgLengthOfStep(opPos);
  +      buf.append("FOLS|");
  +    }
  +    if ((analysis & BIT_NAMESPACE) != 0)
  +    {
  +      buf.append("NS|");
  +    }
  +    if ((analysis & BIT_PARENT) != 0)
  +    {
  +      buf.append("P|");
  +    }
  +    if ((analysis & BIT_PRECEDING) != 0)
  +    {
  +      buf.append("PREC|");
  +    }
  +    if ((analysis & BIT_PRECEDING_SIBLING) != 0)
  +    {
  +      buf.append("PRECS|");
  +    }
  +    if ((analysis & BIT_SELF) != 0)
  +    {
  +      buf.append(".|");
       }
  +    if ((analysis & BIT_FILTER) != 0)
  +    {
  +      buf.append("FLT|");
  +    }
  +    if ((analysis & BIT_ROOT) != 0)
  +    {
  +      buf.append("R|");
  +    }
  +    return buf.toString();
  +  }
   
  -    int predPos = compiler.getFirstPredicateOpPos(opPos);
  -    int count = 0;
  +  /** Set to true for diagnostics about walker creation */
  +  static final boolean DEBUG_PATTERN_CREATION = false;
   
  -    while (OpCodes.OP_PREDICATE == compiler.getOp(predPos))
  -    {
  -      count++;
  -      
  -      int innerExprOpPos = predPos+2;
  -      int predOp = compiler.getOp(innerExprOpPos);
  +  /** Set to true for diagnostics about walker creation */
  +  static final boolean DEBUG_WALKER_CREATION = false;
   
  -      switch(predOp)
  -      {
  -        case OpCodes.OP_VARIABLE:
  -        	return true; // Would need more smarts to tell if this could be a number or not!
  -        case OpCodes.OP_LOCATIONPATH:
  -          // OK.
  -          break;
  -        case OpCodes.OP_NUMBER:
  -        case OpCodes.OP_NUMBERLIT:
  -          return true; // that's all she wrote!
  -        case OpCodes.OP_FUNCTION:
  -          boolean isProx 
  -            = functionProximateOrContainsProximate(compiler, innerExprOpPos);
  -          if(isProx)
  -            return true;
  -          break;
  -        case OpCodes.OP_GT:
  -        case OpCodes.OP_GTE:
  -        case OpCodes.OP_LT:
  -        case OpCodes.OP_LTE:
  -        case OpCodes.OP_EQUALS:
  -          int leftPos = compiler.getFirstChildPos(innerExprOpPos);
  -          int rightPos = compiler.getNextOpPos(leftPos);
  -          isProx = isProximateInnerExpr(compiler, leftPos);
  -          if(isProx)
  -            return true;
  -          isProx = isProximateInnerExpr(compiler, rightPos);
  -          if(isProx)
  -            return true;
  -          break;
  -        default:
  -          return true; // be conservative...
  -      }
  +  /** Set to true for diagnostics about iterator creation */
  +  static final boolean DEBUG_ITERATOR_CREATION = false;
   
  -      predPos = compiler.getNextOpPos(predPos);
  -    }
  +  public static boolean hasPredicate(int analysis)
  +  {
  +    return (0 != (analysis & BIT_PREDICATE));
  +  }
   
  -    return mightBeProximate;
  +  public static boolean isWild(int analysis)
  +  {
  +    return (0 != (analysis & BIT_NODETEST_ANY));
     }
  -  
  -  /**
  -   * Special purpose function to see if we can optimize the pattern for 
  -   * a DescendantIterator.
  -   *
  -   * @param compiler non-null reference to compiler object that has processed
  -   *                 the XPath operations into an opcode map.
  -   * @param stepOpCodePos The opcode position for the step.
  -   * @param stepIndex The top-level step index withing the iterator.
  -   *
  -   * @return 32 bits as an integer that give information about the location
  -   * path as a whole.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  private static boolean isOptimizableForDescendantIterator(
  -          Compiler compiler, int stepOpCodePos, int stepIndex)
  -            throws javax.xml.transform.TransformerException
  +
  +  public static boolean walksAncestors(int analysis)
     {
  +    return isSet(analysis, BIT_ANCESTOR | BIT_ANCESTOR_OR_SELF);
  +  }
   
  -    int stepType;
  -    int ops[] = compiler.getOpMap();
  -    int stepCount = 0;
  -    boolean foundDorDS = false;
  -    boolean foundSelf = false;
  -    boolean foundDS = false;
  -    
  -    int nodeTestType = OpCodes.NODETYPE_NODE;
  -    
  -    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  -    {
  -      // The DescendantIterator can only do one node test.  If there's more 
  -      // than one, use another iterator.
  -      if(nodeTestType != OpCodes.NODETYPE_NODE && nodeTestType != OpCodes.NODETYPE_ROOT)
  -        return false;
  -        
  -      stepCount++;
  -      if(stepCount > 3)
  -        return false;
  -        
  -      boolean mightBeProximate = mightBeProximate(compiler, stepOpCodePos, stepType);
  -      if(mightBeProximate)
  -        return false;
  +  public static boolean walksAttributes(int analysis)
  +  {
  +    return (0 != (analysis & BIT_ATTRIBUTE));
  +  }
   
  -      switch (stepType)
  -      {
  -      case OpCodes.FROM_FOLLOWING :
  -      case OpCodes.FROM_FOLLOWING_SIBLINGS :
  -      case OpCodes.FROM_PRECEDING :
  -      case OpCodes.FROM_PRECEDING_SIBLINGS :
  -      case OpCodes.FROM_PARENT :
  -      case OpCodes.OP_VARIABLE :
  -      case OpCodes.OP_EXTFUNCTION :
  -      case OpCodes.OP_FUNCTION :
  -      case OpCodes.OP_GROUP :
  -      case OpCodes.FROM_NAMESPACE :
  -      case OpCodes.FROM_ANCESTORS :
  -      case OpCodes.FROM_ANCESTORS_OR_SELF :
  -      case OpCodes.FROM_ATTRIBUTES :
  -      case OpCodes.MATCH_ATTRIBUTE :
  -      case OpCodes.MATCH_ANY_ANCESTOR :
  -      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
  -        return false;
  -      case OpCodes.FROM_ROOT :
  -        if(1 != stepCount)
  -          return false;
  -        break;
  -      case OpCodes.FROM_CHILDREN :
  -        if(!foundDS && !(foundDorDS && foundSelf))
  -          return false;
  -        break;
  -      case OpCodes.FROM_DESCENDANTS_OR_SELF :
  -        foundDS = true;
  -      case OpCodes.FROM_DESCENDANTS :
  -        if(3 == stepCount)
  -          return false;
  -        foundDorDS = true;
  -        break;
  -      case OpCodes.FROM_SELF :
  -        if(1 != stepCount)
  -          return false;
  -        foundSelf = true;
  -        break;
  -      default :
  -        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  -                                  // + stepType);
  -      }
  -      
  -      nodeTestType = compiler.getStepTestType(stepOpCodePos);
  +  public static boolean walksNamespaces(int analysis)
  +  {
  +    return (0 != (analysis & BIT_NAMESPACE));
  +  }
   
  -      int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  +  public static boolean walksChildren(int analysis)
  +  {
  +    return (0 != (analysis & BIT_CHILD));
  +  }
   
  -      if (nextStepOpCodePos < 0)
  -        break;
  -        
  -      if(OpCodes.ENDOP != ops[nextStepOpCodePos])
  -      {
  -        if(compiler.countPredicates(stepOpCodePos) > 0)
  -        {
  -          return false;
  -        }
  -      }
  -      
  -      stepOpCodePos = nextStepOpCodePos;
  -    }
  +  public static boolean walksDescendants(int analysis)
  +  {
  +    return isSet(analysis, BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF | BIT_ANY_DESCENDANT_FROM_ROOT);
  +  }
   
  -    return true;
  +  public static boolean walksSubtree(int analysis)
  +  {
  +    return isSet(analysis, BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF | BIT_CHILD);
     }
   
  -  /**
  -   * Analyze the location path and return 32 bits that give information about
  -   * the location path as a whole.  See the BIT_XXX constants for meaning about
  -   * each of the bits.
  -   *
  -   * @param compiler non-null reference to compiler object that has processed
  -   *                 the XPath operations into an opcode map.
  -   * @param stepOpCodePos The opcode position for the step.
  -   * @param stepIndex The top-level step index withing the iterator.
  -   *
  -   * @return 32 bits as an integer that give information about the location
  -   * path as a whole.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  private static int analyze(
  -          Compiler compiler, int stepOpCodePos, int stepIndex)
  -            throws javax.xml.transform.TransformerException
  +  public static boolean walksSubtreeOnlyMaybeAbsolute(int analysis)
     {
  +    return walksSubtree(analysis)
  +      && !walksExtraNodes(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis);
  +  }
   
  -    int stepType;
  -    int ops[] = compiler.getOpMap();
  -    int stepCount = 0;
  -    int analysisResult = 0x00000000;  // 32 bits of analysis
  -
  -    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  -    {
  -      stepCount++;
  -
  -      // String namespace = compiler.getStepNS(stepOpCodePos);
  -      // boolean isNSWild = (null != namespace) 
  -      //                   ? namespace.equals(NodeTest.WILD) : false;
  -      // String localname = compiler.getStepLocalName(stepOpCodePos);
  -      // boolean isWild = (null != localname) ? localname.equals(NodeTest.WILD) : false;
  -      boolean predAnalysis = analyzePredicate(compiler, stepOpCodePos,
  -                                              stepType);
  +  public static boolean walksSubtreeOnly(int analysis)
  +  {
  +    return walksSubtreeOnlyMaybeAbsolute(analysis) && !isAbsolute(analysis);
  +  }
   
  -      if (predAnalysis)
  -        analysisResult |= BIT_PREDICATE;
  +  public static boolean walksFilteredList(int analysis)
  +  {
  +    return isSet(analysis, BIT_FILTER);
  +  }
   
  -      switch (stepType)
  -      {
  -      case OpCodes.OP_VARIABLE :
  -      case OpCodes.OP_EXTFUNCTION :
  -      case OpCodes.OP_FUNCTION :
  -      case OpCodes.OP_GROUP :
  -        analysisResult |= BIT_FILTER;
  -        break;
  -      case OpCodes.FROM_ROOT :
  -        analysisResult |= BIT_ROOT;
  -        break;
  -      case OpCodes.FROM_ANCESTORS :
  -        analysisResult |= BIT_ANCESTOR;
  -        break;
  -      case OpCodes.FROM_ANCESTORS_OR_SELF :
  -        analysisResult |= BIT_ANCESTOR_OR_SELF;
  -        break;
  -      case OpCodes.FROM_ATTRIBUTES :
  -        analysisResult |= BIT_ATTRIBUTE;
  -        break;
  -      case OpCodes.FROM_NAMESPACE :
  -        analysisResult |= BIT_NAMESPACE;
  -        break;
  -      case OpCodes.FROM_CHILDREN :
  -        analysisResult |= BIT_CHILD;
  -        break;
  -      case OpCodes.FROM_DESCENDANTS :
  -        analysisResult |= BIT_DESCENDANT;
  -        break;
  -      case OpCodes.FROM_DESCENDANTS_OR_SELF :
  +  public static boolean walksSubtreeOnlyFromRootOrContext(int analysis)
  +  {
  +    return walksSubtree(analysis)
  +      && !walksExtraNodes(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && !isSet(analysis, BIT_FILTER);
  +  }
   
  -        // Use a special bit to to make sure we get the right analysis of "//foo".
  -        if (2 == stepCount && BIT_ROOT == analysisResult)
  -        {
  -          analysisResult |= BIT_ANY_DESCENDANT_FROM_ROOT;
  -        }
  +  public static boolean walksInDocOrder(int analysis)
  +  {
  +    return (
  +      walksSubtreeOnlyMaybeAbsolute(analysis)
  +        || walksExtraNodesOnly(analysis)
  +        || walksFollowingOnlyMaybeAbsolute(analysis))
  +      && !isSet(analysis, BIT_FILTER);
  +  }
   
  -        analysisResult |= BIT_DESCENDANT_OR_SELF;
  -        break;
  -      case OpCodes.FROM_FOLLOWING :
  -        analysisResult |= BIT_FOLLOWING;
  -        break;
  -      case OpCodes.FROM_FOLLOWING_SIBLINGS :
  -        analysisResult |= BIT_FOLLOWING_SIBLING;
  -        break;
  -      case OpCodes.FROM_PRECEDING :
  -        analysisResult |= BIT_PRECEDING;
  -        break;
  -      case OpCodes.FROM_PRECEDING_SIBLINGS :
  -        analysisResult |= BIT_PRECEDING_SIBLING;
  -        break;
  -      case OpCodes.FROM_PARENT :
  -        analysisResult |= BIT_PARENT;
  -        break;
  -      case OpCodes.FROM_SELF :
  -        analysisResult |= BIT_SELF;
  -        break;
  -      case OpCodes.MATCH_ATTRIBUTE :
  -        analysisResult |= (BIT_MATCH_PATTERN | BIT_ATTRIBUTE);
  -        break;
  -      case OpCodes.MATCH_ANY_ANCESTOR :
  -        analysisResult |= (BIT_MATCH_PATTERN | BIT_ANCESTOR);
  -        break;
  -      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
  -        analysisResult |= (BIT_MATCH_PATTERN | BIT_PARENT);
  -        break;
  -      default :
  -        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  -                                   //+ stepType);
  -      }
  +  public static boolean walksFollowingOnlyMaybeAbsolute(int analysis)
  +  {
  +    return isSet(analysis, BIT_SELF | BIT_FOLLOWING_SIBLING | BIT_FOLLOWING)
  +      && !walksSubtree(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis);
  +  }
   
  -      if (OpCodes.NODETYPE_NODE == ops[stepOpCodePos + 3])  // child::node()
  -      {
  -        analysisResult |= BIT_NODETEST_ANY;
  -      }
  +  public static boolean walksUp(int analysis)
  +  {
  +    return isSet(analysis, BIT_PARENT | BIT_ANCESTOR | BIT_ANCESTOR_OR_SELF);
  +  }
   
  -      stepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  +  public static boolean walksSideways(int analysis)
  +  {
  +    return isSet(
  +      analysis,
  +      BIT_FOLLOWING
  +        | BIT_FOLLOWING_SIBLING
  +        | BIT_PRECEDING
  +        | BIT_PRECEDING_SIBLING);
  +  }
   
  -      if (stepOpCodePos < 0)
  -        break;
  -    }
  +  public static boolean walksExtraNodes(int analysis)
  +  {
  +    return isSet(analysis, BIT_NAMESPACE | BIT_ATTRIBUTE);
  +  }
   
  -    analysisResult |= (stepCount & BITS_COUNT);
  +  public static boolean walksExtraNodesOnly(int analysis)
  +  {
  +    return walksExtraNodes(analysis)
  +      && !isSet(analysis, BIT_SELF)
  +      && !walksSubtree(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && !isAbsolute(analysis);
  +  }
   
  -    return analysisResult;
  +  public static boolean isAbsolute(int analysis)
  +  {
  +    return isSet(analysis, BIT_ROOT | BIT_FILTER);
     }
  -  
  -  /**
  -   * Tell if the given axis goes downword.  Bogus name, if you can think of 
  -   * a better one, please do tell.  This really has to do with inverting 
  -   * attribute axis.
  -   * @param axis One of Axis.XXX.
  -   * @return true if the axis is not a child axis and does not go up from 
  -   * the axis root.
  -   */
  -  public static boolean isDownwardAxisOfMany(int axis)
  +
  +  public static boolean walksChildrenOnly(int analysis)
     {
  -    return ((Axis.DESCENDANTORSELF == axis) ||
  -          (Axis.DESCENDANT == axis) 
  -          || (Axis.FOLLOWING == axis) 
  -//          || (Axis.FOLLOWINGSIBLING == axis) 
  -          || (Axis.PRECEDING == axis) 
  -//          || (Axis.PRECEDINGSIBLING == axis)
  -          );
  +    return walksChildren(analysis)
  +      && !isSet(analysis, BIT_SELF)
  +      && !walksExtraNodes(analysis)
  +      && !walksDescendants(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT));
  +  }
  +
  +  public static boolean walksChildrenAndExtraAndSelfOnly(int analysis)
  +  {
  +    return walksChildren(analysis)
  +      && !walksDescendants(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT));
  +  }
  +
  +  public static boolean walksDescendantsAndExtraAndSelfOnly(int analysis)
  +  {
  +    return !walksChildren(analysis)
  +      && walksDescendants(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT));
  +  }
  +
  +  public static boolean walksSelfOnly(int analysis)
  +  {
  +    return isSet(analysis, BIT_SELF)
  +      && !walksSubtree(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && !isAbsolute(analysis);
  +  }
  +
  +  public static boolean walksUpOnly(int analysis)
  +  {
  +    return !walksSubtree(analysis)
  +      && walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && !isAbsolute(analysis);
  +  }
  +
  +  public static boolean walksDownOnly(int analysis)
  +  {
  +    return walksSubtree(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && !isAbsolute(analysis);
  +  }
  +
  +  public static boolean walksDownExtraOnly(int analysis)
  +  {
  +    return walksSubtree(analysis)
  +      && walksExtraNodes(analysis)
  +      && !walksUp(analysis)
  +      && !walksSideways(analysis)
  +      && !isAbsolute(analysis);
  +  }
  +
  +  public static boolean canSkipSubtrees(int analysis)
  +  {
  +    return isSet(analysis, BIT_CHILD) | walksSideways(analysis);
  +  }
  +
  +  public static boolean canCrissCross(int analysis)
  +  {
  +    // This could be done faster.  Coded for clarity.
  +    if (walksSelfOnly(analysis))
  +      return false;
  +    else
  +      if (walksDownOnly(analysis) && !canSkipSubtrees(analysis))
  +        return false;
  +      else
  +        if (walksChildrenAndExtraAndSelfOnly(analysis))
  +          return false;
  +        else
  +          if (walksDescendantsAndExtraAndSelfOnly(analysis))
  +            return false;
  +          else
  +            if (walksUpOnly(analysis))
  +              return false;
  +            else
  +              if (walksExtraNodesOnly(analysis))
  +                return false;
  +              else
  +                if (walksSubtree(analysis)
  +                  && (walksSideways(analysis)
  +                    || walksUp(analysis)
  +                    || canSkipSubtrees(analysis)))
  +                  return true;
  +                else
  +                  return false;
  +  }
  +
  +  /**
  +   * Tell if the pattern can be 'walked' with the iteration steps in natural 
  +   * document order, without duplicates.
  +   *
  +   * @param analysis The general analysis of the pattern.
  +   *
  +   * @return true if the walk can be done in natural order.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  static public boolean isNaturalDocOrder(int analysis)
  +  {
  +    if (canCrissCross(analysis)
  +      || isSet(analysis, BIT_NAMESPACE)
  +      || walksFilteredList(analysis))
  +      return false;
  +
  +    if (walksInDocOrder(analysis))
  +      return true;
  +
  +    return false;
  +  }
  +
  +  public static boolean isOneStep(int analysis)
  +  {
  +    return (analysis & BITS_COUNT) == 0x00000001;
  +  }
  +
  +  public static int getStepCount(int analysis)
  +  {
  +    return (analysis & BITS_COUNT);
     }
   
     /**
  -   * Read a <a href="http://www.w3.org/TR/xpath#location-paths">LocationPath</a>
  -   * as a generalized match pattern.  What this means is that the LocationPath
  -   * is read backwards, as a test on a given node, to see if it matches the
  -   * criteria of the selection, and ends up at the context node.  Essentially,
  -   * this is a backwards query from a given node, to find the context node.
  -   * <p>So, the selection "foo/daz[2]" is, in non-abreviated expanded syntax,
  -   * "self::node()/following-sibling::foo/child::daz[position()=2]".
  -   * Taking this as a match pattern for a probable node, it works out to
  -   * "self::daz/parent::foo[child::daz[position()=2 and isPrevStepNode()]
  -   * precedingSibling::node()[isContextNodeOfLocationPath()]", adding magic
  -   * isPrevStepNode and isContextNodeOfLocationPath operations.  Predicates in
  -   * the location path have to be executed by the following step,
  -   * because they have to know the context of their execution.
  -   *
  -   * @param mpi The MatchPatternIterator to which the steps will be attached.
  -   * @param compiler The compiler that holds the syntax tree/op map to
  -   * construct from.
  -   * @param stepOpCodePos The current op code position within the opmap.
  +   * Tell if the pattern can be 'walked' with the iteration steps in natural 
  +   * document order, without duplicates.
  +   *
  +   * @param pathExpr Root of the path expression being analyzed.
      * @param stepIndex The top-level step index withing the iterator.
  +   * @param analysis The general analysis of the pattern.
      *
  -   * @return A StepPattern object, which may contain relative StepPatterns.
  +   * @return true if the walk can be done in natural order.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  static StepPattern loadSteps(
  -          MatchPatternIterator mpi, Compiler compiler, int stepOpCodePos, 
  -                                                       int stepIndex)
  -            throws javax.xml.transform.TransformerException
  +  private static boolean isNaturalDocOrder(
  +    PathExpr pathExpr,
  +    int stepIndex,
  +    int analysis)
  +    throws javax.xml.transform.TransformerException
     {
  -    if (DEBUG_PATTERN_CREATION)
  -    {
  -      System.out.println("================");
  -      System.out.println("loadSteps for: "+compiler.getPatternString());
  -    }
  -    int stepType;
  -    StepPattern step = null;
  -    StepPattern firstStep = null, prevStep = null;
  -    int ops[] = compiler.getOpMap();
  -    int analysis = analyze(compiler, stepOpCodePos, stepIndex);
  +    if (canCrissCross(analysis))
  +      return false;
   
  -    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  -    {
  -      step = createDefaultStepPattern(compiler, stepOpCodePos, mpi, analysis,
  -                                      firstStep, prevStep);
  +    // Namespaces can present some problems, so just punt if we're looking for 
  +    // these.
  +    if (isSet(analysis, BIT_NAMESPACE))
  +      return false;
   
  -      if (null == firstStep)
  -      {
  -        firstStep = step;
  -      }
  -      else
  -      {
  +    // The following, preceding, following-sibling, and preceding sibling can 
  +    // be found in doc order if we get to this point, but if they occur 
  +    // together, they produce 
  +    // duplicates, so it's better for us to eliminate this case so we don't 
  +    // have to check for duplicates during runtime if we're using a 
  +    // WalkingIterator.
  +    if (isSet(analysis, BIT_FOLLOWING | BIT_FOLLOWING_SIBLING)
  +      && isSet(analysis, BIT_PRECEDING | BIT_PRECEDING_SIBLING))
  +      return false;
   
  -        //prevStep.setNextWalker(step);
  -        step.setRelativePathPattern(prevStep);
  -      }
  +    // OK, now we have to check for select="@*/axis::*" patterns, which 
  +    // can also cause duplicates to happen.  But select="axis*/@::*" patterns 
  +    // are OK, as are select="@foo/axis::*" patterns.
  +    // Unfortunately, we can't do this just via the analysis bits.
   
  -      prevStep = step;
  -      stepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  +    int stepType;
  +    boolean foundWildAttribute = false;
   
  -      if (stepOpCodePos < 0)
  -        break;
  -    }
  -    
  -    int axis = Axis.SELF;
  -    int paxis = Axis.SELF;
  -    StepPattern tail = step;
  -    for (StepPattern pat = step; null != pat; 
  -         pat = pat.getRelativePathPattern()) 
  -    {
  -      int nextAxis = pat.getAxis();
  -      //int nextPaxis = pat.getPredicateAxis();
  -      pat.setAxis(axis);
  -      
  -      // The predicate axis can't be moved!!!  Test Axes103
  -      // pat.setPredicateAxis(paxis);
  -      
  -      // If we have an attribute or namespace axis that went up, then 
  -      // it won't find the attribute in the inverse, since the select-to-match
  -      // axes are not invertable (an element is a parent of an attribute, but 
  -      // and attribute is not a child of an element).
  -      // If we don't do the magic below, then "@*/ancestor-or-self::*" gets
  -      // inverted for match to "self::*/descendant-or-self::@*/parent::node()",
  -      // which obviously won't work.
  -      // So we will rewrite this as:
  -      // "self::*/descendant-or-self::*/attribute::*/parent::node()"
  -      // Child has to be rewritten a little differently:
  -      // select: "@*/parent::*"
  -      // inverted match: "self::*/child::@*/parent::node()"
  -      // rewrite: "self::*/attribute::*/parent::node()"
  -      // Axes that go down in the select, do not have to have special treatment 
  -      // in the rewrite. The following inverted match will still not select 
  -      // anything.
  -      // select: "@*/child::*"
  -      // inverted match: "self::*/parent::@*/parent::node()"
  -      // Lovely business, this.
  -      // -sb
  -      int whatToShow = pat.getWhatToShow();
  -      if(whatToShow == DTMFilter.SHOW_ATTRIBUTE || 
  -         whatToShow == DTMFilter.SHOW_NAMESPACE)
  +    // Steps that can traverse anything other than down a 
  +    // subtree or that can produce duplicates when used in 
  +    // combonation are counted with this variable.
  +    int potentialDuplicateMakingStepCount = 0;
  +
  +    int numSteps = pathExpr.jjtGetNumChildren();
  +
  +    for (int i = 0; i < numSteps; i++)
  +    {
  +      StepExpr stepExpr = (StepExpr) pathExpr.jjtGetChild(stepIndex);
  +
  +      Node firstChild = stepExpr.jjtGetChild(0);
  +      if (firstChild instanceof PatternAxis)
         {
  -        int newAxis = (whatToShow == DTMFilter.SHOW_ATTRIBUTE) ? 
  -                       Axis.ATTRIBUTE : Axis.NAMESPACE;
  -        if(isDownwardAxisOfMany(axis))
  +        Node secondChild = stepExpr.jjtGetChild(1);
  +        org.apache.xpath.parser.NodeTest nt;
  +        boolean isTotallyWild;
  +
  +        if (secondChild instanceof org.apache.xpath.parser.NodeTest)
  +        {
  +          nt = (org.apache.xpath.parser.NodeTest) secondChild;
  +          isTotallyWild = nt.isTotallyWild();
  +          // Double check.
  +          if (0
  +            != (nt.getWhatToShow() | org.apache.xml.dtm.DTMFilter.SHOW_ALL))
  +          {
  +            isTotallyWild = true;
  +          }
  +        }
  +        else
           {
  -          StepPattern attrPat = new StepPattern(whatToShow, 
  -                                    pat.getNamespace(),
  -                                    pat.getLocalName(),
  -                                //newAxis, pat.getPredicateAxis);
  -                                                newAxis, 0); // don't care about the predicate axis
  -          XNumber score = pat.getStaticScore();
  -          pat.setNamespace(null);
  -          pat.setLocalName(NodeTest.WILD);
  -          attrPat.setPredicates(pat.getPredicates());
  -          pat.setPredicates(null);
  -          pat.setWhatToShow(DTMFilter.SHOW_ELEMENT);
  -          StepPattern rel = pat.getRelativePathPattern();
  -          pat.setRelativePathPattern(attrPat);
  -          attrPat.setRelativePathPattern(rel);
  -          attrPat.setStaticScore(score);
  -          
  -          // This is needed to inverse a following pattern, because of the 
  -          // wacky Xalan rules for following from an attribute.  See axes108.
  -          // By these rules, following from an attribute is not strictly 
  -          // inverseable.
  -          if(Axis.PRECEDING == pat.getAxis())
  -            pat.setAxis(Axis.PRECEDINGANDANCESTOR);
  -            
  -          else if(Axis.DESCENDANT == pat.getAxis())
  -            pat.setAxis(Axis.DESCENDANTORSELF);
  -          
  -          pat = attrPat;
  +          isTotallyWild = false;
  +          nt = null;
           }
  -        else if(Axis.CHILD == pat.getAxis())
  +
  +        int axis = ((PatternAxis) firstChild).getAxis();
  +        switch (axis)
           {
  -          // In this case just change the axis.
  -          // pat.setWhatToShow(whatToShow);
  -          pat.setAxis(Axis.ATTRIBUTE);
  +          case Axis.NAMESPACE :
  +          case Axis.ATTRIBUTE :
  +            if (foundWildAttribute) // Maybe not needed, but be safe.
  +              return false;
  +            if (isTotallyWild)
  +              foundWildAttribute = true;
  +            break;
  +          case Axis.DESCENDANTSFROMROOT :
  +          case Axis.DESCENDANTSORSELFFROMROOT :
  +          case Axis.ANCESTOR :
  +          case Axis.ANCESTORORSELF :
  +          case Axis.DESCENDANT :
  +          case Axis.DESCENDANTORSELF :
  +          case Axis.FOLLOWING :
  +          case Axis.FOLLOWINGSIBLING :
  +          case Axis.PRECEDING :
  +          case Axis.PRECEDINGSIBLING :
  +          case Axis.PARENT :
  +            if (potentialDuplicateMakingStepCount > 0)
  +              return false;
  +            potentialDuplicateMakingStepCount++;
  +          case Axis.ROOT :
  +          case Axis.CHILD :
  +          case Axis.SELF :
  +            if (foundWildAttribute)
  +              return false;
  +            break;
  +          default :
  +            // TBD: Change the wording of this expression.
  +            throw new RuntimeException(
  +              XSLMessages.createXPATHMessage(
  +                XPATHErrorResources.ER_NULL_ERROR_HANDLER,
  +                new Object[] { firstChild.getClass().getName()}));
  +            //"Programmer's assertion: unknown opcode: "
  +            //+ stepType);
           }
         }
  -      axis = nextAxis;
  -      //paxis = nextPaxis;
  -      tail = pat;
  -    }
  -    
  -    if(axis < Axis.ALL)
  -    {
  -      StepPattern selfPattern = new ContextMatchStepPattern(axis, paxis);
  -      // We need to keep the new nodetest from affecting the score...
  -      XNumber score = tail.getStaticScore();
  -      tail.setRelativePathPattern(selfPattern);
  -      tail.setStaticScore(score);
  -      selfPattern.setStaticScore(score);
  -    }        
  -
  -    if (DEBUG_PATTERN_CREATION)
  -    {
  -      System.out.println("Done loading steps: "+step.toString());
  -            
  -      System.out.println("");
  +      else
  +      {
  +        // For the moment return false if it is a filter expression.  
  +        // Ideally, we'd like to follow the analysis into a variable or function.
  +        return false;
  +      }
       }
  -    return step;  // start from last pattern?? //firstStep;
  +
  +    return true;
     }
   
     /**
  -   * Create a StepPattern that is contained within a LocationPath.
  -   *
  +   * Special purpose function to see if we can optimize the pattern for 
  +   * a DescendantIterator.
      *
  -   * @param compiler The compiler that holds the syntax tree/op map to
  -   * construct from.
  -   * @param stepOpCodePos The current op code position within the opmap.
  -   * @param mpi The MatchPatternIterator to which the steps will be attached.
  -   * @param analysis 32 bits of analysis, from which the type of AxesWalker
  -   *                 may be influenced.
  -   * @param tail The step that is the first step analyzed, but the last 
  -   *                  step in the relative match linked list, i.e. the tail.
  -   *                  May be null.
  -   * @param head The step that is the current head of the relative 
  -   *                 match step linked list.
  -   *                 May be null.
  +   * @param pathExpr Root of the path expression being analyzed.
  +   * @param stepIndex The top-level step index withing the iterator.
      *
  -   * @return the head of the list.
  +   * @return 32 bits as an integer that give information about the location
  +   * path as a whole.
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  private static StepPattern createDefaultStepPattern(
  -          Compiler compiler, int opPos, MatchPatternIterator mpi, 
  -          int analysis, StepPattern tail, StepPattern head)
  -            throws javax.xml.transform.TransformerException
  +  private static boolean isOptimizableForDescendantIterator(
  +    PathExpr pathExpr,
  +    int stepIndex)
  +    throws javax.xml.transform.TransformerException
     {
   
  -    int stepType = compiler.getOp(opPos);
  -    boolean simpleInit = false;
  -    int totalNumberWalkers = (analysis & BITS_COUNT);
  -    boolean prevIsOneStepDown = true;
  -    int firstStepPos = compiler.getFirstChildPos(opPos);
  -    
  -    int whatToShow = compiler.getWhatToShow(opPos);
  -    StepPattern ai = null;
  -    int axis, predicateAxis;
  -    
  -    switch (stepType)
  -    {
  -    case OpCodes.OP_VARIABLE :
  -    case OpCodes.OP_EXTFUNCTION :
  -    case OpCodes.OP_FUNCTION :
  -    case OpCodes.OP_GROUP :
  -      prevIsOneStepDown = false;
  +    int stepType;
  +    boolean foundDESCENDANTSFROMROOT = false;
  +
  +    int nodeTestType = DTMFilter.SHOW_ALL;
   
  -      Expression expr;
  +    int numSteps = pathExpr.jjtGetNumChildren();
   
  -      switch (stepType)
  +    if (numSteps > 2)
  +      return false;
  +
  +    for (int i = 0; i < numSteps; i++)
  +    {
  +      StepExpr stepExpr = (StepExpr) pathExpr.jjtGetChild(i);
  +
  +      int axis = stepExpr.getAxis();
  +      switch (axis)
         {
  -      case OpCodes.OP_VARIABLE :
  -      case OpCodes.OP_EXTFUNCTION :
  -      case OpCodes.OP_FUNCTION :
  -      case OpCodes.OP_GROUP :
  -        expr = compiler.compile(opPos);
  -        break;
  -      default :
  -        expr = compiler.compile(opPos + 2);
  +        case Axis.SELF :
  +        case Axis.ATTRIBUTE :
  +        case Axis.ROOT :
  +        case Axis.ANCESTOR :
  +        case Axis.ANCESTORORSELF :
  +        case Axis.NAMESPACE :
  +        case Axis.DESCENDANT :
  +        case Axis.DESCENDANTORSELF :
  +        case Axis.FOLLOWING :
  +        case Axis.FOLLOWINGSIBLING :
  +        case Axis.PRECEDING :
  +        case Axis.PRECEDINGSIBLING :
  +        case Axis.PARENT :
  +          return false;
  +        case Axis.DESCENDANTSORSELFFROMROOT :
  +        case Axis.DESCENDANTSFROMROOT :
  +          if (0 != i)
  +            return false;
  +          foundDESCENDANTSFROMROOT = true;
  +          if (analyzePredicate(stepExpr))
  +          {
  +            return false;
  +          }
  +          break;
  +        case Axis.CHILD :
  +          if (!foundDESCENDANTSFROMROOT || 1 != i)
  +            return false;
  +          if(mightBeProximate(stepExpr))
  +            return false;
  +          break;
  +        default :
  +          return false;
  +          // TBD: Change the wording of this expression.
  +          // throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{firstChild.getClass().getName()})); //"Programmer's assertion: unknown opcode: "
         }
   
  -      axis = Axis.FILTEREDLIST;
  -      predicateAxis = Axis.FILTEREDLIST;
  -      ai = new FunctionPattern(expr, axis, predicateAxis);
  -      simpleInit = true;
  -      break;
  -    case OpCodes.FROM_ROOT :
  -      whatToShow = DTMFilter.SHOW_DOCUMENT
  -                   | DTMFilter.SHOW_DOCUMENT_FRAGMENT;
  -
  -      axis = Axis.ROOT;
  -      predicateAxis = Axis.ROOT;
  -      ai = new StepPattern(DTMFilter.SHOW_DOCUMENT | 
  -                                DTMFilter.SHOW_DOCUMENT_FRAGMENT,
  -                                axis, predicateAxis);
  -      break;
  -    case OpCodes.FROM_ATTRIBUTES :
  -      whatToShow = DTMFilter.SHOW_ATTRIBUTE;
  -      axis = Axis.PARENT;
  -      predicateAxis = Axis.ATTRIBUTE;
  -      // ai = new StepPattern(whatToShow, Axis.SELF, Axis.SELF);
  -      break;
  -    case OpCodes.FROM_NAMESPACE :
  -      whatToShow = DTMFilter.SHOW_NAMESPACE;
  -      axis = Axis.PARENT;
  -      predicateAxis = Axis.NAMESPACE;
  -      // ai = new StepPattern(whatToShow, axis, predicateAxis);
  -      break;
  -    case OpCodes.FROM_ANCESTORS :
  -      axis = Axis.DESCENDANT;
  -      predicateAxis = Axis.ANCESTOR;
  -      break;
  -    case OpCodes.FROM_CHILDREN :
  -      axis = Axis.PARENT;
  -      predicateAxis = Axis.CHILD;
  -      break;
  -    case OpCodes.FROM_ANCESTORS_OR_SELF :
  -      axis = Axis.DESCENDANTORSELF;
  -      predicateAxis = Axis.ANCESTORORSELF;
  -      break;
  -    case OpCodes.FROM_SELF :
  -      axis = Axis.SELF;
  -      predicateAxis = Axis.SELF;
  -      break;
  -    case OpCodes.FROM_PARENT :
  -      axis = Axis.CHILD;
  -      predicateAxis = Axis.PARENT;
  -      break;
  -    case OpCodes.FROM_PRECEDING_SIBLINGS :
  -      axis = Axis.FOLLOWINGSIBLING;
  -      predicateAxis = Axis.PRECEDINGSIBLING;
  -      break;
  -    case OpCodes.FROM_PRECEDING :
  -      axis = Axis.FOLLOWING;
  -      predicateAxis = Axis.PRECEDING;
  -      break;
  -    case OpCodes.FROM_FOLLOWING_SIBLINGS :
  -      axis = Axis.PRECEDINGSIBLING;
  -      predicateAxis = Axis.FOLLOWINGSIBLING;
  -      break;
  -    case OpCodes.FROM_FOLLOWING :
  -      axis = Axis.PRECEDING;
  -      predicateAxis = Axis.FOLLOWING;
  -      break;
  -    case OpCodes.FROM_DESCENDANTS_OR_SELF :
  -      axis = Axis.ANCESTORORSELF;
  -      predicateAxis = Axis.DESCENDANTORSELF;
  -      break;
  -    case OpCodes.FROM_DESCENDANTS :
  -      axis = Axis.ANCESTOR;
  -      predicateAxis = Axis.DESCENDANT;
  -      break;
  -    default :
  -      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  -                                 //+ stepType);
  -    }
  -    if(null == ai)
  -    {
  -      whatToShow = compiler.getWhatToShow(opPos); // %REVIEW%
  -      ai = new StepPattern(whatToShow, compiler.getStepNS(opPos),
  -                                compiler.getStepLocalName(opPos),
  -                                axis, predicateAxis);
  -    }
  -   
  -    if (false || DEBUG_PATTERN_CREATION)
  -    {
  -      System.out.print("new step: "+ ai);
  -      System.out.print(", axis: " + Axis.names[ai.getAxis()]);
  -      System.out.print(", predAxis: " + Axis.names[ai.getAxis()]);
  -      System.out.print(", what: ");
  -      System.out.print("    ");
  -      ai.debugWhatToShow(ai.getWhatToShow());
  -    }
  -
  -    int argLen = compiler.getFirstPredicateOpPos(opPos);
  +      // TBD: I don't think the code will function properly without this.      
  +      //      boolean mightBeProximate = mightBeProximate(compiler, stepOpCodePos, stepType);
  +      //      if(mightBeProximate)
  +      //        return false;
   
  -    ai.setPredicates(compiler.getCompiledPredicates(argLen));
  +    }
   
  -    return ai;
  +    return true;
     }
   
  +  // TBD: Needs to use methods on the expressions instead of instanceof!
     /**
  -   * Analyze a step and give information about it's predicates.  Right now this
  -   * just returns true or false if the step has a predicate.
  -   *
  -   * @param compiler non-null reference to compiler object that has processed
  -   *                 the XPath operations into an opcode map.
  -   * @param opPos The opcode position for the step.
  -   * @param stepType The type of step, one of OP_GROUP, etc.
  -   *
  -   * @return true if step has a predicate.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * Tell if the predicates need to have proximity knowledge.
      */
  -  static boolean analyzePredicate(Compiler compiler, int opPos, int stepType)
  -          throws javax.xml.transform.TransformerException
  +  public static boolean mightBeProximate(Expression stepExpr)
  +    throws javax.xml.transform.TransformerException
     {
   
  +    boolean mightBeProximate = false;
       int argLen;
   
  -    switch (stepType)
  +    Node lastChild = stepExpr.jjtGetChild(stepExpr.jjtGetNumChildren() - 1);
  +    if (lastChild instanceof Predicates)
       {
  -    case OpCodes.OP_VARIABLE :
  -    case OpCodes.OP_EXTFUNCTION :
  -    case OpCodes.OP_FUNCTION :
  -    case OpCodes.OP_GROUP :
  -      argLen = compiler.getArgLength(opPos);
  -      break;
  -    default :
  -      argLen = compiler.getArgLengthOfStep(opPos);
  +      Predicates preds = (Predicates) lastChild;
  +      int numChildren = preds.jjtGetNumChildren();
  +      for (int i = 0; i < numChildren; i++)
  +      {
  +        Expression expr = (Expression) preds.jjtGetChild(i);
  +
  +        if (expr instanceof org.apache.xpath.operations.Variable)
  +        {
  +          return true;
  +          // Would need more smarts to tell if this could be a number or not!
  +        }
  +        else
  +          if (expr instanceof org.apache.xpath.objects.XNumber)
  +          {
  +            return true;
  +          }
  +          else
  +            if (expr instanceof org.apache.xpath.parser.PathExpr
  +              || expr instanceof LocPathIterator)
  +            {
  +              // OK, keep going, we don't want to recurse.
  +            }
  +            else
  +              if (expr instanceof org.apache.xpath.functions.Function)
  +              {
  +                boolean isProx =
  +                  functionProximateOrContainsProximate(
  +                    (org.apache.xpath.functions.Function) expr);
  +                if (isProx)
  +                  return true;
  +                break;
  +
  +              }
  +              else
  +              {
  +                int numChildrenOfExpr = expr.jjtGetNumChildren();
  +                for (int j = 0; j < numChildrenOfExpr; j++)
  +                {
  +                  Expression exprChild = (Expression) expr.jjtGetChild(j);
  +                  boolean prox = isProximateInnerExpr(exprChild);
  +                  if (prox)
  +                    return true;
  +                }
  +              }
  +
  +      }
  +    }
  +
  +    return mightBeProximate;
  +  }
  +
  +  // TBD: Needs to use methods on the expressions instead of instanceof!
  +  static boolean functionProximateOrContainsProximate(
  +    org.apache.xpath.functions.Function func)
  +  {
  +    if (func instanceof org.apache.xpath.functions.FuncLast
  +      || func instanceof org.apache.xpath.functions.FuncPosition)
  +    {
  +      return true;
       }
  +    else
  +    {
  +      int numChildren = func.jjtGetNumChildren();
  +      for (int i = 0; i < numChildren; i++)
  +      {
  +        Expression expr = (Expression) func.jjtGetChild(i);
  +        boolean prox = isProximateInnerExpr(expr);
  +        if (prox)
  +          return true;
  +      }
  +    }
  +    return false;
  +  }
   
  -    int pos = compiler.getFirstPredicateOpPos(opPos);
  -    int nPredicates = compiler.countPredicates(pos);
  +  // TBD: Needs to use methods on the expressions instead of instanceof!
  +  static boolean isProximateInnerExpr(Expression expr)
  +  {
  +    boolean mightBeProximate = false;
  +    int argLen;
   
  -    return (nPredicates > 0) ? true : false;
  +    if (expr instanceof org.apache.xpath.parser.PathExpr
  +      || expr instanceof LocPathIterator)
  +    {
  +      // OK, we don't want to recurse!
  +    }
  +    else
  +      if (expr instanceof org.apache.xpath.functions.Function)
  +      {
  +        boolean isProx =
  +          functionProximateOrContainsProximate(
  +            (org.apache.xpath.functions.Function) expr);
  +        if (isProx)
  +          return true;
  +      }
  +      else
  +      {
  +        int numChildrenOfExpr = expr.jjtGetNumChildren();
  +        for (int j = 0; j < numChildrenOfExpr; j++)
  +        {
  +          Expression exprChild = (Expression) expr.jjtGetChild(j);
  +          boolean prox = isProximateInnerExpr(exprChild);
  +          if (prox)
  +            return true;
  +        }
  +      }
  +    return mightBeProximate;
     }
   
     /**
  @@ -1210,666 +1289,1999 @@
      * @return non-null reference to AxesWalker derivative.
      * @throws RuntimeException if the input is bad.
      */
  -  private static AxesWalker createDefaultWalker(Compiler compiler, int opPos,
  -          WalkingIterator lpi, int analysis)
  +  private static AxesWalker createDefaultWalker(
  +    StepExpr stepExpr,
  +    WalkingIterator lpi,
  +    int analysis)
     {
   
       AxesWalker ai = null;
  -    int stepType = compiler.getOp(opPos);
   
  -    /*
  -    System.out.println("0: "+compiler.getOp(opPos));
  -    System.out.println("1: "+compiler.getOp(opPos+1));
  -    System.out.println("2: "+compiler.getOp(opPos+2));
  -    System.out.println("3: "+compiler.getOp(opPos+3));
  -    System.out.println("4: "+compiler.getOp(opPos+4));
  -    System.out.println("5: "+compiler.getOp(opPos+5));
  -    */
  -    boolean simpleInit = false;
  -    int totalNumberWalkers = (analysis & BITS_COUNT);
  -    boolean prevIsOneStepDown = true;
  -
  -    switch (stepType)
  -    {
  -    case OpCodes.OP_VARIABLE :
  -    case OpCodes.OP_EXTFUNCTION :
  -    case OpCodes.OP_FUNCTION :
  -    case OpCodes.OP_GROUP :
  -      prevIsOneStepDown = false;
  -
  -      if (DEBUG_WALKER_CREATION)
  -        System.out.println("new walker:  FilterExprWalker: " + analysis
  -                           + ", " + compiler.toString());
  -
  -      ai = new FilterExprWalker(lpi);
  -      simpleInit = true;
  -      break;
  -    case OpCodes.FROM_ROOT :
  -      ai = new AxesWalker(lpi, Axis.ROOT);
  -      break;
  -    case OpCodes.FROM_ANCESTORS :
  -      prevIsOneStepDown = false;
  -      ai = new ReverseAxesWalker(lpi, Axis.ANCESTOR);
  -      break;
  -    case OpCodes.FROM_ANCESTORS_OR_SELF :
  -      prevIsOneStepDown = false;
  -      ai = new ReverseAxesWalker(lpi, Axis.ANCESTORORSELF);
  -      break;
  -    case OpCodes.FROM_ATTRIBUTES :
  -      ai = new AxesWalker(lpi, Axis.ATTRIBUTE);
  -      break;
  -    case OpCodes.FROM_NAMESPACE :
  -      ai = new AxesWalker(lpi, Axis.NAMESPACE);
  -      break;
  -    case OpCodes.FROM_CHILDREN :
  -      ai = new AxesWalker(lpi, Axis.CHILD);
  -      break;
  -    case OpCodes.FROM_DESCENDANTS :
  -      prevIsOneStepDown = false;
  -      ai = new AxesWalker(lpi, Axis.DESCENDANT);
  -      break;
  -    case OpCodes.FROM_DESCENDANTS_OR_SELF :
  -      prevIsOneStepDown = false;
  -      ai = new AxesWalker(lpi, Axis.DESCENDANTORSELF);
  -      break;
  -    case OpCodes.FROM_FOLLOWING :
  -      prevIsOneStepDown = false;
  -      ai = new AxesWalker(lpi, Axis.FOLLOWING);
  -      break;
  -    case OpCodes.FROM_FOLLOWING_SIBLINGS :
  -      prevIsOneStepDown = false;
  -      ai = new AxesWalker(lpi, Axis.FOLLOWINGSIBLING);
  -      break;
  -    case OpCodes.FROM_PRECEDING :
  -      prevIsOneStepDown = false;
  -      ai = new ReverseAxesWalker(lpi, Axis.PRECEDING);
  -      break;
  -    case OpCodes.FROM_PRECEDING_SIBLINGS :
  -      prevIsOneStepDown = false;
  -      ai = new ReverseAxesWalker(lpi, Axis.PRECEDINGSIBLING);
  -      break;
  -    case OpCodes.FROM_PARENT :
  -      prevIsOneStepDown = false;
  -      ai = new ReverseAxesWalker(lpi, Axis.PARENT);
  -      break;
  -    case OpCodes.FROM_SELF :
  -      ai = new AxesWalker(lpi, Axis.SELF);
  -      break;
  -    default :
  -      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  -                                 //+ stepType);
  -    }
  -
  -    if (simpleInit)
  -    {
  -      ai.initNodeTest(DTMFilter.SHOW_ALL);
  -    }
  -    else
  +    PatternAxis patternAxis = stepExpr.getAxisExpr();
  +    if (null != patternAxis)
       {
  -      int whatToShow = compiler.getWhatToShow(opPos);
  +      boolean isTotallyWild = stepExpr.isTotallyWild();
   
  -      /*
  -      System.out.print("construct: ");
  -      NodeTest.debugWhatToShow(whatToShow);
  -      System.out.println("or stuff: "+(whatToShow & (DTMFilter.SHOW_ATTRIBUTE
  -                             | DTMFilter.SHOW_ELEMENT
  -                             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)));
  -      */
  -      if ((0 == (whatToShow
  -                 & (DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_NAMESPACE | DTMFilter.SHOW_ELEMENT
  -                    | DTMFilter.SHOW_PROCESSING_INSTRUCTION))) || (whatToShow == DTMFilter.SHOW_ALL))
  -        ai.initNodeTest(whatToShow);
  -      else
  +      int axis = stepExpr.getAxis();
  +      switch (axis)
         {
  -        ai.initNodeTest(whatToShow, compiler.getStepNS(opPos),
  -                        compiler.getStepLocalName(opPos));
  -      }
  -    }
  -
  -    return ai;
  -  }
  -  
  -  public static String getAnalysisString(int analysis)
  -  {
  -    StringBuffer buf = new StringBuffer();
  -    buf.append("count: "+getStepCount(analysis)+" ");
  -    if((analysis & BIT_NODETEST_ANY) != 0)
  -    {
  -      buf.append("NTANY|");
  -    }
  -    if((analysis & BIT_PREDICATE) != 0)
  -    {
  -      buf.append("PRED|");
  -    }
  -    if((analysis & BIT_ANCESTOR) != 0)
  -    {
  -      buf.append("ANC|");
  -    }
  -    if((analysis & BIT_ANCESTOR_OR_SELF) != 0)
  -    {
  -      buf.append("ANCOS|");
  -    }
  -    if((analysis & BIT_ATTRIBUTE) != 0)
  -    {
  -      buf.append("ATTR|");
  -    }
  -    if((analysis & BIT_CHILD) != 0)
  -    {
  -      buf.append("CH|");
  -    }
  -    if((analysis & BIT_DESCENDANT) != 0)
  -    {
  -      buf.append("DESC|");
  -    }
  -    if((analysis & BIT_DESCENDANT_OR_SELF) != 0)
  -    {
  -      buf.append("DESCOS|");
  -    }
  -    if((analysis & BIT_FOLLOWING) != 0)
  -    {
  -      buf.append("FOL|");
  -    }
  -    if((analysis & BIT_FOLLOWING_SIBLING) != 0)
  -    {
  -      buf.append("FOLS|");
  -    }
  -    if((analysis & BIT_NAMESPACE) != 0)
  -    {
  -      buf.append("NS|");
  -    }
  -    if((analysis & BIT_PARENT) != 0)
  -    {
  -      buf.append("P|");
  -    }
  -    if((analysis & BIT_PRECEDING) != 0)
  -    {
  -      buf.append("PREC|");
  -    }
  -    if((analysis & BIT_PRECEDING_SIBLING) != 0)
  -    {
  -      buf.append("PRECS|");
  -    }
  -    if((analysis & BIT_SELF) != 0)
  -    {
  -      buf.append(".|");
  -    }
  -    if((analysis & BIT_FILTER) != 0)
  -    {
  -      buf.append("FLT|");
  +        case Axis.ROOT :
  +          ai = new AxesWalker(lpi, Axis.ROOT);
  +          break;
  +        case Axis.DESCENDANTSFROMROOT :
  +          ai = new AxesWalker(lpi, Axis.DESCENDANTSFROMROOT);
  +          break;
  +        case Axis.DESCENDANTSORSELFFROMROOT :
  +          ai = new AxesWalker(lpi, Axis.DESCENDANTSORSELFFROMROOT);
  +          break;
  +        case Axis.ANCESTOR :
  +          ai = new ReverseAxesWalker(lpi, Axis.ANCESTOR);
  +          break;
  +        case Axis.ANCESTORORSELF :
  +          ai = new ReverseAxesWalker(lpi, Axis.ANCESTORORSELF);
  +          break;
  +        case Axis.ATTRIBUTE :
  +          ai = new AxesWalker(lpi, Axis.ATTRIBUTE);
  +          break;
  +        case Axis.NAMESPACE :
  +          ai = new AxesWalker(lpi, Axis.NAMESPACE);
  +          break;
  +        case Axis.CHILD :
  +          ai = new AxesWalker(lpi, Axis.CHILD);
  +          break;
  +        case Axis.DESCENDANT :
  +          ai = new AxesWalker(lpi, Axis.DESCENDANT);
  +          break;
  +        case Axis.DESCENDANTORSELF :
  +          ai = new AxesWalker(lpi, Axis.DESCENDANTORSELF);
  +          break;
  +        case Axis.FOLLOWING :
  +          ai = new AxesWalker(lpi, Axis.FOLLOWING);
  +          break;
  +        case Axis.FOLLOWINGSIBLING :
  +          ai = new AxesWalker(lpi, Axis.FOLLOWINGSIBLING);
  +          break;
  +        case Axis.PRECEDING :
  +          ai = new ReverseAxesWalker(lpi, Axis.PRECEDING);
  +          break;
  +        case Axis.PRECEDINGSIBLING :
  +          ai = new ReverseAxesWalker(lpi, Axis.PRECEDINGSIBLING);
  +          break;
  +        case Axis.PARENT :
  +          ai = new ReverseAxesWalker(lpi, Axis.PARENT);
  +          break;
  +        case Axis.SELF :
  +          ai = new AxesWalker(lpi, Axis.SELF);
  +          break;
  +        default :
  +          throw new RuntimeException(
  +            XSLMessages.createXPATHMessage(
  +              XPATHErrorResources.ER_NULL_ERROR_HANDLER,
  +              new Object[] { StepExpr.class.getName()}));
  +          //"Programmer's assertion: unknown opcode: "
  +          //+ stepType);
  +      }
  +      int whatToShow = stepExpr.getWhatToShow();
  +
  +      /*
  +      System.out.print("construct: ");
  +      NodeTest.debugWhatToShow(whatToShow);
  +      System.out.println("or stuff: "+(whatToShow & (DTMFilter.SHOW_ATTRIBUTE
  +                             | DTMFilter.SHOW_ELEMENT
  +                             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)));
  +      */
  +      if ((0
  +        == (whatToShow
  +          & (DTMFilter.SHOW_ATTRIBUTE
  +            | DTMFilter.SHOW_NAMESPACE
  +            | DTMFilter.SHOW_ELEMENT
  +            | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
  +        || (whatToShow == DTMFilter.SHOW_ALL))
  +        ai.initNodeTest(whatToShow);
  +      else
  +      {
  +        ai.initNodeTest(
  +          whatToShow,
  +          stepExpr.getNamespaceURI(),
  +          stepExpr.getLocalName());
  +      }
       }
  -    if((analysis & BIT_ROOT) != 0)
  +    else
       {
  -      buf.append("R|");
  -    }
  -    return buf.toString();
  -  }
  -
  -  /** Set to true for diagnostics about walker creation */
  -  static final boolean DEBUG_PATTERN_CREATION = false;
  -
  -  /** Set to true for diagnostics about walker creation */
  -  static final boolean DEBUG_WALKER_CREATION = false;
  -
  -  /** Set to true for diagnostics about iterator creation */
  -  static final boolean DEBUG_ITERATOR_CREATION = false;
  -  
  -  public static boolean hasPredicate(int analysis)
  -  {
  -    return (0 != (analysis & BIT_PREDICATE));
  -  }
  +      // FilterWalker
  +      if (DEBUG_WALKER_CREATION)
  +        System.out.println(
  +          "new walker:  FilterExprWalker: "
  +            + analysis
  +            + ", "
  +            + stepExpr.toString());
   
  -  public static boolean isWild(int analysis)
  -  {
  -    return (0 != (analysis & BIT_NODETEST_ANY));
  -  }
  +      ai = new FilterExprWalker(lpi);
  +      try
  +      {
  +        ai.init(stepExpr);
  +      }
  +      catch (TransformerException te)
  +      {
  +        throw new org.apache.xml.utils.WrappedRuntimeException(te);
  +      }
  +      ai.initNodeTest(DTMFilter.SHOW_ALL);
  +    }
   
  -  public static boolean walksAncestors(int analysis)
  -  {
  -    return isSet(analysis, BIT_ANCESTOR | BIT_ANCESTOR_OR_SELF);
  -  }
  -  
  -  public static boolean walksAttributes(int analysis)
  -  {
  -    return (0 != (analysis & BIT_ATTRIBUTE));
  +    return ai;
     }
   
  -  public static boolean walksNamespaces(int analysis)
  -  {
  -    return (0 != (analysis & BIT_NAMESPACE));
  -  }  
  -
  -  public static boolean walksChildren(int analysis)
  +  /**
  +   * <meta name="usage" content="advanced"/>
  +   * This method is for building an array of possible levels
  +   * where the target element(s) could be found for a match.
  +   * @param xpath The xpath that is executing.
  +   * @param context The current source tree context node.
  +   *
  +   * @param lpi The owning location path iterator object.
  +   * @param compiler non-null reference to compiler object that has processed
  +   *                 the XPath operations into an opcode map.
  +   * @param stepOpCodePos The opcode position for the step.
  +   * @param stepIndex The top-level step index withing the iterator.
  +   *
  +   * @return non-null AxesWalker derivative.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  static AxesWalker loadWalkers(
  +    org.apache.xpath.parser.PathExpr pathExpr,
  +    WalkingIterator lpi)
  +    throws javax.xml.transform.TransformerException
     {
  -    return (0 != (analysis & BIT_CHILD));
  -  }
   
  -  public static boolean walksDescendants(int analysis)
  -  {
  -    return isSet(analysis, BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF);
  -  }
  +    int stepType;
  +    AxesWalker firstWalker = null;
  +    AxesWalker walker, prevWalker = null;
  +    int analysis = analyze(pathExpr, 0);
  +    int numSteps = pathExpr.jjtGetNumChildren();
   
  -  public static boolean walksSubtree(int analysis)
  -  {
  -    return isSet(analysis, BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF | BIT_CHILD);
  -  }
  -  
  -  public static boolean walksSubtreeOnlyMaybeAbsolute(int analysis)
  -  {
  -    return walksSubtree(analysis)
  -           && !walksExtraNodes(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           ;
  -  }
  -  
  -  public static boolean walksSubtreeOnly(int analysis)
  -  {
  -    return walksSubtreeOnlyMaybeAbsolute(analysis) 
  -           && !isAbsolute(analysis) 
  -           ;
  -  }
  +    for (int i = 0; i < numSteps; i++)
  +    {
  +      StepExpr stepExpr = (StepExpr) pathExpr.jjtGetChild(i);
   
  -  public static boolean walksFilteredList(int analysis)
  -  {
  -    return isSet(analysis, BIT_FILTER);
  -  }
  -  
  -  public static boolean walksSubtreeOnlyFromRootOrContext(int analysis)
  -  {
  -    return walksSubtree(analysis)
  -           && !walksExtraNodes(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && !isSet(analysis, BIT_FILTER) 
  -           ;
  -  }
  +      walker = createDefaultWalker(stepExpr, lpi, analysis);
  +      walker.init(stepExpr);
   
  -  public static boolean walksInDocOrder(int analysis)
  -  {
  -    return (walksSubtreeOnlyMaybeAbsolute(analysis)
  -           || walksExtraNodesOnly(analysis)
  -           || walksFollowingOnlyMaybeAbsolute(analysis)) 
  -           && !isSet(analysis, BIT_FILTER) 
  -           ;
  -  }
  -  
  -  public static boolean walksFollowingOnlyMaybeAbsolute(int analysis)
  -  {
  -    return isSet(analysis, BIT_SELF | BIT_FOLLOWING_SIBLING | BIT_FOLLOWING)
  -           && !walksSubtree(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           ;
  -  }
  -  
  -  public static boolean walksUp(int analysis)
  -  {
  -    return isSet(analysis, BIT_PARENT | BIT_ANCESTOR | BIT_ANCESTOR_OR_SELF);
  -  }
  -  
  -  public static boolean walksSideways(int analysis)
  -  {
  -    return isSet(analysis, BIT_FOLLOWING | BIT_FOLLOWING_SIBLING | 
  -                           BIT_PRECEDING | BIT_PRECEDING_SIBLING);
  -  }
  -  
  -  public static boolean walksExtraNodes(int analysis)
  -  {
  -    return isSet(analysis, BIT_NAMESPACE | BIT_ATTRIBUTE);
  -  }
  +      // walker.setAnalysis(analysis);
  +      if (null == firstWalker)
  +      {
  +        firstWalker = walker;
  +        walker.exprSetParent(lpi);
  +      }
  +      else
  +      {
  +        prevWalker.setNextWalker(walker);
  +        walker.setPrevWalker(prevWalker);
  +        walker.exprSetParent(prevWalker);
  +      }
   
  -  public static boolean walksExtraNodesOnly(int analysis)
  -  {
  -    return walksExtraNodes(analysis)
  -           && !isSet(analysis, BIT_SELF) 
  -           && !walksSubtree(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && !isAbsolute(analysis) 
  -           ;
  -  }
  +      prevWalker = walker;
  +    }
   
  -  public static boolean isAbsolute(int analysis)
  -  {
  -    return isSet(analysis, BIT_ROOT | BIT_FILTER);
  -  }
  -  
  -  public static boolean walksChildrenOnly(int analysis)
  -  {
  -    return walksChildren(analysis)
  -           && !isSet(analysis, BIT_SELF)
  -           && !walksExtraNodes(analysis)
  -           && !walksDescendants(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT))
  -           ;
  -  }
  -  
  -  public static boolean walksChildrenAndExtraAndSelfOnly(int analysis)
  -  {
  -    return walksChildren(analysis)
  -           && !walksDescendants(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT))
  -           ;
  -  }
  -  
  -  public static boolean walksDescendantsAndExtraAndSelfOnly(int analysis)
  -  {
  -    return !walksChildren(analysis)
  -           && walksDescendants(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT))
  -           ;
  -  }
  -  
  -  public static boolean walksSelfOnly(int analysis)
  -  {
  -    return isSet(analysis, BIT_SELF) 
  -           && !walksSubtree(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && !isAbsolute(analysis) 
  -           ;
  +    return firstWalker;
     }
   
  -  
  -  public static boolean walksUpOnly(int analysis)
  -  {
  -    return !walksSubtree(analysis) 
  -           && walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && !isAbsolute(analysis) 
  -           ;
  -  }
  -  
  -  public static boolean walksDownOnly(int analysis)
  -  {
  -    return walksSubtree(analysis) 
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && !isAbsolute(analysis) 
  -           ;
  -  }
  +}
   
  -  public static boolean walksDownExtraOnly(int analysis)
  -  {
  -    return walksSubtree(analysis) &&  walksExtraNodes(analysis)
  -           && !walksUp(analysis) 
  -           && !walksSideways(analysis) 
  -           && !isAbsolute(analysis) 
  -           ;
  -  }
  -  
  -  public static boolean canSkipSubtrees(int analysis)
  -  {
  -    return isSet(analysis, BIT_CHILD) | walksSideways(analysis);
  -  }
  -  
  -  public static boolean canCrissCross(int analysis)
  -  {
  -    // This could be done faster.  Coded for clarity.
  -    if(walksSelfOnly(analysis))
  -      return false;
  -    else if(walksDownOnly(analysis) && !canSkipSubtrees(analysis))
  -      return false;
  -    else if(walksChildrenAndExtraAndSelfOnly(analysis))
  -      return false;
  -    else if(walksDescendantsAndExtraAndSelfOnly(analysis))
  -      return false;
  -    else if(walksUpOnly(analysis))
  -      return false;
  -    else if(walksExtraNodesOnly(analysis))
  -      return false;
  -    else if(walksSubtree(analysis) 
  -           && (walksSideways(analysis) 
  -            || walksUp(analysis) 
  -            || canSkipSubtrees(analysis)))
  -      return true;
  -    else
  -      return false;
  -  }
  -  
  -  /**
  -   * Tell if the pattern can be 'walked' with the iteration steps in natural 
  -   * document order, without duplicates.
  -   *
  -   * @param analysis The general analysis of the pattern.
  -   *
  -   * @return true if the walk can be done in natural order.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  static public boolean isNaturalDocOrder(int analysis)
  -  {
  -    if(canCrissCross(analysis) || isSet(analysis, BIT_NAMESPACE) ||
  -       walksFilteredList(analysis))
  -      return false;
  -      
  -    if(walksInDocOrder(analysis))
  -      return true;
  -      
  -    return false;
  -  }
  -  
  -  /**
  -   * Tell if the pattern can be 'walked' with the iteration steps in natural 
  -   * document order, without duplicates.
  -   *
  -   * @param compiler non-null reference to compiler object that has processed
  -   *                 the XPath operations into an opcode map.
  -   * @param stepOpCodePos The opcode position for the step.
  -   * @param stepIndex The top-level step index withing the iterator.
  -   * @param analysis The general analysis of the pattern.
  -   *
  -   * @return true if the walk can be done in natural order.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  private static boolean isNaturalDocOrder(
  -          Compiler compiler, int stepOpCodePos, int stepIndex, int analysis)
  -            throws javax.xml.transform.TransformerException
  -  {
  -    if(canCrissCross(analysis))
  -      return false;
  -      
  -    // Namespaces can present some problems, so just punt if we're looking for 
  -    // these.
  -    if(isSet(analysis, BIT_NAMESPACE))
  -      return false;
  -      
  -    // The following, preceding, following-sibling, and preceding sibling can 
  -    // be found in doc order if we get to this point, but if they occur 
  -    // together, they produce 
  -    // duplicates, so it's better for us to eliminate this case so we don't 
  -    // have to check for duplicates during runtime if we're using a 
  -    // WalkingIterator.
  -    if(isSet(analysis, BIT_FOLLOWING | BIT_FOLLOWING_SIBLING) && 
  -       isSet(analysis, BIT_PRECEDING | BIT_PRECEDING_SIBLING))
  -      return  false;
  -      
  -    // OK, now we have to check for select="@*/axis::*" patterns, which 
  -    // can also cause duplicates to happen.  But select="axis*/@::*" patterns 
  -    // are OK, as are select="@foo/axis::*" patterns.
  -    // Unfortunately, we can't do this just via the analysis bits.
  -    
  -    int stepType;
  -    int ops[] = compiler.getOpMap();
  -    int stepCount = 0;
  -    boolean foundWildAttribute = false;
  -    
  -    // Steps that can traverse anything other than down a 
  -    // subtree or that can produce duplicates when used in 
  -    // combonation are counted with this variable.
  -    int potentialDuplicateMakingStepCount = 0;
  -    
  -    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  -    {        
  -      stepCount++;
  -        
  -      switch (stepType)
  -      {
  -      case OpCodes.FROM_ATTRIBUTES :
  -      case OpCodes.MATCH_ATTRIBUTE :
  -        if(foundWildAttribute) // Maybe not needed, but be safe.
  -          return false;
  -        
  -        // This doesn't seem to work as a test for wild card.  Hmph.
  -        // int nodeTestType = compiler.getStepTestType(stepOpCodePos);  
  -        
  -        String localName = compiler.getStepLocalName(stepOpCodePos);
  -        // System.err.println("localName: "+localName);
  -        if(localName.equals("*"))
  -        {
  -          foundWildAttribute = true;
  -        }
  -        break;
  -      case OpCodes.FROM_FOLLOWING :
  -      case OpCodes.FROM_FOLLOWING_SIBLINGS :
  -      case OpCodes.FROM_PRECEDING :
  -      case OpCodes.FROM_PRECEDING_SIBLINGS :
  -      case OpCodes.FROM_PARENT :
  -      case OpCodes.OP_VARIABLE :
  -      case OpCodes.OP_EXTFUNCTION :
  -      case OpCodes.OP_FUNCTION :
  -      case OpCodes.OP_GROUP :
  -      case OpCodes.FROM_NAMESPACE :
  -      case OpCodes.FROM_ANCESTORS :
  -      case OpCodes.FROM_ANCESTORS_OR_SELF :      
  -      case OpCodes.MATCH_ANY_ANCESTOR :
  -      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
  -      case OpCodes.FROM_DESCENDANTS_OR_SELF :
  -      case OpCodes.FROM_DESCENDANTS :
  -        if(potentialDuplicateMakingStepCount > 0)
  -            return false;
  -        potentialDuplicateMakingStepCount++;
  -      case OpCodes.FROM_ROOT :
  -      case OpCodes.FROM_CHILDREN :
  -      case OpCodes.FROM_SELF :
  -        if(foundWildAttribute)
  -          return false;
  -        break;
  -      default :
  -        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  -                                  // + stepType);
  -      }
  -
  -      int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  -
  -      if (nextStepOpCodePos < 0)
  -        break;
  -              
  -      stepOpCodePos = nextStepOpCodePos;
  -    }
  -
  -    return true;
  -  }
  -  
  -  public static boolean isOneStep(int analysis)
  -  {
  -    return (analysis & BITS_COUNT) == 0x00000001;
  -  }
  -
  -  public static int getStepCount(int analysis)
  -  {
  -    return (analysis & BITS_COUNT);
  -  }
  -
  -  /**
  -   * First 8 bits are the number of top-level location steps.  Hopefully
  -   *  there will never be more that 255 location steps!!!
  -   */
  -  public static final int BITS_COUNT = 0x000000FF;
  -
  -  /** 4 bits are reserved for future use. */
  -  public static final int BITS_RESERVED = 0x00000F00;
  -
  -  /** Bit is on if the expression contains a top-level predicate. */
  -  public static final int BIT_PREDICATE = (0x00001000);
  -
  -  /** Bit is on if any of the walkers contain an ancestor step. */
  -  public static final int BIT_ANCESTOR = (0x00001000 << 1);
  -
  -  /** Bit is on if any of the walkers contain an ancestor-or-self step. */
  -  public static final int BIT_ANCESTOR_OR_SELF = (0x00001000 << 2);
  -
  -  /** Bit is on if any of the walkers contain an attribute step. */
  -  public static final int BIT_ATTRIBUTE = (0x00001000 << 3);
  -
  -  /** Bit is on if any of the walkers contain a child step. */
  -  public static final int BIT_CHILD = (0x00001000 << 4);
  -
  -  /** Bit is on if any of the walkers contain a descendant step. */
  -  public static final int BIT_DESCENDANT = (0x00001000 << 5);
  -
  -  /** Bit is on if any of the walkers contain a descendant-or-self step. */
  -  public static final int BIT_DESCENDANT_OR_SELF = (0x00001000 << 6);
  -
  -  /** Bit is on if any of the walkers contain a following step. */
  -  public static final int BIT_FOLLOWING = (0x00001000 << 7);
  -
  -  /** Bit is on if any of the walkers contain a following-sibiling step. */
  -  public static final int BIT_FOLLOWING_SIBLING = (0x00001000 << 8);
  -
  -  /** Bit is on if any of the walkers contain a namespace step. */
  -  public static final int BIT_NAMESPACE = (0x00001000 << 9);
  -
  -  /** Bit is on if any of the walkers contain a parent step. */
  -  public static final int BIT_PARENT = (0x00001000 << 10);
  -
  -  /** Bit is on if any of the walkers contain a preceding step. */
  -  public static final int BIT_PRECEDING = (0x00001000 << 11);
  -
  -  /** Bit is on if any of the walkers contain a preceding-sibling step. */
  -  public static final int BIT_PRECEDING_SIBLING = (0x00001000 << 12);
  -
  -  /** Bit is on if any of the walkers contain a self step. */
  -  public static final int BIT_SELF = (0x00001000 << 13);
  -
  -  /**
  -   * Bit is on if any of the walkers contain a filter (i.e. id(), extension
  -   *  function, etc.) step.
  -   */
  -  public static final int BIT_FILTER = (0x00001000 << 14);
  -
  -  /** Bit is on if any of the walkers contain a root step. */
  -  public static final int BIT_ROOT = (0x00001000 << 15);
  -
  -  /**
  -   * If any of these bits are on, the expression may likely traverse outside
  -   *  the given subtree.
  -   */
  -  public static final int BITMASK_TRAVERSES_OUTSIDE_SUBTREE = (BIT_NAMESPACE  // ??
  -                                                                | BIT_PRECEDING_SIBLING
  -                                                                | BIT_PRECEDING
  -                                                                | BIT_FOLLOWING_SIBLING
  -                                                                | BIT_FOLLOWING
  -                                                                | BIT_PARENT  // except parent of attrs.
  -                                                                | BIT_ANCESTOR_OR_SELF
  -                                                                | BIT_ANCESTOR
  -                                                                | BIT_FILTER
  -                                                                | BIT_ROOT);
  -
  -  /**
  -   * Bit is on if any of the walkers can go backwards in document
  -   *  order from the context node.
  -   */
  -  public static final int BIT_BACKWARDS_SELF = (0x00001000 << 16);
  -
  -  /** Found "//foo" pattern */
  -  public static final int BIT_ANY_DESCENDANT_FROM_ROOT = (0x00001000 << 17);
  -
  -  /**
  -   * Bit is on if any of the walkers contain an node() test.  This is
  -   *  really only useful if the count is 1.
  -   */
  -  public static final int BIT_NODETEST_ANY = (0x00001000 << 18);
  -
  -  // can't go higher than 18!
  -
  -  /** Bit is on if the expression is a match pattern. */
  -  public static final int BIT_MATCH_PATTERN = (0x00001000 << 19);
  -}
  +//import org.apache.xpath.compiler.OpCodes;
  +//import org.apache.xpath.compiler.Compiler;
  +//import org.apache.xpath.compiler.FunctionTable;
  +//import org.apache.xpath.patterns.NodeTest;
  +//import org.apache.xpath.patterns.StepPattern;
  +//import org.apache.xpath.patterns.ContextMatchStepPattern;
  +//import org.apache.xpath.patterns.FunctionPattern;
  +//import org.apache.xpath.Expression;
  +//import org.apache.xpath.objects.XNumber;
  +//import org.apache.xalan.res.XSLMessages;
  +//import org.apache.xpath.res.XPATHErrorResources;
  +//
  +//import org.apache.xml.dtm.DTMFilter;
  +//import org.apache.xml.dtm.DTMIterator;
  +//import org.apache.xml.dtm.Axis;
  +//
  +///**
  +// * This class is both a factory for XPath location path expressions,
  +// * which are built from the opcode map output, and an analysis engine
  +// * for the location path expressions in order to provide optimization hints.
  +// */
  +//public class WalkerFactory
  +//{
  +//
  +//  /**
  +//   * <meta name="usage" content="advanced"/>
  +//   * This method is for building an array of possible levels
  +//   * where the target element(s) could be found for a match.
  +//   * @param xpath The xpath that is executing.
  +//   * @param context The current source tree context node.
  +//   *
  +//   * @param lpi The owning location path iterator.
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param stepOpCodePos The opcode position for the step.
  +//   *
  +//   * @return non-null AxesWalker derivative.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  static AxesWalker loadOneWalker(
  +//          WalkingIterator lpi, Compiler compiler, int stepOpCodePos)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    AxesWalker firstWalker = null;
  +//    int stepType = compiler.getOpMap()[stepOpCodePos];
  +//
  +//    if (stepType != OpCodes.ENDOP)
  +//    {
  +//
  +//      // m_axesWalkers = new AxesWalker[1];
  +//      // As we unwind from the recursion, create the iterators.
  +//      firstWalker = createDefaultWalker(compiler, stepType, lpi, 0);
  +//
  +//      firstWalker.init(compiler, stepOpCodePos, stepType);
  +//    }
  +//
  +//    return firstWalker;
  +//  }
  +//
  +//  /**
  +//   * <meta name="usage" content="advanced"/>
  +//   * This method is for building an array of possible levels
  +//   * where the target element(s) could be found for a match.
  +//   * @param xpath The xpath that is executing.
  +//   * @param context The current source tree context node.
  +//   *
  +//   * @param lpi The owning location path iterator object.
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param stepOpCodePos The opcode position for the step.
  +//   * @param stepIndex The top-level step index withing the iterator.
  +//   *
  +//   * @return non-null AxesWalker derivative.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  static AxesWalker loadWalkers(
  +//          WalkingIterator lpi, Compiler compiler, int stepOpCodePos, int stepIndex)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    int stepType;
  +//    AxesWalker firstWalker = null;
  +//    AxesWalker walker, prevWalker = null;
  +//    int ops[] = compiler.getOpMap();
  +//    int analysis = analyze(compiler, stepOpCodePos, stepIndex);
  +//
  +//    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  +//    {
  +//      walker = createDefaultWalker(compiler, stepOpCodePos, lpi, analysis);
  +//
  +//      walker.init(compiler, stepOpCodePos, stepType);
  +//      walker.exprSetParent(lpi);
  +//
  +//      // walker.setAnalysis(analysis);
  +//      if (null == firstWalker)
  +//      {
  +//        firstWalker = walker;
  +//      }
  +//      else
  +//      {
  +//        prevWalker.setNextWalker(walker);
  +//        walker.setPrevWalker(prevWalker);
  +//      }
  +//
  +//      prevWalker = walker;
  +//      stepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  +//
  +//      if (stepOpCodePos < 0)
  +//        break;
  +//    }
  +//
  +//    return firstWalker;
  +//  }
  +//  
  +//  public static boolean isSet(int analysis, int bits)
  +//  {
  +//    return (0 != (analysis & bits));
  +//  }
  +//  
  +//  public static void diagnoseIterator(String name, int analysis, Compiler compiler)
  +//  {
  +//    System.out.println(compiler.toString()+", "+name+", "
  +//                             + Integer.toBinaryString(analysis) + ", "
  +//                             + getAnalysisString(analysis));
  +//  }
  +//
  +//  /**
  +//   * Create a new LocPathIterator iterator.  The exact type of iterator
  +//   * returned is based on an analysis of the XPath operations.
  +//   *
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param opPos The position of the operation code for this itterator.
  +//   *
  +//   * @return non-null reference to a LocPathIterator or derivative.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  public static DTMIterator newDTMIterator(
  +//          Compiler compiler, int opPos,
  +//          boolean isTopLevel)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    int firstStepPos = compiler.getFirstChildPos(opPos);
  +//    int analysis = analyze(compiler, firstStepPos, 0);
  +//    boolean isOneStep = isOneStep(analysis);
  +//    DTMIterator iter;
  +//
  +//    // Is the iteration a one-step attribute pattern (i.e. select="@foo")?
  +//    if (isOneStep && walksSelfOnly(analysis) && 
  +//        isWild(analysis) && !hasPredicate(analysis))
  +//    {
  +//      if (DEBUG_ITERATOR_CREATION)
  +//        diagnoseIterator("SelfIteratorNoPredicate", analysis, compiler);
  +//
  +//      // Then use a simple iteration of the attributes, with node test 
  +//      // and predicate testing.
  +//      iter = new SelfIteratorNoPredicate(compiler, opPos, analysis);
  +//    }
  +//    // Is the iteration exactly one child step?
  +//    else if (walksChildrenOnly(analysis) && isOneStep)
  +//    {
  +//
  +//      // Does the pattern specify *any* child with no predicate? (i.e. select="child::node()".
  +//      if (isWild(analysis) && !hasPredicate(analysis))
  +//      {
  +//        if (DEBUG_ITERATOR_CREATION)
  +//          diagnoseIterator("ChildIterator", analysis, compiler);
  +//
  +//        // Use simple child iteration without any test.
  +//        iter = new ChildIterator(compiler, opPos, analysis);
  +//      }
  +//      else
  +//      {
  +//        if (DEBUG_ITERATOR_CREATION)
  +//          diagnoseIterator("ChildTestIterator", analysis, compiler);
  +//
  +//        // Else use simple node test iteration with predicate test.
  +//        iter = new ChildTestIterator(compiler, opPos, analysis);
  +//      }
  +//    }
  +//    // Is the iteration a one-step attribute pattern (i.e. select="@foo")?
  +//    else if (isOneStep && walksAttributes(analysis))
  +//    {
  +//      if (DEBUG_ITERATOR_CREATION)
  +//        diagnoseIterator("AttributeIterator", analysis, compiler);
  +//
  +//      // Then use a simple iteration of the attributes, with node test 
  +//      // and predicate testing.
  +//      iter = new AttributeIterator(compiler, opPos, analysis);
  +//    }
  +//    else if(isOneStep && !walksFilteredList(analysis))
  +//    {
  +//      if( !walksNamespaces(analysis) 
  +//      && (walksInDocOrder(analysis) || isSet(analysis, BIT_PARENT)))
  +//      {
  +//        if (false || DEBUG_ITERATOR_CREATION)
  +//          diagnoseIterator("OneStepIteratorForward", analysis, compiler);
  +//  
  +//        // Then use a simple iteration of the attributes, with node test 
  +//        // and predicate testing.
  +//        iter = new OneStepIteratorForward(compiler, opPos, analysis);
  +//      }
  +//      else
  +//      {
  +//        if (false || DEBUG_ITERATOR_CREATION)
  +//          diagnoseIterator("OneStepIterator", analysis, compiler);
  +//  
  +//        // Then use a simple iteration of the attributes, with node test 
  +//        // and predicate testing.
  +//        iter = new OneStepIterator(compiler, opPos, analysis);
  +//      }
  +//    }
  +//
  +//    // Analysis of "//center":
  +//    // bits: 1001000000001010000000000000011
  +//    // count: 3
  +//    // root
  +//    // child:node()
  +//    // BIT_DESCENDANT_OR_SELF
  +//    // It's highly possible that we should have a seperate bit set for 
  +//    // "//foo" patterns.
  +//    // For at least the time being, we can't optimize patterns like 
  +//    // "//table[3]", because this has to be analyzed as 
  +//    // "/descendant-or-self::node()/table[3]" in order for the indexes 
  +//    // to work right.
  +//    else if (isOptimizableForDescendantIterator(compiler, firstStepPos, 0)
  +//              // && getStepCount(analysis) <= 3 
  +//              // && walksDescendants(analysis) 
  +//              // && walksSubtreeOnlyFromRootOrContext(analysis)
  +//             )
  +//    {
  +//      if (DEBUG_ITERATOR_CREATION)
  +//        diagnoseIterator("DescendantIterator", analysis, compiler);
  +//
  +//      iter = new DescendantIterator(compiler, opPos, analysis);
  +//    }
  +//    else
  +//    { 
  +//      if(isNaturalDocOrder(compiler, firstStepPos, 0, analysis))
  +//      {
  +//        if (false || DEBUG_ITERATOR_CREATION)
  +//        {
  +//          diagnoseIterator("WalkingIterator", analysis, compiler);
  +//        }
  +//  
  +//        iter = new WalkingIterator(compiler, opPos, analysis, true);
  +//      }
  +//      else
  +//      {
  +////        if (DEBUG_ITERATOR_CREATION)
  +////          diagnoseIterator("MatchPatternIterator", analysis, compiler);
  +////
  +////        return new MatchPatternIterator(compiler, opPos, analysis);
  +//        if (DEBUG_ITERATOR_CREATION)
  +//          diagnoseIterator("WalkingIteratorSorted", analysis, compiler);
  +//
  +//        iter = new WalkingIteratorSorted(compiler, opPos, analysis, true);
  +//      }
  +//    }
  +//    if(iter instanceof LocPathIterator)
  +//      ((LocPathIterator)iter).setIsTopLevel(isTopLevel);
  +//      
  +//    return iter;
  +//  }
  +//  
  +//  /**
  +//   * Special purpose function to see if we can optimize the pattern for 
  +//   * a DescendantIterator.
  +//   *
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param stepOpCodePos The opcode position for the step.
  +//   * @param stepIndex The top-level step index withing the iterator.
  +//   *
  +//   * @return 32 bits as an integer that give information about the location
  +//   * path as a whole.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  public static int getAxisFromStep(
  +//          Compiler compiler, int stepOpCodePos)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    int ops[] = compiler.getOpMap();
  +//    int stepType = ops[stepOpCodePos];
  +//
  +//    switch (stepType)
  +//    {
  +//    case OpCodes.FROM_FOLLOWING :
  +//      return Axis.FOLLOWING;
  +//    case OpCodes.FROM_FOLLOWING_SIBLINGS :
  +//      return Axis.FOLLOWINGSIBLING;
  +//    case OpCodes.FROM_PRECEDING :
  +//      return Axis.PRECEDING;
  +//    case OpCodes.FROM_PRECEDING_SIBLINGS :
  +//      return Axis.PRECEDINGSIBLING;
  +//    case OpCodes.FROM_PARENT :
  +//      return Axis.PARENT;
  +//    case OpCodes.FROM_NAMESPACE :
  +//      return Axis.NAMESPACE;
  +//    case OpCodes.FROM_ANCESTORS :
  +//      return Axis.ANCESTOR;
  +//    case OpCodes.FROM_ANCESTORS_OR_SELF :
  +//      return Axis.ANCESTORORSELF;
  +//    case OpCodes.FROM_ATTRIBUTES :
  +//      return Axis.ATTRIBUTE;
  +//    case OpCodes.FROM_ROOT :
  +//      return Axis.ROOT;
  +//    case OpCodes.FROM_CHILDREN :
  +//      return Axis.CHILD;
  +//    case OpCodes.FROM_DESCENDANTS_OR_SELF :
  +//      return Axis.DESCENDANTORSELF;
  +//    case OpCodes.FROM_DESCENDANTS :
  +//      return Axis.DESCENDANT;
  +//    case OpCodes.FROM_SELF :
  +//      return Axis.SELF;
  +//    case OpCodes.OP_EXTFUNCTION :
  +//    case OpCodes.OP_FUNCTION :
  +//    case OpCodes.OP_GROUP :
  +//    case OpCodes.OP_VARIABLE :
  +//      return Axis.FILTEREDLIST;
  +//    }
  +//
  +//    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  +//                               //+ stepType);
  +//   }
  +//    
  +//    /**
  +//     * Get a corresponding BIT_XXX from an axis.
  +//     * @param axis One of Axis.ANCESTOR, etc.
  +//     * @return One of BIT_ANCESTOR, etc.
  +//     */
  +//    static public int getAnalysisBitFromAxes(int axis)
  +//    {
  +//      switch (axis) // Generate new traverser
  +//        {
  +//        case Axis.ANCESTOR :
  +//          return BIT_ANCESTOR;
  +//        case Axis.ANCESTORORSELF :
  +//          return BIT_ANCESTOR_OR_SELF;
  +//        case Axis.ATTRIBUTE :
  +//          return BIT_ATTRIBUTE;
  +//        case Axis.CHILD :
  +//          return BIT_CHILD;
  +//        case Axis.DESCENDANT :
  +//          return BIT_DESCENDANT;
  +//        case Axis.DESCENDANTORSELF :
  +//          return BIT_DESCENDANT_OR_SELF;
  +//        case Axis.FOLLOWING :
  +//          return BIT_FOLLOWING;
  +//        case Axis.FOLLOWINGSIBLING :
  +//          return BIT_FOLLOWING_SIBLING;
  +//        case Axis.NAMESPACE :
  +//        case Axis.NAMESPACEDECLS :
  +//          return BIT_NAMESPACE;
  +//        case Axis.PARENT :
  +//          return BIT_PARENT;
  +//        case Axis.PRECEDING :
  +//          return BIT_PRECEDING;
  +//        case Axis.PRECEDINGSIBLING :
  +//          return BIT_PRECEDING_SIBLING;
  +//        case Axis.SELF :
  +//          return BIT_SELF;
  +//        case Axis.ALLFROMNODE :
  +//          return BIT_DESCENDANT_OR_SELF;
  +//          // case Axis.PRECEDINGANDANCESTOR :
  +//        case Axis.DESCENDANTSFROMROOT :
  +//        case Axis.ALL :
  +//        case Axis.DESCENDANTSORSELFFROMROOT :
  +//          return BIT_ANY_DESCENDANT_FROM_ROOT;
  +//        case Axis.ROOT :
  +//          return BIT_ROOT;
  +//        case Axis.FILTEREDLIST :
  +//          return BIT_FILTER;
  +//        default :
  +//          return BIT_FILTER;
  +//      }
  +//    }
  +//  
  +//  static boolean functionProximateOrContainsProximate(Compiler compiler, 
  +//                                                      int opPos)
  +//  {
  +//    int endFunc = opPos + compiler.getOp(opPos + 1) - 1;
  +//    opPos = compiler.getFirstChildPos(opPos);
  +//    int funcID = compiler.getOp(opPos);
  +//    //  System.out.println("funcID: "+funcID);
  +//    //  System.out.println("opPos: "+opPos);
  +//    //  System.out.println("endFunc: "+endFunc);
  +//    switch(funcID)
  +//    {
  +//      case FunctionTable.FUNC_LAST:
  +//      case FunctionTable.FUNC_POSITION:
  +//        return true;
  +//      default:
  +//        opPos++;
  +//        int i = 0;
  +//        for (int p = opPos; p < endFunc; p = compiler.getNextOpPos(p), i++)
  +//        {
  +//          int innerExprOpPos = p+2;
  +//          int argOp = compiler.getOp(innerExprOpPos);
  +//          boolean prox = isProximateInnerExpr(compiler, innerExprOpPos);
  +//          if(prox)
  +//            return true;
  +//        }
  +//
  +//    }
  +//    return false;
  +//  }
  +//  
  +//  static boolean isProximateInnerExpr(Compiler compiler, int opPos)
  +//  {
  +//    int op = compiler.getOp(opPos);
  +//    int innerExprOpPos = opPos+2;
  +//    switch(op)
  +//    {
  +//      case OpCodes.OP_ARGUMENT:
  +//        if(isProximateInnerExpr(compiler, innerExprOpPos))
  +//          return true;
  +//        break;
  +//      case OpCodes.OP_VARIABLE:
  +//      case OpCodes.OP_NUMBERLIT:
  +//      case OpCodes.OP_LITERAL:
  +//      case OpCodes.OP_LOCATIONPATH:
  +//        break; // OK
  +//      case OpCodes.OP_FUNCTION:
  +//        boolean isProx = functionProximateOrContainsProximate(compiler, opPos);
  +//        if(isProx)
  +//          return true;
  +//        break;
  +//      case OpCodes.OP_GT:
  +//      case OpCodes.OP_GTE:
  +//      case OpCodes.OP_LT:
  +//      case OpCodes.OP_LTE:
  +//      case OpCodes.OP_EQUALS:
  +//        int leftPos = compiler.getFirstChildPos(op);
  +//        int rightPos = compiler.getNextOpPos(leftPos);
  +//        isProx = isProximateInnerExpr(compiler, leftPos);
  +//        if(isProx)
  +//          return true;
  +//        isProx = isProximateInnerExpr(compiler, rightPos);
  +//        if(isProx)
  +//          return true;
  +//        break;
  +//      default:
  +//        return true; // be conservative...
  +//    }
  +//    return false;
  +//  }
  +//    
  +//  /**
  +//   * Tell if the predicates need to have proximity knowledge.
  +//   */
  +//  public static boolean mightBeProximate(Compiler compiler, int opPos, int stepType)
  +//          throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    boolean mightBeProximate = false;
  +//    int argLen;
  +//
  +//    switch (stepType)
  +//    {
  +//    case OpCodes.OP_VARIABLE :
  +//    case OpCodes.OP_EXTFUNCTION :
  +//    case OpCodes.OP_FUNCTION :
  +//    case OpCodes.OP_GROUP :
  +//      argLen = compiler.getArgLength(opPos);
  +//      break;
  +//    default :
  +//      argLen = compiler.getArgLengthOfStep(opPos);
  +//    }
  +//
  +//    int predPos = compiler.getFirstPredicateOpPos(opPos);
  +//    int count = 0;
  +//
  +//    while (OpCodes.OP_PREDICATE == compiler.getOp(predPos))
  +//    {
  +//      count++;
  +//      
  +//      int innerExprOpPos = predPos+2;
  +//      int predOp = compiler.getOp(innerExprOpPos);
  +//
  +//      switch(predOp)
  +//      {
  +//        case OpCodes.OP_VARIABLE:
  +//        	return true; // Would need more smarts to tell if this could be a number or not!
  +//        case OpCodes.OP_LOCATIONPATH:
  +//          // OK.
  +//          break;
  +//        case OpCodes.OP_NUMBER:
  +//        case OpCodes.OP_NUMBERLIT:
  +//          return true; // that's all she wrote!
  +//        case OpCodes.OP_FUNCTION:
  +//          boolean isProx 
  +//            = functionProximateOrContainsProximate(compiler, innerExprOpPos);
  +//          if(isProx)
  +//            return true;
  +//          break;
  +//        case OpCodes.OP_GT:
  +//        case OpCodes.OP_GTE:
  +//        case OpCodes.OP_LT:
  +//        case OpCodes.OP_LTE:
  +//        case OpCodes.OP_EQUALS:
  +//          int leftPos = compiler.getFirstChildPos(innerExprOpPos);
  +//          int rightPos = compiler.getNextOpPos(leftPos);
  +//          isProx = isProximateInnerExpr(compiler, leftPos);
  +//          if(isProx)
  +//            return true;
  +//          isProx = isProximateInnerExpr(compiler, rightPos);
  +//          if(isProx)
  +//            return true;
  +//          break;
  +//        default:
  +//          return true; // be conservative...
  +//      }
  +//
  +//      predPos = compiler.getNextOpPos(predPos);
  +//    }
  +//
  +//    return mightBeProximate;
  +//  }
  +//  
  +//  /**
  +//   * Special purpose function to see if we can optimize the pattern for 
  +//   * a DescendantIterator.
  +//   *
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param stepOpCodePos The opcode position for the step.
  +//   * @param stepIndex The top-level step index withing the iterator.
  +//   *
  +//   * @return 32 bits as an integer that give information about the location
  +//   * path as a whole.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  private static boolean isOptimizableForDescendantIterator(
  +//          Compiler compiler, int stepOpCodePos, int stepIndex)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    int stepType;
  +//    int ops[] = compiler.getOpMap();
  +//    int stepCount = 0;
  +//    boolean foundDorDS = false;
  +//    boolean foundSelf = false;
  +//    boolean foundDS = false;
  +//    
  +//    int nodeTestType = OpCodes.NODETYPE_NODE;
  +//    
  +//    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  +//    {
  +//      // The DescendantIterator can only do one node test.  If there's more 
  +//      // than one, use another iterator.
  +//      if(nodeTestType != OpCodes.NODETYPE_NODE && nodeTestType != OpCodes.NODETYPE_ROOT)
  +//        return false;
  +//        
  +//      stepCount++;
  +//      if(stepCount > 3)
  +//        return false;
  +//        
  +//      boolean mightBeProximate = mightBeProximate(compiler, stepOpCodePos, stepType);
  +//      if(mightBeProximate)
  +//        return false;
  +//
  +//      switch (stepType)
  +//      {
  +//      case OpCodes.FROM_FOLLOWING :
  +//      case OpCodes.FROM_FOLLOWING_SIBLINGS :
  +//      case OpCodes.FROM_PRECEDING :
  +//      case OpCodes.FROM_PRECEDING_SIBLINGS :
  +//      case OpCodes.FROM_PARENT :
  +//      case OpCodes.OP_VARIABLE :
  +//      case OpCodes.OP_EXTFUNCTION :
  +//      case OpCodes.OP_FUNCTION :
  +//      case OpCodes.OP_GROUP :
  +//      case OpCodes.FROM_NAMESPACE :
  +//      case OpCodes.FROM_ANCESTORS :
  +//      case OpCodes.FROM_ANCESTORS_OR_SELF :
  +//      case OpCodes.FROM_ATTRIBUTES :
  +//      case OpCodes.MATCH_ATTRIBUTE :
  +//      case OpCodes.MATCH_ANY_ANCESTOR :
  +//      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
  +//        return false;
  +//      case OpCodes.FROM_ROOT :
  +//        if(1 != stepCount)
  +//          return false;
  +//        break;
  +//      case OpCodes.FROM_CHILDREN :
  +//        if(!foundDS && !(foundDorDS && foundSelf))
  +//          return false;
  +//        break;
  +//      case OpCodes.FROM_DESCENDANTS_OR_SELF :
  +//        foundDS = true;
  +//      case OpCodes.FROM_DESCENDANTS :
  +//        if(3 == stepCount)
  +//          return false;
  +//        foundDorDS = true;
  +//        break;
  +//      case OpCodes.FROM_SELF :
  +//        if(1 != stepCount)
  +//          return false;
  +//        foundSelf = true;
  +//        break;
  +//      default :
  +//        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  +//                                  // + stepType);
  +//      }
  +//      
  +//      nodeTestType = compiler.getStepTestType(stepOpCodePos);
  +//
  +//      int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  +//
  +//      if (nextStepOpCodePos < 0)
  +//        break;
  +//        
  +//      if(OpCodes.ENDOP != ops[nextStepOpCodePos])
  +//      {
  +//        if(compiler.countPredicates(stepOpCodePos) > 0)
  +//        {
  +//          return false;
  +//        }
  +//      }
  +//      
  +//      stepOpCodePos = nextStepOpCodePos;
  +//    }
  +//
  +//    return true;
  +//  }
  +//
  +//  /**
  +//   * Analyze the location path and return 32 bits that give information about
  +//   * the location path as a whole.  See the BIT_XXX constants for meaning about
  +//   * each of the bits.
  +//   *
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param stepOpCodePos The opcode position for the step.
  +//   * @param stepIndex The top-level step index withing the iterator.
  +//   *
  +//   * @return 32 bits as an integer that give information about the location
  +//   * path as a whole.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  private static int analyze(
  +//          Compiler compiler, int stepOpCodePos, int stepIndex)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    int stepType;
  +//    int ops[] = compiler.getOpMap();
  +//    int stepCount = 0;
  +//    int analysisResult = 0x00000000;  // 32 bits of analysis
  +//
  +//    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  +//    {
  +//      stepCount++;
  +//
  +//      // String namespace = compiler.getStepNS(stepOpCodePos);
  +//      // boolean isNSWild = (null != namespace) 
  +//      //                   ? namespace.equals(NodeTest.WILD) : false;
  +//      // String localname = compiler.getStepLocalName(stepOpCodePos);
  +//      // boolean isWild = (null != localname) ? localname.equals(NodeTest.WILD) : false;
  +//      boolean predAnalysis = analyzePredicate(compiler, stepOpCodePos,
  +//                                              stepType);
  +//
  +//      if (predAnalysis)
  +//        analysisResult |= BIT_PREDICATE;
  +//
  +//      switch (stepType)
  +//      {
  +//      case OpCodes.OP_VARIABLE :
  +//      case OpCodes.OP_EXTFUNCTION :
  +//      case OpCodes.OP_FUNCTION :
  +//      case OpCodes.OP_GROUP :
  +//        analysisResult |= BIT_FILTER;
  +//        break;
  +//      case OpCodes.FROM_ROOT :
  +//        analysisResult |= BIT_ROOT;
  +//        break;
  +//      case OpCodes.FROM_ANCESTORS :
  +//        analysisResult |= BIT_ANCESTOR;
  +//        break;
  +//      case OpCodes.FROM_ANCESTORS_OR_SELF :
  +//        analysisResult |= BIT_ANCESTOR_OR_SELF;
  +//        break;
  +//      case OpCodes.FROM_ATTRIBUTES :
  +//        analysisResult |= BIT_ATTRIBUTE;
  +//        break;
  +//      case OpCodes.FROM_NAMESPACE :
  +//        analysisResult |= BIT_NAMESPACE;
  +//        break;
  +//      case OpCodes.FROM_CHILDREN :
  +//        analysisResult |= BIT_CHILD;
  +//        break;
  +//      case OpCodes.FROM_DESCENDANTS :
  +//        analysisResult |= BIT_DESCENDANT;
  +//        break;
  +//      case OpCodes.FROM_DESCENDANTS_OR_SELF :
  +//
  +//        // Use a special bit to to make sure we get the right analysis of "//foo".
  +//        if (2 == stepCount && BIT_ROOT == analysisResult)
  +//        {
  +//          analysisResult |= BIT_ANY_DESCENDANT_FROM_ROOT;
  +//        }
  +//
  +//        analysisResult |= BIT_DESCENDANT_OR_SELF;
  +//        break;
  +//      case OpCodes.FROM_FOLLOWING :
  +//        analysisResult |= BIT_FOLLOWING;
  +//        break;
  +//      case OpCodes.FROM_FOLLOWING_SIBLINGS :
  +//        analysisResult |= BIT_FOLLOWING_SIBLING;
  +//        break;
  +//      case OpCodes.FROM_PRECEDING :
  +//        analysisResult |= BIT_PRECEDING;
  +//        break;
  +//      case OpCodes.FROM_PRECEDING_SIBLINGS :
  +//        analysisResult |= BIT_PRECEDING_SIBLING;
  +//        break;
  +//      case OpCodes.FROM_PARENT :
  +//        analysisResult |= BIT_PARENT;
  +//        break;
  +//      case OpCodes.FROM_SELF :
  +//        analysisResult |= BIT_SELF;
  +//        break;
  +//      case OpCodes.MATCH_ATTRIBUTE :
  +//        analysisResult |= (BIT_MATCH_PATTERN | BIT_ATTRIBUTE);
  +//        break;
  +//      case OpCodes.MATCH_ANY_ANCESTOR :
  +//        analysisResult |= (BIT_MATCH_PATTERN | BIT_ANCESTOR);
  +//        break;
  +//      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
  +//        analysisResult |= (BIT_MATCH_PATTERN | BIT_PARENT);
  +//        break;
  +//      default :
  +//        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  +//                                   //+ stepType);
  +//      }
  +//
  +//      if (OpCodes.NODETYPE_NODE == ops[stepOpCodePos + 3])  // child::node()
  +//      {
  +//        analysisResult |= BIT_NODETEST_ANY;
  +//      }
  +//
  +//      stepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  +//
  +//      if (stepOpCodePos < 0)
  +//        break;
  +//    }
  +//
  +//    analysisResult |= (stepCount & BITS_COUNT);
  +//
  +//    return analysisResult;
  +//  }
  +//  
  +//  /**
  +//   * Tell if the given axis goes downword.  Bogus name, if you can think of 
  +//   * a better one, please do tell.  This really has to do with inverting 
  +//   * attribute axis.
  +//   * @param axis One of Axis.XXX.
  +//   * @return true if the axis is not a child axis and does not go up from 
  +//   * the axis root.
  +//   */
  +//  public static boolean isDownwardAxisOfMany(int axis)
  +//  {
  +//    return ((Axis.DESCENDANTORSELF == axis) ||
  +//          (Axis.DESCENDANT == axis) 
  +//          || (Axis.FOLLOWING == axis) 
  +////          || (Axis.FOLLOWINGSIBLING == axis) 
  +//          || (Axis.PRECEDING == axis) 
  +////          || (Axis.PRECEDINGSIBLING == axis)
  +//          );
  +//  }
  +//
  +//  /**
  +//   * Read a <a href="http://www.w3.org/TR/xpath#location-paths">LocationPath</a>
  +//   * as a generalized match pattern.  What this means is that the LocationPath
  +//   * is read backwards, as a test on a given node, to see if it matches the
  +//   * criteria of the selection, and ends up at the context node.  Essentially,
  +//   * this is a backwards query from a given node, to find the context node.
  +//   * <p>So, the selection "foo/daz[2]" is, in non-abreviated expanded syntax,
  +//   * "self::node()/following-sibling::foo/child::daz[position()=2]".
  +//   * Taking this as a match pattern for a probable node, it works out to
  +//   * "self::daz/parent::foo[child::daz[position()=2 and isPrevStepNode()]
  +//   * precedingSibling::node()[isContextNodeOfLocationPath()]", adding magic
  +//   * isPrevStepNode and isContextNodeOfLocationPath operations.  Predicates in
  +//   * the location path have to be executed by the following step,
  +//   * because they have to know the context of their execution.
  +//   *
  +//   * @param mpi The MatchPatternIterator to which the steps will be attached.
  +//   * @param compiler The compiler that holds the syntax tree/op map to
  +//   * construct from.
  +//   * @param stepOpCodePos The current op code position within the opmap.
  +//   * @param stepIndex The top-level step index withing the iterator.
  +//   *
  +//   * @return A StepPattern object, which may contain relative StepPatterns.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  static StepPattern loadSteps(
  +//          MatchPatternIterator mpi, Compiler compiler, int stepOpCodePos, 
  +//                                                       int stepIndex)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//    if (DEBUG_PATTERN_CREATION)
  +//    {
  +//      System.out.println("================");
  +//      System.out.println("loadSteps for: "+compiler.getPatternString());
  +//    }
  +//    int stepType;
  +//    StepPattern step = null;
  +//    StepPattern firstStep = null, prevStep = null;
  +//    int ops[] = compiler.getOpMap();
  +//    int analysis = analyze(compiler, stepOpCodePos, stepIndex);
  +//
  +//    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  +//    {
  +//      step = createDefaultStepPattern(compiler, stepOpCodePos, mpi, analysis,
  +//                                      firstStep, prevStep);
  +//
  +//      if (null == firstStep)
  +//      {
  +//        firstStep = step;
  +//      }
  +//      else
  +//      {
  +//
  +//        //prevStep.setNextWalker(step);
  +//        step.setRelativePathPattern(prevStep);
  +//      }
  +//
  +//      prevStep = step;
  +//      stepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  +//
  +//      if (stepOpCodePos < 0)
  +//        break;
  +//    }
  +//    
  +//    int axis = Axis.SELF;
  +//    int paxis = Axis.SELF;
  +//    StepPattern tail = step;
  +//    for (StepPattern pat = step; null != pat; 
  +//         pat = pat.getRelativePathPattern()) 
  +//    {
  +//      int nextAxis = pat.getAxis();
  +//      //int nextPaxis = pat.getPredicateAxis();
  +//      pat.setAxis(axis);
  +//      
  +//      // The predicate axis can't be moved!!!  Test Axes103
  +//      // pat.setPredicateAxis(paxis);
  +//      
  +//      // If we have an attribute or namespace axis that went up, then 
  +//      // it won't find the attribute in the inverse, since the select-to-match
  +//      // axes are not invertable (an element is a parent of an attribute, but 
  +//      // and attribute is not a child of an element).
  +//      // If we don't do the magic below, then "@*/ancestor-or-self::*" gets
  +//      // inverted for match to "self::*/descendant-or-self::@*/parent::node()",
  +//      // which obviously won't work.
  +//      // So we will rewrite this as:
  +//      // "self::*/descendant-or-self::*/attribute::*/parent::node()"
  +//      // Child has to be rewritten a little differently:
  +//      // select: "@*/parent::*"
  +//      // inverted match: "self::*/child::@*/parent::node()"
  +//      // rewrite: "self::*/attribute::*/parent::node()"
  +//      // Axes that go down in the select, do not have to have special treatment 
  +//      // in the rewrite. The following inverted match will still not select 
  +//      // anything.
  +//      // select: "@*/child::*"
  +//      // inverted match: "self::*/parent::@*/parent::node()"
  +//      // Lovely business, this.
  +//      // -sb
  +//      int whatToShow = pat.getWhatToShow();
  +//      if(whatToShow == DTMFilter.SHOW_ATTRIBUTE || 
  +//         whatToShow == DTMFilter.SHOW_NAMESPACE)
  +//      {
  +//        int newAxis = (whatToShow == DTMFilter.SHOW_ATTRIBUTE) ? 
  +//                       Axis.ATTRIBUTE : Axis.NAMESPACE;
  +//        if(isDownwardAxisOfMany(axis))
  +//        {
  +//          StepPattern attrPat = new StepPattern(whatToShow, 
  +//                                    pat.getNamespace(),
  +//                                    pat.getLocalName(),
  +//                                //newAxis, pat.getPredicateAxis);
  +//                                                newAxis, 0); // don't care about the predicate axis
  +//          XNumber score = pat.getStaticScore();
  +//          pat.setNamespace(null);
  +//          pat.setLocalName(NodeTest.WILD);
  +//          attrPat.setPredicates(pat.getPredicates());
  +//          pat.setPredicates(null);
  +//          pat.setWhatToShow(DTMFilter.SHOW_ELEMENT);
  +//          StepPattern rel = pat.getRelativePathPattern();
  +//          pat.setRelativePathPattern(attrPat);
  +//          attrPat.setRelativePathPattern(rel);
  +//          attrPat.setStaticScore(score);
  +//          
  +//          // This is needed to inverse a following pattern, because of the 
  +//          // wacky Xalan rules for following from an attribute.  See axes108.
  +//          // By these rules, following from an attribute is not strictly 
  +//          // inverseable.
  +//          if(Axis.PRECEDING == pat.getAxis())
  +//            pat.setAxis(Axis.PRECEDINGANDANCESTOR);
  +//            
  +//          else if(Axis.DESCENDANT == pat.getAxis())
  +//            pat.setAxis(Axis.DESCENDANTORSELF);
  +//          
  +//          pat = attrPat;
  +//        }
  +//        else if(Axis.CHILD == pat.getAxis())
  +//        {
  +//          // In this case just change the axis.
  +//          // pat.setWhatToShow(whatToShow);
  +//          pat.setAxis(Axis.ATTRIBUTE);
  +//        }
  +//      }
  +//      axis = nextAxis;
  +//      //paxis = nextPaxis;
  +//      tail = pat;
  +//    }
  +//    
  +//    if(axis < Axis.ALL)
  +//    {
  +//      StepPattern selfPattern = new ContextMatchStepPattern(axis, paxis);
  +//      // We need to keep the new nodetest from affecting the score...
  +//      XNumber score = tail.getStaticScore();
  +//      tail.setRelativePathPattern(selfPattern);
  +//      tail.setStaticScore(score);
  +//      selfPattern.setStaticScore(score);
  +//    }        
  +//
  +//    if (DEBUG_PATTERN_CREATION)
  +//    {
  +//      System.out.println("Done loading steps: "+step.toString());
  +//            
  +//      System.out.println("");
  +//    }
  +//    return step;  // start from last pattern?? //firstStep;
  +//  }
  +//
  +//  /**
  +//   * Create a StepPattern that is contained within a LocationPath.
  +//   *
  +//   *
  +//   * @param compiler The compiler that holds the syntax tree/op map to
  +//   * construct from.
  +//   * @param stepOpCodePos The current op code position within the opmap.
  +//   * @param mpi The MatchPatternIterator to which the steps will be attached.
  +//   * @param analysis 32 bits of analysis, from which the type of AxesWalker
  +//   *                 may be influenced.
  +//   * @param tail The step that is the first step analyzed, but the last 
  +//   *                  step in the relative match linked list, i.e. the tail.
  +//   *                  May be null.
  +//   * @param head The step that is the current head of the relative 
  +//   *                 match step linked list.
  +//   *                 May be null.
  +//   *
  +//   * @return the head of the list.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  private static StepPattern createDefaultStepPattern(
  +//          Compiler compiler, int opPos, MatchPatternIterator mpi, 
  +//          int analysis, StepPattern tail, StepPattern head)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    int stepType = compiler.getOp(opPos);
  +//    boolean simpleInit = false;
  +//    int totalNumberWalkers = (analysis & BITS_COUNT);
  +//    boolean prevIsOneStepDown = true;
  +//    int firstStepPos = compiler.getFirstChildPos(opPos);
  +//    
  +//    int whatToShow = compiler.getWhatToShow(opPos);
  +//    StepPattern ai = null;
  +//    int axis, predicateAxis;
  +//    
  +//    switch (stepType)
  +//    {
  +//    case OpCodes.OP_VARIABLE :
  +//    case OpCodes.OP_EXTFUNCTION :
  +//    case OpCodes.OP_FUNCTION :
  +//    case OpCodes.OP_GROUP :
  +//      prevIsOneStepDown = false;
  +//
  +//      Expression expr;
  +//
  +//      switch (stepType)
  +//      {
  +//      case OpCodes.OP_VARIABLE :
  +//      case OpCodes.OP_EXTFUNCTION :
  +//      case OpCodes.OP_FUNCTION :
  +//      case OpCodes.OP_GROUP :
  +//        expr = compiler.compile(opPos);
  +//        break;
  +//      default :
  +//        expr = compiler.compile(opPos + 2);
  +//      }
  +//
  +//      axis = Axis.FILTEREDLIST;
  +//      predicateAxis = Axis.FILTEREDLIST;
  +//      ai = new FunctionPattern(expr, axis, predicateAxis);
  +//      simpleInit = true;
  +//      break;
  +//    case OpCodes.FROM_ROOT :
  +//      whatToShow = DTMFilter.SHOW_DOCUMENT
  +//                   | DTMFilter.SHOW_DOCUMENT_FRAGMENT;
  +//
  +//      axis = Axis.ROOT;
  +//      predicateAxis = Axis.ROOT;
  +//      ai = new StepPattern(DTMFilter.SHOW_DOCUMENT | 
  +//                                DTMFilter.SHOW_DOCUMENT_FRAGMENT,
  +//                                axis, predicateAxis);
  +//      break;
  +//    case OpCodes.FROM_ATTRIBUTES :
  +//      whatToShow = DTMFilter.SHOW_ATTRIBUTE;
  +//      axis = Axis.PARENT;
  +//      predicateAxis = Axis.ATTRIBUTE;
  +//      // ai = new StepPattern(whatToShow, Axis.SELF, Axis.SELF);
  +//      break;
  +//    case OpCodes.FROM_NAMESPACE :
  +//      whatToShow = DTMFilter.SHOW_NAMESPACE;
  +//      axis = Axis.PARENT;
  +//      predicateAxis = Axis.NAMESPACE;
  +//      // ai = new StepPattern(whatToShow, axis, predicateAxis);
  +//      break;
  +//    case OpCodes.FROM_ANCESTORS :
  +//      axis = Axis.DESCENDANT;
  +//      predicateAxis = Axis.ANCESTOR;
  +//      break;
  +//    case OpCodes.FROM_CHILDREN :
  +//      axis = Axis.PARENT;
  +//      predicateAxis = Axis.CHILD;
  +//      break;
  +//    case OpCodes.FROM_ANCESTORS_OR_SELF :
  +//      axis = Axis.DESCENDANTORSELF;
  +//      predicateAxis = Axis.ANCESTORORSELF;
  +//      break;
  +//    case OpCodes.FROM_SELF :
  +//      axis = Axis.SELF;
  +//      predicateAxis = Axis.SELF;
  +//      break;
  +//    case OpCodes.FROM_PARENT :
  +//      axis = Axis.CHILD;
  +//      predicateAxis = Axis.PARENT;
  +//      break;
  +//    case OpCodes.FROM_PRECEDING_SIBLINGS :
  +//      axis = Axis.FOLLOWINGSIBLING;
  +//      predicateAxis = Axis.PRECEDINGSIBLING;
  +//      break;
  +//    case OpCodes.FROM_PRECEDING :
  +//      axis = Axis.FOLLOWING;
  +//      predicateAxis = Axis.PRECEDING;
  +//      break;
  +//    case OpCodes.FROM_FOLLOWING_SIBLINGS :
  +//      axis = Axis.PRECEDINGSIBLING;
  +//      predicateAxis = Axis.FOLLOWINGSIBLING;
  +//      break;
  +//    case OpCodes.FROM_FOLLOWING :
  +//      axis = Axis.PRECEDING;
  +//      predicateAxis = Axis.FOLLOWING;
  +//      break;
  +//    case OpCodes.FROM_DESCENDANTS_OR_SELF :
  +//      axis = Axis.ANCESTORORSELF;
  +//      predicateAxis = Axis.DESCENDANTORSELF;
  +//      break;
  +//    case OpCodes.FROM_DESCENDANTS :
  +//      axis = Axis.ANCESTOR;
  +//      predicateAxis = Axis.DESCENDANT;
  +//      break;
  +//    default :
  +//      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  +//                                 //+ stepType);
  +//    }
  +//    if(null == ai)
  +//    {
  +//      whatToShow = compiler.getWhatToShow(opPos); // %REVIEW%
  +//      ai = new StepPattern(whatToShow, compiler.getStepNS(opPos),
  +//                                compiler.getStepLocalName(opPos),
  +//                                axis, predicateAxis);
  +//    }
  +//   
  +//    if (false || DEBUG_PATTERN_CREATION)
  +//    {
  +//      System.out.print("new step: "+ ai);
  +//      System.out.print(", axis: " + Axis.names[ai.getAxis()]);
  +//      System.out.print(", predAxis: " + Axis.names[ai.getAxis()]);
  +//      System.out.print(", what: ");
  +//      System.out.print("    ");
  +//      ai.debugWhatToShow(ai.getWhatToShow());
  +//    }
  +//
  +//    int argLen = compiler.getFirstPredicateOpPos(opPos);
  +//
  +//    ai.setPredicates(compiler.getCompiledPredicates(argLen));
  +//
  +//    return ai;
  +//  }
  +//
  +//  /**
  +//   * Analyze a step and give information about it's predicates.  Right now this
  +//   * just returns true or false if the step has a predicate.
  +//   *
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param opPos The opcode position for the step.
  +//   * @param stepType The type of step, one of OP_GROUP, etc.
  +//   *
  +//   * @return true if step has a predicate.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  static boolean analyzePredicate(Compiler compiler, int opPos, int stepType)
  +//          throws javax.xml.transform.TransformerException
  +//  {
  +//
  +//    int argLen;
  +//
  +//    switch (stepType)
  +//    {
  +//    case OpCodes.OP_VARIABLE :
  +//    case OpCodes.OP_EXTFUNCTION :
  +//    case OpCodes.OP_FUNCTION :
  +//    case OpCodes.OP_GROUP :
  +//      argLen = compiler.getArgLength(opPos);
  +//      break;
  +//    default :
  +//      argLen = compiler.getArgLengthOfStep(opPos);
  +//    }
  +//
  +//    int pos = compiler.getFirstPredicateOpPos(opPos);
  +//    int nPredicates = compiler.countPredicates(pos);
  +//
  +//    return (nPredicates > 0) ? true : false;
  +//  }
  +//
  +//  /**
  +//   * Create the proper Walker from the axes type.
  +//   *
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param opPos The opcode position for the step.
  +//   * @param lpi The owning location path iterator.
  +//   * @param analysis 32 bits of analysis, from which the type of AxesWalker
  +//   *                 may be influenced.
  +//   *
  +//   * @return non-null reference to AxesWalker derivative.
  +//   * @throws RuntimeException if the input is bad.
  +//   */
  +//  private static AxesWalker createDefaultWalker(Compiler compiler, int opPos,
  +//          WalkingIterator lpi, int analysis)
  +//  {
  +//
  +//    AxesWalker ai = null;
  +//    int stepType = compiler.getOp(opPos);
  +//
  +//    /*
  +//    System.out.println("0: "+compiler.getOp(opPos));
  +//    System.out.println("1: "+compiler.getOp(opPos+1));
  +//    System.out.println("2: "+compiler.getOp(opPos+2));
  +//    System.out.println("3: "+compiler.getOp(opPos+3));
  +//    System.out.println("4: "+compiler.getOp(opPos+4));
  +//    System.out.println("5: "+compiler.getOp(opPos+5));
  +//    */
  +//    boolean simpleInit = false;
  +//    int totalNumberWalkers = (analysis & BITS_COUNT);
  +//    boolean prevIsOneStepDown = true;
  +//
  +//    switch (stepType)
  +//    {
  +//    case OpCodes.OP_VARIABLE :
  +//    case OpCodes.OP_EXTFUNCTION :
  +//    case OpCodes.OP_FUNCTION :
  +//    case OpCodes.OP_GROUP :
  +//      prevIsOneStepDown = false;
  +//
  +//      if (DEBUG_WALKER_CREATION)
  +//        System.out.println("new walker:  FilterExprWalker: " + analysis
  +//                           + ", " + compiler.toString());
  +//
  +//      ai = new FilterExprWalker(lpi);
  +//      simpleInit = true;
  +//      break;
  +//    case OpCodes.FROM_ROOT :
  +//      ai = new AxesWalker(lpi, Axis.ROOT);
  +//      break;
  +//    case OpCodes.FROM_ANCESTORS :
  +//      prevIsOneStepDown = false;
  +//      ai = new ReverseAxesWalker(lpi, Axis.ANCESTOR);
  +//      break;
  +//    case OpCodes.FROM_ANCESTORS_OR_SELF :
  +//      prevIsOneStepDown = false;
  +//      ai = new ReverseAxesWalker(lpi, Axis.ANCESTORORSELF);
  +//      break;
  +//    case OpCodes.FROM_ATTRIBUTES :
  +//      ai = new AxesWalker(lpi, Axis.ATTRIBUTE);
  +//      break;
  +//    case OpCodes.FROM_NAMESPACE :
  +//      ai = new AxesWalker(lpi, Axis.NAMESPACE);
  +//      break;
  +//    case OpCodes.FROM_CHILDREN :
  +//      ai = new AxesWalker(lpi, Axis.CHILD);
  +//      break;
  +//    case OpCodes.FROM_DESCENDANTS :
  +//      prevIsOneStepDown = false;
  +//      ai = new AxesWalker(lpi, Axis.DESCENDANT);
  +//      break;
  +//    case OpCodes.FROM_DESCENDANTS_OR_SELF :
  +//      prevIsOneStepDown = false;
  +//      ai = new AxesWalker(lpi, Axis.DESCENDANTORSELF);
  +//      break;
  +//    case OpCodes.FROM_FOLLOWING :
  +//      prevIsOneStepDown = false;
  +//      ai = new AxesWalker(lpi, Axis.FOLLOWING);
  +//      break;
  +//    case OpCodes.FROM_FOLLOWING_SIBLINGS :
  +//      prevIsOneStepDown = false;
  +//      ai = new AxesWalker(lpi, Axis.FOLLOWINGSIBLING);
  +//      break;
  +//    case OpCodes.FROM_PRECEDING :
  +//      prevIsOneStepDown = false;
  +//      ai = new ReverseAxesWalker(lpi, Axis.PRECEDING);
  +//      break;
  +//    case OpCodes.FROM_PRECEDING_SIBLINGS :
  +//      prevIsOneStepDown = false;
  +//      ai = new ReverseAxesWalker(lpi, Axis.PRECEDINGSIBLING);
  +//      break;
  +//    case OpCodes.FROM_PARENT :
  +//      prevIsOneStepDown = false;
  +//      ai = new ReverseAxesWalker(lpi, Axis.PARENT);
  +//      break;
  +//    case OpCodes.FROM_SELF :
  +//      ai = new AxesWalker(lpi, Axis.SELF);
  +//      break;
  +//    default :
  +//      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  +//                                 //+ stepType);
  +//    }
  +//
  +//    if (simpleInit)
  +//    {
  +//      ai.initNodeTest(DTMFilter.SHOW_ALL);
  +//    }
  +//    else
  +//    {
  +//      int whatToShow = compiler.getWhatToShow(opPos);
  +//
  +//      /*
  +//      System.out.print("construct: ");
  +//      NodeTest.debugWhatToShow(whatToShow);
  +//      System.out.println("or stuff: "+(whatToShow & (DTMFilter.SHOW_ATTRIBUTE
  +//                             | DTMFilter.SHOW_ELEMENT
  +//                             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)));
  +//      */
  +//      if ((0 == (whatToShow
  +//                 & (DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_NAMESPACE | DTMFilter.SHOW_ELEMENT
  +//                    | DTMFilter.SHOW_PROCESSING_INSTRUCTION))) || (whatToShow == DTMFilter.SHOW_ALL))
  +//        ai.initNodeTest(whatToShow);
  +//      else
  +//      {
  +//        ai.initNodeTest(whatToShow, compiler.getStepNS(opPos),
  +//                        compiler.getStepLocalName(opPos));
  +//      }
  +//    }
  +//
  +//    return ai;
  +//  }
  +//  
  +//  public static String getAnalysisString(int analysis)
  +//  {
  +//    StringBuffer buf = new StringBuffer();
  +//    buf.append("count: "+getStepCount(analysis)+" ");
  +//    if((analysis & BIT_NODETEST_ANY) != 0)
  +//    {
  +//      buf.append("NTANY|");
  +//    }
  +//    if((analysis & BIT_PREDICATE) != 0)
  +//    {
  +//      buf.append("PRED|");
  +//    }
  +//    if((analysis & BIT_ANCESTOR) != 0)
  +//    {
  +//      buf.append("ANC|");
  +//    }
  +//    if((analysis & BIT_ANCESTOR_OR_SELF) != 0)
  +//    {
  +//      buf.append("ANCOS|");
  +//    }
  +//    if((analysis & BIT_ATTRIBUTE) != 0)
  +//    {
  +//      buf.append("ATTR|");
  +//    }
  +//    if((analysis & BIT_CHILD) != 0)
  +//    {
  +//      buf.append("CH|");
  +//    }
  +//    if((analysis & BIT_DESCENDANT) != 0)
  +//    {
  +//      buf.append("DESC|");
  +//    }
  +//    if((analysis & BIT_DESCENDANT_OR_SELF) != 0)
  +//    {
  +//      buf.append("DESCOS|");
  +//    }
  +//    if((analysis & BIT_FOLLOWING) != 0)
  +//    {
  +//      buf.append("FOL|");
  +//    }
  +//    if((analysis & BIT_FOLLOWING_SIBLING) != 0)
  +//    {
  +//      buf.append("FOLS|");
  +//    }
  +//    if((analysis & BIT_NAMESPACE) != 0)
  +//    {
  +//      buf.append("NS|");
  +//    }
  +//    if((analysis & BIT_PARENT) != 0)
  +//    {
  +//      buf.append("P|");
  +//    }
  +//    if((analysis & BIT_PRECEDING) != 0)
  +//    {
  +//      buf.append("PREC|");
  +//    }
  +//    if((analysis & BIT_PRECEDING_SIBLING) != 0)
  +//    {
  +//      buf.append("PRECS|");
  +//    }
  +//    if((analysis & BIT_SELF) != 0)
  +//    {
  +//      buf.append(".|");
  +//    }
  +//    if((analysis & BIT_FILTER) != 0)
  +//    {
  +//      buf.append("FLT|");
  +//    }
  +//    if((analysis & BIT_ROOT) != 0)
  +//    {
  +//      buf.append("R|");
  +//    }
  +//    return buf.toString();
  +//  }
  +//
  +//  /** Set to true for diagnostics about walker creation */
  +//  static final boolean DEBUG_PATTERN_CREATION = false;
  +//
  +//  /** Set to true for diagnostics about walker creation */
  +//  static final boolean DEBUG_WALKER_CREATION = false;
  +//
  +//  /** Set to true for diagnostics about iterator creation */
  +//  static final boolean DEBUG_ITERATOR_CREATION = false;
  +//  
  +//  public static boolean hasPredicate(int analysis)
  +//  {
  +//    return (0 != (analysis & BIT_PREDICATE));
  +//  }
  +//
  +//  public static boolean isWild(int analysis)
  +//  {
  +//    return (0 != (analysis & BIT_NODETEST_ANY));
  +//  }
  +//
  +//  public static boolean walksAncestors(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_ANCESTOR | BIT_ANCESTOR_OR_SELF);
  +//  }
  +//  
  +//  public static boolean walksAttributes(int analysis)
  +//  {
  +//    return (0 != (analysis & BIT_ATTRIBUTE));
  +//  }
  +//
  +//  public static boolean walksNamespaces(int analysis)
  +//  {
  +//    return (0 != (analysis & BIT_NAMESPACE));
  +//  }  
  +//
  +//  public static boolean walksChildren(int analysis)
  +//  {
  +//    return (0 != (analysis & BIT_CHILD));
  +//  }
  +//
  +//  public static boolean walksDescendants(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF);
  +//  }
  +//
  +//  public static boolean walksSubtree(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_DESCENDANT | BIT_DESCENDANT_OR_SELF | BIT_CHILD);
  +//  }
  +//  
  +//  public static boolean walksSubtreeOnlyMaybeAbsolute(int analysis)
  +//  {
  +//    return walksSubtree(analysis)
  +//           && !walksExtraNodes(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           ;
  +//  }
  +//  
  +//  public static boolean walksSubtreeOnly(int analysis)
  +//  {
  +//    return walksSubtreeOnlyMaybeAbsolute(analysis) 
  +//           && !isAbsolute(analysis) 
  +//           ;
  +//  }
  +//
  +//  public static boolean walksFilteredList(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_FILTER);
  +//  }
  +//  
  +//  public static boolean walksSubtreeOnlyFromRootOrContext(int analysis)
  +//  {
  +//    return walksSubtree(analysis)
  +//           && !walksExtraNodes(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && !isSet(analysis, BIT_FILTER) 
  +//           ;
  +//  }
  +//
  +//  public static boolean walksInDocOrder(int analysis)
  +//  {
  +//    return (walksSubtreeOnlyMaybeAbsolute(analysis)
  +//           || walksExtraNodesOnly(analysis)
  +//           || walksFollowingOnlyMaybeAbsolute(analysis)) 
  +//           && !isSet(analysis, BIT_FILTER) 
  +//           ;
  +//  }
  +//  
  +//  public static boolean walksFollowingOnlyMaybeAbsolute(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_SELF | BIT_FOLLOWING_SIBLING | BIT_FOLLOWING)
  +//           && !walksSubtree(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           ;
  +//  }
  +//  
  +//  public static boolean walksUp(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_PARENT | BIT_ANCESTOR | BIT_ANCESTOR_OR_SELF);
  +//  }
  +//  
  +//  public static boolean walksSideways(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_FOLLOWING | BIT_FOLLOWING_SIBLING | 
  +//                           BIT_PRECEDING | BIT_PRECEDING_SIBLING);
  +//  }
  +//  
  +//  public static boolean walksExtraNodes(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_NAMESPACE | BIT_ATTRIBUTE);
  +//  }
  +//
  +//  public static boolean walksExtraNodesOnly(int analysis)
  +//  {
  +//    return walksExtraNodes(analysis)
  +//           && !isSet(analysis, BIT_SELF) 
  +//           && !walksSubtree(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && !isAbsolute(analysis) 
  +//           ;
  +//  }
  +//
  +//  public static boolean isAbsolute(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_ROOT | BIT_FILTER);
  +//  }
  +//  
  +//  public static boolean walksChildrenOnly(int analysis)
  +//  {
  +//    return walksChildren(analysis)
  +//           && !isSet(analysis, BIT_SELF)
  +//           && !walksExtraNodes(analysis)
  +//           && !walksDescendants(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT))
  +//           ;
  +//  }
  +//  
  +//  public static boolean walksChildrenAndExtraAndSelfOnly(int analysis)
  +//  {
  +//    return walksChildren(analysis)
  +//           && !walksDescendants(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT))
  +//           ;
  +//  }
  +//  
  +//  public static boolean walksDescendantsAndExtraAndSelfOnly(int analysis)
  +//  {
  +//    return !walksChildren(analysis)
  +//           && walksDescendants(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && (!isAbsolute(analysis) || isSet(analysis, BIT_ROOT))
  +//           ;
  +//  }
  +//  
  +//  public static boolean walksSelfOnly(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_SELF) 
  +//           && !walksSubtree(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && !isAbsolute(analysis) 
  +//           ;
  +//  }
  +//
  +//  
  +//  public static boolean walksUpOnly(int analysis)
  +//  {
  +//    return !walksSubtree(analysis) 
  +//           && walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && !isAbsolute(analysis) 
  +//           ;
  +//  }
  +//  
  +//  public static boolean walksDownOnly(int analysis)
  +//  {
  +//    return walksSubtree(analysis) 
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && !isAbsolute(analysis) 
  +//           ;
  +//  }
  +//
  +//  public static boolean walksDownExtraOnly(int analysis)
  +//  {
  +//    return walksSubtree(analysis) &&  walksExtraNodes(analysis)
  +//           && !walksUp(analysis) 
  +//           && !walksSideways(analysis) 
  +//           && !isAbsolute(analysis) 
  +//           ;
  +//  }
  +//  
  +//  public static boolean canSkipSubtrees(int analysis)
  +//  {
  +//    return isSet(analysis, BIT_CHILD) | walksSideways(analysis);
  +//  }
  +//  
  +//  public static boolean canCrissCross(int analysis)
  +//  {
  +//    // This could be done faster.  Coded for clarity.
  +//    if(walksSelfOnly(analysis))
  +//      return false;
  +//    else if(walksDownOnly(analysis) && !canSkipSubtrees(analysis))
  +//      return false;
  +//    else if(walksChildrenAndExtraAndSelfOnly(analysis))
  +//      return false;
  +//    else if(walksDescendantsAndExtraAndSelfOnly(analysis))
  +//      return false;
  +//    else if(walksUpOnly(analysis))
  +//      return false;
  +//    else if(walksExtraNodesOnly(analysis))
  +//      return false;
  +//    else if(walksSubtree(analysis) 
  +//           && (walksSideways(analysis) 
  +//            || walksUp(analysis) 
  +//            || canSkipSubtrees(analysis)))
  +//      return true;
  +//    else
  +//      return false;
  +//  }
  +//  
  +//  /**
  +//   * Tell if the pattern can be 'walked' with the iteration steps in natural 
  +//   * document order, without duplicates.
  +//   *
  +//   * @param analysis The general analysis of the pattern.
  +//   *
  +//   * @return true if the walk can be done in natural order.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  static public boolean isNaturalDocOrder(int analysis)
  +//  {
  +//    if(canCrissCross(analysis) || isSet(analysis, BIT_NAMESPACE) ||
  +//       walksFilteredList(analysis))
  +//      return false;
  +//      
  +//    if(walksInDocOrder(analysis))
  +//      return true;
  +//      
  +//    return false;
  +//  }
  +//  
  +//  /**
  +//   * Tell if the pattern can be 'walked' with the iteration steps in natural 
  +//   * document order, without duplicates.
  +//   *
  +//   * @param compiler non-null reference to compiler object that has processed
  +//   *                 the XPath operations into an opcode map.
  +//   * @param stepOpCodePos The opcode position for the step.
  +//   * @param stepIndex The top-level step index withing the iterator.
  +//   * @param analysis The general analysis of the pattern.
  +//   *
  +//   * @return true if the walk can be done in natural order.
  +//   *
  +//   * @throws javax.xml.transform.TransformerException
  +//   */
  +//  private static boolean isNaturalDocOrder(
  +//          Compiler compiler, int stepOpCodePos, int stepIndex, int analysis)
  +//            throws javax.xml.transform.TransformerException
  +//  {
  +//    if(canCrissCross(analysis))
  +//      return false;
  +//      
  +//    // Namespaces can present some problems, so just punt if we're looking for 
  +//    // these.
  +//    if(isSet(analysis, BIT_NAMESPACE))
  +//      return false;
  +//      
  +//    // The following, preceding, following-sibling, and preceding sibling can 
  +//    // be found in doc order if we get to this point, but if they occur 
  +//    // together, they produce 
  +//    // duplicates, so it's better for us to eliminate this case so we don't 
  +//    // have to check for duplicates during runtime if we're using a 
  +//    // WalkingIterator.
  +//    if(isSet(analysis, BIT_FOLLOWING | BIT_FOLLOWING_SIBLING) && 
  +//       isSet(analysis, BIT_PRECEDING | BIT_PRECEDING_SIBLING))
  +//      return  false;
  +//      
  +//    // OK, now we have to check for select="@*/axis::*" patterns, which 
  +//    // can also cause duplicates to happen.  But select="axis*/@::*" patterns 
  +//    // are OK, as are select="@foo/axis::*" patterns.
  +//    // Unfortunately, we can't do this just via the analysis bits.
  +//    
  +//    int stepType;
  +//    int ops[] = compiler.getOpMap();
  +//    int stepCount = 0;
  +//    boolean foundWildAttribute = false;
  +//    
  +//    // Steps that can traverse anything other than down a 
  +//    // subtree or that can produce duplicates when used in 
  +//    // combonation are counted with this variable.
  +//    int potentialDuplicateMakingStepCount = 0;
  +//    
  +//    while (OpCodes.ENDOP != (stepType = ops[stepOpCodePos]))
  +//    {        
  +//      stepCount++;
  +//        
  +//      switch (stepType)
  +//      {
  +//      case OpCodes.FROM_ATTRIBUTES :
  +//      case OpCodes.MATCH_ATTRIBUTE :
  +//        if(foundWildAttribute) // Maybe not needed, but be safe.
  +//          return false;
  +//        
  +//        // This doesn't seem to work as a test for wild card.  Hmph.
  +//        // int nodeTestType = compiler.getStepTestType(stepOpCodePos);  
  +//        
  +//        String localName = compiler.getStepLocalName(stepOpCodePos);
  +//        // System.err.println("localName: "+localName);
  +//        if(localName.equals("*"))
  +//        {
  +//          foundWildAttribute = true;
  +//        }
  +//        break;
  +//      case OpCodes.FROM_FOLLOWING :
  +//      case OpCodes.FROM_FOLLOWING_SIBLINGS :
  +//      case OpCodes.FROM_PRECEDING :
  +//      case OpCodes.FROM_PRECEDING_SIBLINGS :
  +//      case OpCodes.FROM_PARENT :
  +//      case OpCodes.OP_VARIABLE :
  +//      case OpCodes.OP_EXTFUNCTION :
  +//      case OpCodes.OP_FUNCTION :
  +//      case OpCodes.OP_GROUP :
  +//      case OpCodes.FROM_NAMESPACE :
  +//      case OpCodes.FROM_ANCESTORS :
  +//      case OpCodes.FROM_ANCESTORS_OR_SELF :      
  +//      case OpCodes.MATCH_ANY_ANCESTOR :
  +//      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
  +//      case OpCodes.FROM_DESCENDANTS_OR_SELF :
  +//      case OpCodes.FROM_DESCENDANTS :
  +//        if(potentialDuplicateMakingStepCount > 0)
  +//            return false;
  +//        potentialDuplicateMakingStepCount++;
  +//      case OpCodes.FROM_ROOT :
  +//      case OpCodes.FROM_CHILDREN :
  +//      case OpCodes.FROM_SELF :
  +//        if(foundWildAttribute)
  +//          return false;
  +//        break;
  +//      default :
  +//        throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, new Object[]{Integer.toString(stepType)})); //"Programmer's assertion: unknown opcode: "
  +//                                  // + stepType);
  +//      }
  +//
  +//      int nextStepOpCodePos = compiler.getNextStepPos(stepOpCodePos);
  +//
  +//      if (nextStepOpCodePos < 0)
  +//        break;
  +//              
  +//      stepOpCodePos = nextStepOpCodePos;
  +//    }
  +//
  +//    return true;
  +//  }
  +//  
  +//  public static boolean isOneStep(int analysis)
  +//  {
  +//    return (analysis & BITS_COUNT) == 0x00000001;
  +//  }
  +//
  +//  public static int getStepCount(int analysis)
  +//  {
  +//    return (analysis & BITS_COUNT);
  +//  }
  +//
  +//  /**
  +//   * First 8 bits are the number of top-level location steps.  Hopefully
  +//   *  there will never be more that 255 location steps!!!
  +//   */
  +//  public static final int BITS_COUNT = 0x000000FF;
  +//
  +//  /** 4 bits are reserved for future use. */
  +//  public static final int BITS_RESERVED = 0x00000F00;
  +//
  +//  /** Bit is on if the expression contains a top-level predicate. */
  +//  public static final int BIT_PREDICATE = (0x00001000);
  +//
  +//  /** Bit is on if any of the walkers contain an ancestor step. */
  +//  public static final int BIT_ANCESTOR = (0x00001000 << 1);
  +//
  +//  /** Bit is on if any of the walkers contain an ancestor-or-self step. */
  +//  public static final int BIT_ANCESTOR_OR_SELF = (0x00001000 << 2);
  +//
  +//  /** Bit is on if any of the walkers contain an attribute step. */
  +//  public static final int BIT_ATTRIBUTE = (0x00001000 << 3);
  +//
  +//  /** Bit is on if any of the walkers contain a child step. */
  +//  public static final int BIT_CHILD = (0x00001000 << 4);
  +//
  +//  /** Bit is on if any of the walkers contain a descendant step. */
  +//  public static final int BIT_DESCENDANT = (0x00001000 << 5);
  +//
  +//  /** Bit is on if any of the walkers contain a descendant-or-self step. */
  +//  public static final int BIT_DESCENDANT_OR_SELF = (0x00001000 << 6);
  +//
  +//  /** Bit is on if any of the walkers contain a following step. */
  +//  public static final int BIT_FOLLOWING = (0x00001000 << 7);
  +//
  +//  /** Bit is on if any of the walkers contain a following-sibiling step. */
  +//  public static final int BIT_FOLLOWING_SIBLING = (0x00001000 << 8);
  +//
  +//  /** Bit is on if any of the walkers contain a namespace step. */
  +//  public static final int BIT_NAMESPACE = (0x00001000 << 9);
  +//
  +//  /** Bit is on if any of the walkers contain a parent step. */
  +//  public static final int BIT_PARENT = (0x00001000 << 10);
  +//
  +//  /** Bit is on if any of the walkers contain a preceding step. */
  +//  public static final int BIT_PRECEDING = (0x00001000 << 11);
  +//
  +//  /** Bit is on if any of the walkers contain a preceding-sibling step. */
  +//  public static final int BIT_PRECEDING_SIBLING = (0x00001000 << 12);
  +//
  +//  /** Bit is on if any of the walkers contain a self step. */
  +//  public static final int BIT_SELF = (0x00001000 << 13);
  +//
  +//  /**
  +//   * Bit is on if any of the walkers contain a filter (i.e. id(), extension
  +//   *  function, etc.) step.
  +//   */
  +//  public static final int BIT_FILTER = (0x00001000 << 14);
  +//
  +//  /** Bit is on if any of the walkers contain a root step. */
  +//  public static final int BIT_ROOT = (0x00001000 << 15);
  +//
  +//  /**
  +//   * If any of these bits are on, the expression may likely traverse outside
  +//   *  the given subtree.
  +//   */
  +//  public static final int BITMASK_TRAVERSES_OUTSIDE_SUBTREE = (BIT_NAMESPACE  // ??
  +//                                                                | BIT_PRECEDING_SIBLING
  +//                                                                | BIT_PRECEDING
  +//                                                                | BIT_FOLLOWING_SIBLING
  +//                                                                | BIT_FOLLOWING
  +//                                                                | BIT_PARENT  // except parent of attrs.
  +//                                                                | BIT_ANCESTOR_OR_SELF
  +//                                                                | BIT_ANCESTOR
  +//                                                                | BIT_FILTER
  +//                                                                | BIT_ROOT);
  +//
  +//  /**
  +//   * Bit is on if any of the walkers can go backwards in document
  +//   *  order from the context node.
  +//   */
  +//  public static final int BIT_BACKWARDS_SELF = (0x00001000 << 16);
  +//
  +//  /** Found "//foo" pattern */
  +//  public static final int BIT_ANY_DESCENDANT_FROM_ROOT = (0x00001000 << 17);
  +//
  +//  /**
  +//   * Bit is on if any of the walkers contain an node() test.  This is
  +//   *  really only useful if the count is 1.
  +//   */
  +//  public static final int BIT_NODETEST_ANY = (0x00001000 << 18);
  +//
  +//  // can't go higher than 18!
  +//
  +//  /** Bit is on if the expression is a match pattern. */
  +//  public static final int BIT_MATCH_PATTERN = (0x00001000 << 19);
  +//}
  
  
  
  1.5.4.1   +71 -29    xml-xalan/java/src/org/apache/xpath/axes/WalkingIterator.java
  
  Index: WalkingIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/WalkingIterator.java,v
  retrieving revision 1.5
  retrieving revision 1.5.4.1
  diff -u -r1.5 -r1.5.4.1
  --- WalkingIterator.java	22 Mar 2002 01:04:43 -0000	1.5
  +++ WalkingIterator.java	14 Aug 2002 20:06:58 -0000	1.5.4.1
  @@ -1,50 +1,45 @@
   package org.apache.xpath.axes;
   
  -import java.util.Vector;
  -
   import javax.xml.transform.TransformerException;
  +
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.VariableStack;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.compiler.Compiler;
  +import org.apache.xpath.parser.Node;
  +import org.apache.xpath.parser.NonExecutableExpression;
   
   /**
    * Location path iterator that uses Walkers.
    */
   
   public class WalkingIterator extends LocPathIterator implements ExpressionOwner
  -{
  +{  
     /**
  -   * Create a WalkingIterator iterator, including creation
  -   * of step walkers from the opcode list, and call back
  -   * into the Compiler to create predicate expressions.
  -   *
  -   * @param compiler The Compiler which is creating
  -   * this expression.
  -   * @param opPos The position of this iterator in the
  -   * opcode list from the compiler.
  -   * @param shouldLoadWalkers True if walkers should be
  -   * loaded, or false if this is a derived iterator and
  -   * it doesn't wish to load child walkers.
  +   * Create a WalkingIterator object.
      *
  -   * @throws javax.xml.transform.TransformerException
  +   * @param nscontext The namespace context for this iterator,
  +   * should be OK if null.
      */
  -  WalkingIterator(
  -          Compiler compiler, int opPos, int analysis, boolean shouldLoadWalkers)
  -            throws javax.xml.transform.TransformerException
  +  public WalkingIterator(PrefixResolver nscontext, org.apache.xpath.parser.PathExpr path)
     {
  -    super(compiler, opPos, analysis, shouldLoadWalkers);
  -    
  -    int firstStepPos = compiler.getFirstChildPos(opPos);
   
  -    if (shouldLoadWalkers)
  +    super(nscontext);
  +    
  +    try
       {
  -      m_firstWalker = WalkerFactory.loadWalkers(this, compiler, firstStepPos, 0);
  -      m_lastUsedWalker = m_firstWalker;
  +    	m_firstWalker = WalkerFactory.loadWalkers(path, this);
  +    	m_lastUsedWalker = m_firstWalker;
       }
  +    catch(TransformerException te)
  +    {
  +    	throw new org.apache.xml.utils.WrappedRuntimeException(te);
  +    }
  +
     }
     
     /**
  @@ -55,9 +50,9 @@
      */
     public WalkingIterator(PrefixResolver nscontext)
     {
  -
       super(nscontext);
     }
  +
     
     
     /** 
  @@ -264,7 +259,7 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       m_predicateIndex = -1;
   
  @@ -272,7 +267,7 @@
   
       while (null != walker)
       {
  -      walker.fixupVariables(vars, globalsSize);
  +      walker.fixupVariables(vcs);
         walker = walker.getNextWalker();
       }
     }
  @@ -313,6 +308,7 @@
      */
     public void setExpression(Expression exp)
     {
  +    // assertion(null != exp, "Expression owner can not be set to null!");
     	exp.exprSetParent(this);
     	m_firstWalker = (AxesWalker)exp;
     }
  @@ -340,5 +336,51 @@
   
         return true;
       }
  -
  +
  public Node jjtGetChild(int i) 
  +  {
  +    int superclassChildCount = super.jjtGetNumChildren();
  +    if((null != m_firstWalker) && i == 0)
  +    	return m_firstWalker;
  +    else
  +    	return super.jjtGetChild(i-((null == m_firstWalker) ? 0 : 1));
  +  }
  +
  +  public int jjtGetNumChildren() 
  +  {
  +  	int superChildCount = super.jjtGetNumChildren();
  +    return superChildCount+((null == m_firstWalker) ? 0 : 1);
  +  }
  +  
  +  
  +
  +  /**
  +   * @see org.apache.xpath.parser.SimpleNode#checkTreeIntegrity(int, int, boolean)
  +   */
  +  public boolean checkTreeIntegrity(
  +    int levelCount,
  +    int childNumber,
  +    boolean parentOK)
  +  {
  +    ExpressionNode expOwner = getExpressionOwner();
  +    if(null != expOwner)
  +    {
  +      if(!(expOwner instanceof Node))
  +        parentOK = flagProblem(" Expression owner is not a Node! It's a "+expOwner.getClass().getName());
  +      else if(expOwner instanceof NonExecutableExpression)
  +        parentOK = flagProblem(" Expression owner is a NonExecutableExpression!");
  +    }
  +    return super.checkTreeIntegrity(levelCount, childNumber, parentOK);
  +  
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.parser.Node#jjtClose()
  +   */
  +  public void jjtClose()
  +  {
  +    if(null == getExpressionOwner())
  +      flagProblem("The expression owner can not be null on jjtClose!");
  +    super.jjtClose();
  +  }
  +
   }
  
  
  
  1.7.4.1   +14 -32    xml-xalan/java/src/org/apache/xpath/axes/WalkingIteratorSorted.java
  
  Index: WalkingIteratorSorted.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/WalkingIteratorSorted.java,v
  retrieving revision 1.7
  retrieving revision 1.7.4.1
  diff -u -r1.7 -r1.7.4.1
  --- WalkingIteratorSorted.java	22 Mar 2002 01:04:43 -0000	1.7
  +++ WalkingIteratorSorted.java	14 Aug 2002 20:06:58 -0000	1.7.4.1
  @@ -56,12 +56,9 @@
    */
   package org.apache.xpath.axes;
   
  -import org.apache.xpath.XPathContext;
  -import org.apache.xml.utils.PrefixResolver;
  -import org.apache.xpath.compiler.Compiler;
  -import org.apache.xml.dtm.DTM;
  -import org.apache.xml.dtm.DTMIterator;
   import org.apache.xml.dtm.Axis;
  +import org.apache.xml.utils.PrefixResolver;
  +import org.apache.xpath.VariableComposeState;
   
   /**
    * <meta name="usage" content="internal"/>
  @@ -83,31 +80,9 @@
      * @param nscontext The namespace context for this iterator,
      * should be OK if null.
      */
  -  public WalkingIteratorSorted(PrefixResolver nscontext)
  +  public WalkingIteratorSorted(PrefixResolver nscontext, org.apache.xpath.parser.PathExpr path)
     {
  -    super(nscontext);
  -  }
  -
  -  /**
  -   * Create a WalkingIterator iterator, including creation
  -   * of step walkers from the opcode list, and call back
  -   * into the Compiler to create predicate expressions.
  -   *
  -   * @param compiler The Compiler which is creating
  -   * this expression.
  -   * @param opPos The position of this iterator in the
  -   * opcode list from the compiler.
  -   * @param shouldLoadWalkers True if walkers should be
  -   * loaded, or false if this is a derived iterator and
  -   * it doesn't wish to load child walkers.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  WalkingIteratorSorted(
  -          Compiler compiler, int opPos, int analysis, boolean shouldLoadWalkers)
  -            throws javax.xml.transform.TransformerException
  -  {
  -    super(compiler, opPos, analysis, shouldLoadWalkers);
  +    super(nscontext, path);
     }
     
     /**
  @@ -120,7 +95,6 @@
     {
       return m_inNaturalOrderStatic;
     }
  -
       
     /**
      * Tell if the nodeset can be walked in doc order, via static analysis. 
  @@ -231,9 +205,9 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
   
       int analysis = getAnalysisBits();
       if(WalkerFactory.isNaturalDocOrder(analysis))
  @@ -247,6 +221,14 @@
       	//    WalkerFactory.getAnalysisString(analysis));
       }
       
  +  }
  +
  +  /**
  +   * @see java.lang.Object#toString()
  +   */
  +  public String toString()
  +  {
  +    return "(sorted node list) "+super.toString();
     }
   
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +137 -0    xml-xalan/java/src/org/apache/xpath/conditional/Attic/Else.java
  
  
  
  
  1.1.2.1   +255 -0    xml-xalan/java/src/org/apache/xpath/conditional/Attic/If.java
  
  
  
  
  1.1.2.1   +137 -0    xml-xalan/java/src/org/apache/xpath/conditional/Attic/Then.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.4.14.1  +3 -9      xml-xalan/java/src/org/apache/xpath/functions/FuncCeiling.java
  
  Index: FuncCeiling.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncCeiling.java,v
  retrieving revision 1.4
  retrieving revision 1.4.14.1
  diff -u -r1.4 -r1.4.14.1
  --- FuncCeiling.java	12 Jun 2001 19:16:32 -0000	1.4
  +++ FuncCeiling.java	14 Aug 2002 20:06:59 -0000	1.4.14.1
  @@ -56,16 +56,10 @@
    */
   package org.apache.xpath.functions;
   
  -import java.lang.Math;
  -
  -//import org.w3c.dom.Node;
  -
  -import java.util.Vector;
  -
  +import javax.xml.transform.TransformerException;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  +import org.apache.xpath.objects.XDouble;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -84,6 +78,6 @@
      */
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
  -    return new XNumber(Math.ceil(m_arg0.execute(xctxt).num()));
  +    return new XDouble(Math.ceil(m_arg0.execute(xctxt).num()));
     }
   }
  
  
  
  1.6.4.1   +3 -2      xml-xalan/java/src/org/apache/xpath/functions/FuncCount.java
  
  Index: FuncCount.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncCount.java,v
  retrieving revision 1.6
  retrieving revision 1.6.4.1
  diff -u -r1.6 -r1.6.4.1
  --- FuncCount.java	22 Mar 2002 01:04:44 -0000	1.6
  +++ FuncCount.java	14 Aug 2002 20:06:59 -0000	1.6.4.1
  @@ -69,6 +69,7 @@
   import org.apache.xpath.XPath;
   import org.apache.xpath.objects.XObject;
   import org.apache.xpath.objects.XNumber;
  +import org.apache.xpath.objects.XSequence;
   import org.apache.xpath.objects.XString;
   
   /**
  @@ -100,10 +101,10 @@
   //      i++;
   //    }
   //    nl.detach();
  -	DTMIterator nl = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
  +	XSequence nl = m_arg0.execute(xctxt).xseq();
   	int i = nl.getLength();	
   	nl.detach();
   
  -    return new XNumber((double) i);
  +    return new org.apache.xpath.objects.XInteger(i);
     }
   }
  
  
  
  1.8.12.1  +5 -14     xml-xalan/java/src/org/apache/xpath/functions/FuncCurrent.java
  
  Index: FuncCurrent.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncCurrent.java,v
  retrieving revision 1.8
  retrieving revision 1.8.12.1
  diff -u -r1.8 -r1.8.12.1
  --- FuncCurrent.java	20 Aug 2001 23:48:10 -0000	1.8
  +++ FuncCurrent.java	14 Aug 2002 20:06:59 -0000	1.8.12.1
  @@ -56,23 +56,14 @@
    */
   package org.apache.xpath.functions;
   
  -import org.apache.xpath.res.XPATHErrorResources;
  -
  -//import org.w3c.dom.Node;
  -//import org.w3c.dom.traversal.NodeIterator;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  -
  -import java.util.Vector;
  -
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNodeSet;
  -import org.apache.xpath.axes.PredicatedNodeTest;
   import org.apache.xpath.axes.LocPathIterator;
  -import org.apache.xpath.axes.ContextNodeList;
  -import org.apache.xpath.axes.SubContextList;
  +import org.apache.xpath.axes.PredicatedNodeTest;
  +import org.apache.xpath.objects.XNodeSet;
  +import org.apache.xpath.objects.XObject;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -137,7 +128,7 @@
     /**
      * No arguments to process, so this does nothing.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       // no-op
     }
  
  
  
  1.16.2.1  +19 -16    xml-xalan/java/src/org/apache/xpath/functions/FuncExtFunction.java
  
  Index: FuncExtFunction.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncExtFunction.java,v
  retrieving revision 1.16
  retrieving revision 1.16.2.1
  diff -u -r1.16 -r1.16.2.1
  --- FuncExtFunction.java	10 Jun 2002 20:47:44 -0000	1.16
  +++ FuncExtFunction.java	14 Aug 2002 20:06:59 -0000	1.16.2.1
  @@ -58,22 +58,14 @@
   
   import java.util.Vector;
   
  +import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.Expression;
  -import org.apache.xpath.XPathContext;
   import org.apache.xpath.ExtensionsProvider;
  -import org.apache.xpath.objects.*;
  -import org.apache.xalan.transformer.TransformerImpl;
  -import org.apache.xalan.extensions.ExtensionsTable;
  -import org.apache.xml.dtm.DTMIterator;
  -
  -//import org.w3c.dom.Node;
  -import org.w3c.dom.DocumentFragment;
  -import org.w3c.dom.traversal.NodeIterator;
  -
  -import org.apache.xml.dtm.*;
  -import org.apache.xpath.axes.*;
  +import org.apache.xpath.VariableComposeState;
  +import org.apache.xpath.XPathContext;
  +import org.apache.xpath.objects.XNull;
  +import org.apache.xpath.objects.XObject;
   import org.apache.xpath.res.XPATHErrorResources;
  -import org.apache.xalan.res.XSLMessages;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -122,7 +114,7 @@
      * to be offset to the current stack frame).
      * NEEDSDOC @param globalsSize
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
   
       if (null != m_argVec)
  @@ -133,7 +125,7 @@
         {
           Expression arg = (Expression) m_argVec.elementAt(i);
   
  -        arg.fixupVariables(vars, globalsSize);
  +        arg.fixupVariables(vcs);
         }
       }
     }
  @@ -188,6 +180,12 @@
         Expression arg = (Expression) m_argVec.elementAt(i);
         
         XObject xobj = arg.execute(xctxt);
  +      
  +      if(null == xobj)
  +        throw new RuntimeException("Arg executed to a null XObject!!! arg: "+arg);
  +        
  +      if(null == xobj.object())
  +        throw new RuntimeException("Arg executed to a null object!!! arg: "+arg);
   
         argVec.addElement(xobj);
       }
  @@ -198,6 +196,7 @@
   
       if (null != val)
       {
  +      // If val is an XObject, it will just pass through create.
         result = XObject.create(val, xctxt);
       }
       else
  @@ -221,7 +220,11 @@
     public void setArg(Expression arg, int argNum)
             throws WrongNumberArgsException
     {
  -    m_argVec.addElement(arg);
  +    // m_argVec.addElement(arg);
  +    if(argNum >= m_argVec.size())
  +      m_argVec.setSize(argNum+1);
  +    
  +    m_argVec.setElementAt(arg, argNum);
     }
   
     /**
  
  
  
  1.7.2.1   +8 -13     xml-xalan/java/src/org/apache/xpath/functions/FuncExtFunctionAvailable.java
  
  Index: FuncExtFunctionAvailable.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncExtFunctionAvailable.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- FuncExtFunctionAvailable.java	10 Jun 2002 19:24:42 -0000	1.7
  +++ FuncExtFunctionAvailable.java	14 Aug 2002 20:06:59 -0000	1.7.2.1
  @@ -56,21 +56,14 @@
    */
   package org.apache.xpath.functions;
   
  -import org.apache.xml.utils.PrefixResolver;
  +import javax.xml.transform.TransformerException;
   import org.apache.xalan.templates.Constants;
  -//import org.apache.xalan.transformer.TransformerImpl;
  -//import org.apache.xalan.extensions.ExtensionsTable;
  -
  -//import org.w3c.dom.Node;
  -
  -import java.util.Vector;
  -
  -import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  +import org.apache.xml.utils.QName;
   import org.apache.xpath.ExtensionsProvider;
  -import org.apache.xpath.compiler.Keywords;
  -import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.XPathContext;
   import org.apache.xpath.objects.XBoolean;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.parser.SimpleNode;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -116,7 +109,9 @@
       {
         try
         {
  -        return Keywords.functionAvailable(methName) ? XBoolean.S_TRUE : XBoolean.S_FALSE;
  +      	// TBD: At least properly construct the QName object.
  +      	Object funcObj = SimpleNode.m_builtInFunctions.get(new QName(methName));
  +        return (null != funcObj) ? XBoolean.S_TRUE : XBoolean.S_FALSE;
         }
         catch (Exception e)
         {
  
  
  
  1.4.14.1  +3 -5      xml-xalan/java/src/org/apache/xpath/functions/FuncFalse.java
  
  Index: FuncFalse.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncFalse.java,v
  retrieving revision 1.4
  retrieving revision 1.4.14.1
  diff -u -r1.4 -r1.4.14.1
  --- FuncFalse.java	12 Jun 2001 19:16:34 -0000	1.4
  +++ FuncFalse.java	14 Aug 2002 20:06:59 -0000	1.4.14.1
  @@ -58,12 +58,10 @@
   
   //import org.w3c.dom.Node;
   
  -import java.util.Vector;
  -
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.objects.XObject;
   import org.apache.xpath.objects.XBoolean;
  +import org.apache.xpath.objects.XObject;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -88,7 +86,7 @@
     /**
      * No arguments to process, so this does nothing.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       // no-op
     }
  
  
  
  1.4.14.1  +3 -5      xml-xalan/java/src/org/apache/xpath/functions/FuncFloor.java
  
  Index: FuncFloor.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncFloor.java,v
  retrieving revision 1.4
  retrieving revision 1.4.14.1
  diff -u -r1.4 -r1.4.14.1
  --- FuncFloor.java	12 Jun 2001 19:16:35 -0000	1.4
  +++ FuncFloor.java	14 Aug 2002 20:06:59 -0000	1.4.14.1
  @@ -58,12 +58,10 @@
   
   //import org.w3c.dom.Node;
   
  -import java.util.Vector;
  -
  +import javax.xml.transform.TransformerException;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  +import org.apache.xpath.objects.XDouble;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -82,6 +80,6 @@
      */
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
  -    return new XNumber(java.lang.Math.floor(m_arg0.execute(xctxt).num()));
  +    return new XDouble(java.lang.Math.floor(m_arg0.execute(xctxt).num()));
     }
   }
  
  
  
  1.9.14.1  +0 -1      xml-xalan/java/src/org/apache/xpath/functions/FuncId.java
  
  Index: FuncId.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncId.java,v
  retrieving revision 1.9
  retrieving revision 1.9.14.1
  diff -u -r1.9 -r1.9.14.1
  --- FuncId.java	15 Jun 2001 17:54:24 -0000	1.9
  +++ FuncId.java	14 Aug 2002 20:06:59 -0000	1.9.14.1
  @@ -69,7 +69,6 @@
   import java.util.Vector;
   
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.DOMHelper;
   import org.apache.xpath.XPath;
   import org.apache.xpath.NodeSetDTM;
   import org.apache.xpath.objects.XObject;
  
  
  
  1.11.2.1  +10 -15    xml-xalan/java/src/org/apache/xpath/functions/FuncLast.java
  
  Index: FuncLast.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncLast.java,v
  retrieving revision 1.11
  retrieving revision 1.11.2.1
  diff -u -r1.11 -r1.11.2.1
  --- FuncLast.java	13 May 2002 21:07:44 -0000	1.11
  +++ FuncLast.java	14 Aug 2002 20:06:59 -0000	1.11.2.1
  @@ -58,20 +58,14 @@
   
   //import org.w3c.dom.Node;
   //import org.w3c.dom.Element;
  -import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  -
  -import java.util.Vector;
  -
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  -import org.apache.xpath.NodeSetDTM;
  -import org.apache.xpath.axes.LocPathIterator;
  -import org.apache.xpath.axes.ContextNodeList;
   import org.apache.xpath.axes.SubContextList;
  -import org.apache.xpath.compiler.Compiler;
  +import org.apache.xpath.objects.XInteger;
  +import org.apache.xpath.objects.XNumber;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.objects.XSequence;
   
   
   /**
  @@ -89,7 +83,8 @@
      */
     public void postCompileStep(Compiler compiler)
     {
  -    m_isTopLevel = compiler.getLocationPathDepth() == -1;
  +  	// TBD: Figure out isTopLevel for new parser world.
  +    // m_isTopLevel = compiler.getLocationPathDepth() == -1;
     }
   
     /**
  @@ -113,7 +108,7 @@
       if (null != iter)
         return iter.getLastPos(xctxt);
   
  -    DTMIterator cnl = xctxt.getContextNodeList();
  +    XSequence cnl = xctxt.getContextSequence();
       int count;
       if(null != cnl)
       {
  @@ -135,7 +130,7 @@
      */
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
  -    XNumber xnum = new XNumber((double) getCountOfContextNodeList(xctxt));
  +    XNumber xnum = new XInteger(getCountOfContextNodeList(xctxt));
       // System.out.println("last: "+xnum.num());
       return xnum;
     }
  @@ -143,7 +138,7 @@
     /**
      * No arguments to process, so this does nothing.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       // no-op
     }
  
  
  
  1.4.14.1  +3 -10     xml-xalan/java/src/org/apache/xpath/functions/FuncNumber.java
  
  Index: FuncNumber.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncNumber.java,v
  retrieving revision 1.4
  retrieving revision 1.4.14.1
  diff -u -r1.4 -r1.4.14.1
  --- FuncNumber.java	12 Jun 2001 19:16:37 -0000	1.4
  +++ FuncNumber.java	14 Aug 2002 20:07:00 -0000	1.4.14.1
  @@ -56,17 +56,10 @@
    */
   package org.apache.xpath.functions;
   
  -import org.apache.xpath.res.XPATHErrorResources;
  -
  -//import org.w3c.dom.Node;
  -
  -import java.util.Vector;
  -
  +import javax.xml.transform.TransformerException;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  +import org.apache.xpath.objects.XDouble;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  -import org.apache.xpath.objects.XNodeSet;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -85,6 +78,6 @@
      */
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
  -    return new XNumber(getArg0AsNumber(xctxt));
  +    return new XDouble(getArg0AsNumber(xctxt));
     }
   }
  
  
  
  1.8.2.1   +85 -22    xml-xalan/java/src/org/apache/xpath/functions/FuncPosition.java
  
  Index: FuncPosition.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncPosition.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- FuncPosition.java	22 May 2002 20:12:53 -0000	1.8
  +++ FuncPosition.java	14 Aug 2002 20:07:00 -0000	1.8.2.1
  @@ -60,17 +60,12 @@
   //import org.w3c.dom.traversal.NodeIterator;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  -
  -import java.util.Vector;
  -
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
   import org.apache.xpath.axes.SubContextList;
  -import org.apache.xpath.axes.ContextNodeList;
  -import org.apache.xpath.NodeSetDTM;
  -import org.apache.xpath.compiler.Compiler;
  +import org.apache.xpath.objects.XInteger;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.objects.XSequence;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -86,8 +81,73 @@
      */
     public void postCompileStep(Compiler compiler)
     {
  -    m_isTopLevel = compiler.getLocationPathDepth() == -1;
  +  	// TBD: Figure out isTopLevel for new parser world.
  +    // m_isTopLevel = compiler.getLocationPathDepth() == -1;
     }
  +  
  +//    /**
  +//   * Get the position in the current context node list.
  +//   *
  +//   * @param xctxt Runtime XPath context.
  +//   *
  +//   * @return The current position of the itteration in the context node list, 
  +//   *         or -1 if there is no active context node list.
  +//   */
  +//  public int getPositionInContextNodeList(XPathContext xctxt)
  +//  {
  +//
  +//    // System.out.println("FuncPosition- entry");
  +//    // If we're in a predicate, then this will return non-null.
  +//    SubContextList iter = m_isTopLevel ? null : xctxt.getSubContextList();
  +//
  +//    if (null != iter)
  +//    {
  +//      int prox = iter.getProximityPosition(xctxt);
  +// 
  +//      // System.out.println("FuncPosition- prox: "+prox);
  +//      return prox;
  +//    }
  +//
  +//    DTMIterator cnl = xctxt.getContextNodeList();
  +//
  +//    if (null != cnl)
  +//    {
  +//      int n = cnl.getCurrentNode();
  +//      if(n == DTM.NULL)
  +//      {
  +//        if(cnl.getCurrentPos() == 0)
  +//          return 0;
  +//          
  +//        // Then I think we're in a sort.  See sort21.xsl. So the iterator has 
  +//        // already been spent, and is not on the node we're processing. 
  +//        // It's highly possible that this is an issue for other context-list 
  +//        // functions.  Shouldn't be a problem for last(), and it shouldn't be 
  +//        // a problem for current().
  +//        try 
  +//        { 
  +//          cnl = cnl.cloneWithReset(); 
  +//        }
  +//        catch(CloneNotSupportedException cnse)
  +//        {
  +//          throw new org.apache.xml.utils.WrappedRuntimeException(cnse);
  +//        }
  +//        int currentNode = xctxt.getContextNode();
  +//        // System.out.println("currentNode: "+currentNode);
  +//        while(DTM.NULL != (n = cnl.nextNode()))
  +//        {
  +//          if(n == currentNode)
  +//            break;
  +//        }
  +//      }
  +//      // System.out.println("n: "+n);
  +//      // System.out.println("FuncPosition- cnl.getCurrentPos(): "+cnl.getCurrentPos());
  +//      return cnl.getCurrentPos();
  +//    }
  +//
  +//    // System.out.println("FuncPosition - out of guesses: -1");
  +//    return -1;
  +//  }
  +
   
     /**
      * Get the position in the current context node list.
  @@ -106,20 +166,21 @@
   
       if (null != iter)
       {
  -      int prox = iter.getProximityPosition(xctxt);
  +      int prox = iter.getProximityPosition(xctxt)-1;
    
         // System.out.println("FuncPosition- prox: "+prox);
         return prox;
       }
   
  -    DTMIterator cnl = xctxt.getContextNodeList();
  +    XSequence cnl = xctxt.getContextSequence();
   
       if (null != cnl)
       {
  -      int n = cnl.getCurrentNode();
  -      if(n == DTM.NULL)
  +      XObject current = cnl.getCurrent();
  +      if(current == null)
         {
  -        if(cnl.getCurrentPos() == 0)
  +        int pos = cnl.getCurrentPos();
  +        if(pos == 0)
             return 0;
             
           // Then I think we're in a sort.  See sort21.xsl. So the iterator has 
  @@ -129,17 +190,19 @@
           // a problem for current().
           try 
           { 
  -          cnl = cnl.cloneWithReset(); 
  +          cnl = (XSequence)cnl.clone(); 
  +          cnl.reset();
           }
           catch(CloneNotSupportedException cnse)
           {
             throw new org.apache.xml.utils.WrappedRuntimeException(cnse);
           }
  -        int currentNode = xctxt.getContextNode();
  +        XObject currentItem = xctxt.getCurrentItem();
  +        XObject item;
           // System.out.println("currentNode: "+currentNode);
  -        while(DTM.NULL != (n = cnl.nextNode()))
  +        while(null != (item = cnl.next()))
           {
  -          if(n == currentNode)
  +          if(item.equals(currentItem))
               break;
           }
         }
  @@ -162,15 +225,15 @@
      */
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
  -    double pos = (double) getPositionInContextNodeList(xctxt);
  +    int pos = getPositionInContextNodeList(xctxt);
       
  -    return new XNumber(pos);
  +    return new XInteger(pos+1);
     }
     
     /**
      * No arguments to process, so this does nothing.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       // no-op
     }
  
  
  
  1.5.14.1  +3 -5      xml-xalan/java/src/org/apache/xpath/functions/FuncRound.java
  
  Index: FuncRound.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncRound.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- FuncRound.java	12 Jun 2001 19:16:37 -0000	1.5
  +++ FuncRound.java	14 Aug 2002 20:07:00 -0000	1.5.14.1
  @@ -58,12 +58,10 @@
   
   //import org.w3c.dom.Node;
   
  -import java.util.Vector;
  -
  +import javax.xml.transform.TransformerException;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  +import org.apache.xpath.objects.XDouble;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -82,7 +80,7 @@
      */
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
  -    return new XNumber(java.lang.Math.floor(m_arg0.execute(xctxt).num()
  +    return new XDouble(java.lang.Math.floor(m_arg0.execute(xctxt).num()
                                               + 0.5));
     }
   }
  
  
  
  1.4.14.1  +3 -10     xml-xalan/java/src/org/apache/xpath/functions/FuncStringLength.java
  
  Index: FuncStringLength.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncStringLength.java,v
  retrieving revision 1.4
  retrieving revision 1.4.14.1
  diff -u -r1.4 -r1.4.14.1
  --- FuncStringLength.java	12 Jun 2001 19:16:38 -0000	1.4
  +++ FuncStringLength.java	14 Aug 2002 20:07:00 -0000	1.4.14.1
  @@ -56,17 +56,10 @@
    */
   package org.apache.xpath.functions;
   
  -import org.apache.xpath.res.XPATHErrorResources;
  -
  -//import org.w3c.dom.Node;
  -
  -import java.util.Vector;
  -
  +import javax.xml.transform.TransformerException;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  +import org.apache.xpath.objects.XInteger;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  -import org.apache.xpath.objects.XNodeSet;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -85,6 +78,6 @@
      */
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
  -    return new XNumber(getArg0AsString(xctxt).length());
  +    return new XInteger(getArg0AsString(xctxt).length());
     }
   }
  
  
  
  1.5.14.1  +4 -10     xml-xalan/java/src/org/apache/xpath/functions/FuncSum.java
  
  Index: FuncSum.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncSum.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- FuncSum.java	12 Jun 2001 19:16:38 -0000	1.5
  +++ FuncSum.java	14 Aug 2002 20:07:00 -0000	1.5.14.1
  @@ -56,19 +56,13 @@
    */
   package org.apache.xpath.functions;
   
  +import javax.xml.transform.TransformerException;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  -
  -import java.util.Vector;
  -
  +import org.apache.xml.utils.XMLString;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.DOMHelper;
  -import org.apache.xpath.XPath;
  +import org.apache.xpath.objects.XDouble;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  -import org.apache.xpath.objects.XString;
  -
  -import org.apache.xml.utils.XMLString;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -102,6 +96,6 @@
       }
       nodes.detach();
   
  -    return new XNumber(sum);
  +    return new XDouble(sum);
     }
   }
  
  
  
  1.11.14.1 +8 -2      xml-xalan/java/src/org/apache/xpath/functions/FuncSystemProperty.java
  
  Index: FuncSystemProperty.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncSystemProperty.java,v
  retrieving revision 1.11
  retrieving revision 1.11.14.1
  diff -u -r1.11 -r1.11.14.1
  --- FuncSystemProperty.java	20 Jun 2001 19:07:27 -0000	1.11
  +++ FuncSystemProperty.java	14 Aug 2002 20:07:00 -0000	1.11.14.1
  @@ -61,7 +61,6 @@
   import java.io.BufferedInputStream;
   import java.io.InputStream;
   
  -import java.lang.ClassLoader;
   
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.res.XPATHErrorResources;
  @@ -72,6 +71,7 @@
   
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPath;
  +import org.apache.xpath.objects.XDouble;
   import org.apache.xpath.objects.XObject;
   import org.apache.xpath.objects.XNumber;
   import org.apache.xpath.objects.XString;
  @@ -194,7 +194,13 @@
         try
         {
           // Needs to return the version number of the spec we conform to.
  -        return new XNumber(1.0);
  +        String verStr = xctxt.getXPathVersion();
  +        if(Double.valueOf(verStr).doubleValue() == 2.0)
  +          return new XString(verStr);
  +        else if(Double.valueOf(verStr).doubleValue() < 1.9)
  +          return new XDouble(1.0);
  +        else
  +          return new XString("2.0");
         }
         catch (Exception ex)
         {
  
  
  
  1.4.14.1  +3 -5      xml-xalan/java/src/org/apache/xpath/functions/FuncTrue.java
  
  Index: FuncTrue.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncTrue.java,v
  retrieving revision 1.4
  retrieving revision 1.4.14.1
  diff -u -r1.4 -r1.4.14.1
  --- FuncTrue.java	12 Jun 2001 19:16:39 -0000	1.4
  +++ FuncTrue.java	14 Aug 2002 20:07:00 -0000	1.4.14.1
  @@ -58,12 +58,10 @@
   
   //import org.w3c.dom.Node;
   
  -import java.util.Vector;
  -
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.objects.XObject;
   import org.apache.xpath.objects.XBoolean;
  +import org.apache.xpath.objects.XObject;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -88,7 +86,7 @@
     /**
      * No arguments to process, so this does nothing.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       // no-op
     }
  
  
  
  1.9.2.1   +50 -2     xml-xalan/java/src/org/apache/xpath/functions/Function.java
  
  Index: Function.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Function.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- Function.java	10 Jun 2002 20:47:44 -0000	1.9
  +++ Function.java	14 Aug 2002 20:07:00 -0000	1.9.2.1
  @@ -61,11 +61,13 @@
   import javax.xml.transform.TransformerException;
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.compiler.Compiler;
   import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.parser.Node;
  +import org.apache.xpath.parser.PathExpr;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -77,7 +79,7 @@
    * the arguments don't have to be added to an array, but causes
    * a larger code footprint.
    */
  -public abstract class Function extends Expression
  +public abstract class Function extends Expression implements Cloneable
   {
   
     /**
  @@ -96,6 +98,24 @@
   			// throw new WrongNumberArgsException(XSLMessages.createXPATHMessage("zero", null));
         reportWrongNumberArgs();
     }
  +  
  +  
  +  /**
  +   * @see ExpressionOwner#setExpression(Expression)
  +   */
  +  public void jjtAddChild(Node exp, int argNum)
  +  {
  +  	try
  +  	{
  +  		exp = fixupPrimarys(exp);
  +  		setArg((Expression)exp, argNum);
  +  	}
  +  	catch(WrongNumberArgsException wnae)
  +  	{
  +  		throw new org.apache.xml.utils.WrappedRuntimeException(wnae);
  +  	}
  +  }
  +
   
     /**
      * Check that the number of arguments passed to this function is correct.
  @@ -179,4 +199,32 @@
     {
       // no default action
     }
  +  
  +//  public void jjtAddChild(org.apache.xpath.parser.Node n, int i) {
  +//    // at least for now, just ignore this.
  +//  }
  +  
  +  /** This method tells the node to add its argument to the node's
  +    list of children.  */
  +  public void exprAddChild(ExpressionNode n, int i)
  +  {
  +  	try
  +  	{
  +  		setArg((Expression)n, i);
  +  	}
  +  	catch(WrongNumberArgsException wnae)
  +  	{
  +  		throw new RuntimeException(wnae.getMessage());
  +  	}
  +  }
  +
  +  /**
  +   * Tell if this node should have it's PathExpr ancestory reduced.
  +   */
  +  public boolean isPathExprReduced()
  +  {
  +   	Node pathOwner = jjtGetParent().jjtGetParent();
  +  	return pathOwner.jjtGetNumChildren() == 1 ? true : false;
  +  }
  +
   }
  
  
  
  1.9.2.1   +20 -5     xml-xalan/java/src/org/apache/xpath/functions/Function2Args.java
  
  Index: Function2Args.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Function2Args.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- Function2Args.java	10 Jun 2002 20:47:44 -0000	1.9
  +++ Function2Args.java	14 Aug 2002 20:07:00 -0000	1.9.2.1
  @@ -56,11 +56,11 @@
    */
   package org.apache.xpath.functions;
   
  -import java.util.Vector;
  -
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathVisitor;
   
   /**
  @@ -95,11 +95,11 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
       if(null != m_arg1)
  -      m_arg1.fixupVariables(vars, globalsSize);
  +      m_arg1.fixupVariables(vcs);
     }
   
   
  @@ -217,5 +217,20 @@
     		
     	return true;
     }
  +  
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	assertion(i <= 1, "Function2Args only allows index one or less to be accessed at this level!");
  +  	return (1 == i) ? m_arg1 : super.exprGetChild(i);
  +  }
  +
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
  +  {
  +  	return 2;
  +  }
  +
   
   }
  
  
  
  1.10.2.1  +18 -5     xml-xalan/java/src/org/apache/xpath/functions/Function3Args.java
  
  Index: Function3Args.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/Function3Args.java,v
  retrieving revision 1.10
  retrieving revision 1.10.2.1
  diff -u -r1.10 -r1.10.2.1
  --- Function3Args.java	10 Jun 2002 20:47:44 -0000	1.10
  +++ Function3Args.java	14 Aug 2002 20:07:00 -0000	1.10.2.1
  @@ -56,11 +56,11 @@
    */
   package org.apache.xpath.functions;
   
  -import java.util.Vector;
  -
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathVisitor;
   
   /**
  @@ -95,11 +95,11 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
       if(null != m_arg2)
  -      m_arg2.fixupVariables(vars, globalsSize);
  +      m_arg2.fixupVariables(vcs);
     }
   
     /**
  @@ -216,5 +216,18 @@
     	return true;
     }
   
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	assertion(i <= 2, "Function2Args only allows index two or less to be accessed at this level!");
  +  	return (2 == i) ? m_arg2 : super.exprGetChild(i);
  +  }
  +
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
  +  {
  +  	return 2;
  +  }
   
   }
  
  
  
  1.8.2.1   +20 -7     xml-xalan/java/src/org/apache/xpath/functions/FunctionDef1Arg.java
  
  Index: FunctionDef1Arg.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FunctionDef1Arg.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- FunctionDef1Arg.java	10 Jun 2002 20:47:44 -0000	1.8
  +++ FunctionDef1Arg.java	14 Aug 2002 20:07:00 -0000	1.8.2.1
  @@ -58,17 +58,15 @@
   
   //import org.w3c.dom.Node;
   
  +import javax.xml.transform.TransformerException;
  +import org.apache.xalan.res.XSLMessages;
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.utils.XMLString;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.objects.XNodeSet;
  -import org.apache.xpath.objects.XNumber;
   import org.apache.xpath.objects.XString;
  -import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.res.XPATHErrorResources;
   
  -import org.apache.xml.utils.XMLString;
  -
  -import org.apache.xml.dtm.DTM;
  -
   /**
    * <meta name="usage" content="advanced"/>
    * Base class for functions that accept one argument that can be defaulted if
  @@ -205,4 +203,19 @@
     {
       return (null == m_arg0) ? false : super.canTraverseOutsideSubtree();
     }
  +  
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	assertion(i == 0, "FunctionDef1Arg only allows index zero to be accessed at this level!");
  +  	return m_arg0;
  +  }
  +
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
  +  {
  +  	return (null == m_arg0) ? 0 : 1;
  +  }
  +
   }
  
  
  
  1.9.2.1   +31 -15    xml-xalan/java/src/org/apache/xpath/functions/FunctionMultiArgs.java
  
  Index: FunctionMultiArgs.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FunctionMultiArgs.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- FunctionMultiArgs.java	10 Jun 2002 20:47:44 -0000	1.9
  +++ FunctionMultiArgs.java	14 Aug 2002 20:07:00 -0000	1.9.2.1
  @@ -56,14 +56,13 @@
    */
   package org.apache.xpath.functions;
   
  -import java.util.Vector;
  -
  +import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.functions.Function3Args.Arg2Owner;
   import org.apache.xpath.res.XPATHErrorResources;
  -import org.apache.xalan.res.XSLMessages;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -95,21 +94,24 @@
         super.setArg(arg, argNum);
       else
       {
  +      argNum-=3;
         if (null == m_args)
         {
  -        m_args = new Expression[1];
  -        m_args[0] = arg;
  +        m_args = new Expression[argNum+1];
  +        m_args[argNum] = arg;
         }
         else
         {
  -
           // Slow but space conservative.
  -        Expression[] args = new Expression[m_args.length + 1];
  -
  -        System.arraycopy(m_args, 0, args, 0, m_args.length);
  +        if(argNum >= m_args.length)
  +        {
  +          Expression[] args = new Expression[argNum + 1];
  +          System.arraycopy(m_args, 0, args, 0, m_args.length);
  +          m_args = args;
  +        }
   
  -        args[m_args.length] = arg;
  -        m_args = args;
  +        m_args[argNum] = arg;
  +        
         }
         arg.exprSetParent(this);
       }
  @@ -125,14 +127,14 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
       if(null != m_args)
       {
         for (int i = 0; i < m_args.length; i++) 
         {
  -        m_args[i].fixupVariables(vars, globalsSize);
  +        m_args[i].fixupVariables(vcs);
         }
       }
     }
  @@ -261,4 +263,18 @@
   
         return true;
       }
  +    
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	return (i < 3) ? super.exprGetChild(i) : m_args[i - 3];
  +  }
  +
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
  +  {
  +  	return ((null != m_args) ? m_args.length : 0)+super.exprGetNumChildren();
  +  }
  +
   }
  
  
  
  1.9.2.1   +18 -4     xml-xalan/java/src/org/apache/xpath/functions/FunctionOneArg.java
  
  Index: FunctionOneArg.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FunctionOneArg.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- FunctionOneArg.java	10 Jun 2002 20:47:44 -0000	1.9
  +++ FunctionOneArg.java	14 Aug 2002 20:07:00 -0000	1.9.2.1
  @@ -56,11 +56,11 @@
    */
   package org.apache.xpath.functions;
   
  -import java.util.Vector;
  -
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathVisitor;
   
   /**
  @@ -152,10 +152,10 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       if(null != m_arg0)
  -      m_arg0.fixupVariables(vars, globalsSize);
  +      m_arg0.fixupVariables(vcs);
     }
     
     /**
  @@ -205,6 +205,20 @@
     		return false;
   
     	return true;
  +  }
  +
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	assertion(i == 0, "FunctionOneArg only allows index zero to be accessed!");
  +  	return m_arg0;
  +  }
  +
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
  +  {
  +  	return 1;
     }
   
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAddDTDurationToDT.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAddDTDurationToDate.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAddDTDurationToTime.java
  
  
  
  
  1.1.2.1   +103 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAddDayTimeDuration.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAddDays.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAddYMDurationToDT.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAddYMDurationToDate.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncAddYearMonthDuration.java
  
  
  
  
  1.1.2.1   +86 -0     xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncCurrentDate.java
  
  
  
  
  1.1.2.1   +99 -0     xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncCurrentDateTime.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDTDuration.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDTDurationEqual.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDTDurationFromSecs.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDTDurationGT.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDTDurationLT.java
  
  
  
  
  1.1.2.1   +132 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncData.java
  
  
  
  
  1.1.2.1   +87 -0     xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDate.java
  
  
  
  
  1.1.2.1   +102 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDateTime.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDateTimeEq.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDateTimeGT.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDateTimeLT.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDivDayTimeDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDivYearMonthDuration.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncDurationEqual.java
  
  
  
  
  1.1.2.1   +100 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGDay.java
  
  
  
  
  1.1.2.1   +100 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGMonth.java
  
  
  
  
  1.1.2.1   +100 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGMonthDay.java
  
  
  
  
  1.1.2.1   +100 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGYear.java
  
  
  
  
  1.1.2.1   +100 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGYearMonth.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetDFromDT.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetDFromDTDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetDFromDate.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetDTDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetHFromDT.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetHFromDTDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetHFromTime.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetMFromDT.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetMFromDate.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetMFromYMDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetMnFromDT.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetMnFromDTDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetMnFromTime.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetSFromDT.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetSFromDTDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetSFromTime.java
  
  
  
  
  1.1.2.1   +103 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetTZFromDT.java
  
  
  
  
  1.1.2.1   +103 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetTZFromDate.java
  
  
  
  
  1.1.2.1   +103 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetTZFromTime.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetYFromDT.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetYFromDate.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetYFromYMDuration.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncGetYMDuration.java
  
  
  
  
  1.1.2.1   +103 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncMultDayTimeDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncMultYearMonthDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSubDayTimeDuration.java
  
  
  
  
  1.1.2.1   +104 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSubYearMonthDuration.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSubtractDTDurationFromDT.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSubtractDTDurationFromDate.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSubtractDTDurationFromTime.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSubtractYMDurationFromDT.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncSubtractYMDurationFromDate.java
  
  
  
  
  1.1.2.1   +100 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncTime.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncYMDuration.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncYMDurationEqual.java
  
  
  
  
  1.1.2.1   +108 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncYMDurationFromDT.java
  
  
  
  
  1.1.2.1   +105 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncYMDurationFromMonths.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncYMDurationGT.java
  
  
  
  
  1.1.2.1   +107 -0    xml-xalan/java/src/org/apache/xpath/functions/Attic/FuncYMDurationLT.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.11.6.1  +25 -28    xml-xalan/java/src/org/apache/xpath/objects/XBoolean.java
  
  Index: XBoolean.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XBoolean.java,v
  retrieving revision 1.11
  retrieving revision 1.11.6.1
  diff -u -r1.11 -r1.11.6.1
  --- XBoolean.java	22 Mar 2002 01:04:44 -0000	1.11
  +++ XBoolean.java	14 Aug 2002 20:07:03 -0000	1.11.6.1
  @@ -56,6 +56,7 @@
    */
   package org.apache.xpath.objects;
   
  +import org.apache.xml.dtm.XType;
   import org.w3c.dom.*;
   
   /**
  @@ -65,33 +66,26 @@
    */
   public class XBoolean extends XObject
   {
  +	boolean m_val;
   
  -  /**
  -   * <meta name="usage" content="internal"/>
  -   * A true boolean object so we don't have to keep creating them.
  -   */
  -  public static XBoolean S_TRUE = new XBooleanStatic(true);
  -
  -  /**
  -   * <meta name="usage" content="internal"/>
  -   * A true boolean object so we don't have to keep creating them.
  -   */
  -  public static XBoolean S_FALSE = new XBooleanStatic(false);
  +  public final static XBoolean S_TRUE = new XBoolean(true);
  +  public final static XBoolean S_FALSE = new XBoolean(false);
   
  -  /** Value of the object.
  -   *  @serial         */
  -  boolean m_val;
   
     /**
      * Construct a XBoolean object.
  +   * 
  +   * NOTE: Arguably, this should not be a public ctor; folks
  +   * should instead be calling a factory which returns one of
  +   * the statics. Problem with that: If XBoolean ever directly
  +   * implements XSequence, and XSequence behaves as a singleton
  +   * iterator... Count this as downside of that approach.
  +   * %REVIEW%
      *
      * @param b Value of the boolean object
      */
     public XBoolean(boolean b)
     {
  -
  -    super();
  -
       m_val = b;
     }
     
  @@ -102,13 +96,17 @@
      */
     public XBoolean(Boolean b)
     {
  -
  -    super();
  -
       m_val = b.booleanValue();
  -    m_obj = b;
     }
  -
  +  
  +  /**
  +   * Return the sequence representing this object.
  +   * @return XSequence
  +   */
  +  public XSequence xseq()
  +  {
  +    return new XSequenceSingleton(this);
  +  }
   
     /**
      * Tell that this is a CLASS_BOOLEAN.
  @@ -169,9 +167,7 @@
      */
     public Object object()
     {
  -    if(null == m_obj)
  -      m_obj = m_val ? S_TRUE : S_FALSE;
  -    return m_obj;
  +	return m_val ? Boolean.TRUE : Boolean.FALSE;
     }
   
     /**
  @@ -185,12 +181,13 @@
      */
     public boolean equals(XObject obj2)
     {
  -
  +  	// Alternative approach would be implement equals(XNodeset)...?
  +  	
       // In order to handle the 'all' semantics of 
       // nodeset comparisons, we always call the 
       // nodeset function.
  -    if (obj2.getType() == XObject.CLASS_NODESET)
  -      return obj2.equals(this);
  +    if (obj2.isNodesetExpr())
  +      return ((XNodeSet)obj2).equalsExistential(this);
   
       try
       {
  
  
  
  1.21.6.1  +280 -43   xml-xalan/java/src/org/apache/xpath/objects/XNodeSet.java
  
  Index: XNodeSet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XNodeSet.java,v
  retrieving revision 1.21
  retrieving revision 1.21.6.1
  diff -u -r1.21 -r1.21.6.1
  --- XNodeSet.java	22 Mar 2002 01:04:44 -0000	1.21
  +++ XNodeSet.java	14 Aug 2002 20:07:03 -0000	1.21.6.1
  @@ -59,34 +59,38 @@
   //import org.w3c.dom.Node;
   //import org.w3c.dom.Text;
   //import org.w3c.dom.DocumentFragment;
  -import org.w3c.dom.traversal.NodeIterator;
  -import org.w3c.dom.NodeList;
  -
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
   import org.apache.xml.dtm.DTMManager;
  -
  -import org.apache.xpath.DOMHelper;
  -import org.apache.xpath.XPathContext;
  -import org.apache.xpath.NodeSetDTM;
  -import org.apache.xpath.axes.ContextNodeList;
  -import org.apache.xpath.axes.NodeSequence;
  -import org.apache.xml.utils.StringVector;
  +import org.apache.xml.dtm.XType;
  +import org.apache.xml.utils.WrappedRuntimeException;
   import org.apache.xml.utils.XMLString;
  +import org.apache.xpath.NodeSetDTM;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.traversal.NodeIterator;
   
   /**
    * <meta name="usage" content="general"/>
    * This class represents an XPath nodeset object, and is capable of
    * converting the nodeset to other types, such as a string.
    */
  -public class XNodeSet extends NodeSequence
  +public class XNodeSet extends NodeSequence implements XSequence
   {  
  +  XNodeSequenceSingleton m_current;
  +  
  +  
  +  // XNodeSetForDOM (subclass) accesses this member as NodeSetDTM
  +  // NodeSequence (superclass) sometimes uses it as NodeVector
  +  //NodeSetDTM m_obj;
  +  
     /**
      * Default constructor for derived objects.
      */
  +  /*
     protected XNodeSet()
     {
     }
  +  */
   
     /**
      * Construct a XNodeSet object.
  @@ -95,50 +99,78 @@
      */
     public XNodeSet(DTMIterator val)
     {
  -  	super();
     	if(val instanceof XNodeSet)
     	{
  -	    setIter(((XNodeSet)val).m_iter);
  -	    m_dtmMgr = ((XNodeSet)val).m_dtmMgr;
  -	    m_last = ((XNodeSet)val).m_last;
  -	    if(!((XNodeSet)val).hasCache())
  -	    	((XNodeSet)val).setShouldCacheNodes(true);
  -	    m_obj = ((XNodeSet)val).m_obj;
  +		// One would expect an explicit copy ctor to take precedence,
  +		// but apparently it doesn't always do so;
  +		// moving this alternative into XNodeSet(XNodeSet)
  +		// yields erroneous results. I don't quite understand why.
  +
  +  		XNodeSet xns=(XNodeSet)val;
  +	    setIter(xns.m_iter);
  +	    m_dtmMgr = xns.m_dtmMgr;
  +	    m_last = xns.m_last;
  +	    if(!xns.hasCache())
  +	    	xns.setShouldCache(true);
  +	    m_obj = xns.m_obj;
     	}
     	else
  +  	{
       	setIter(val);
  +  		m_dtmMgr=val.getDTMManager(); // Hadn't been being done..?
  +  	}
     }
     
     /**
  -   * Construct a XNodeSet object.
  +   * Construct a XNodeSet object by copying from another XNodeSet
  +   *
  +   * Currently, all copy constructions are being caught by the
  +   * XNodeSet(DTMIterator) ctor. I've disabled this one for
  +   * clarity; we should consider deleting it entirely.
      *
      * @param val Value of the XNodeSet object
      */
  +  /*
     public XNodeSet(XNodeSet val)
     {
  -  	super();
  +  	super(val.getDTMManager());
       setIter(val.m_iter);
       m_dtmMgr = val.m_dtmMgr;
       m_last = val.m_last;
       if(!val.hasCache())
  -    	val.setShouldCacheNodes(true);
  +    	val.setShouldCache(true);
       m_obj = val.m_obj;
     }
  -
  -
  +  */
  +  
  +  /**
  +   * Passthrough for XRTreeFrag(Expression) constructor, since
  +   * c'tors are not inherited and there seems to be no way to 
  +   * invoke super.super.super().
  +   *
  +   * @param frag Document fragment this will wrap
  +   */
  +  /*
  +  protected XNodeSet(org.apache.xpath.Expression expr)
  +  {
  +    super(expr);
  +  }
  +  */
  +    
     /**
      * Construct an empty XNodeSet object.  This is used to create a mutable 
      * nodeset to which random nodes may be added.
      */
     public XNodeSet(DTMManager dtmMgr) 
     {
  -    super(dtmMgr);
  +    this(DTM.NULL,dtmMgr);
     }
   
     /**
  -   * Construct a XNodeSet object for one node.
  +   * Construct a XNodeSet object for one node. (Or empty, if
  +   * the node handle is DTM.NULL.)
      *
  -   * @param n Node to add to the new XNodeSet object
  +   * @param n Handle of DTM node to add to the new XNodeSet object
      */
     public XNodeSet(int n, DTMManager dtmMgr)
     {
  @@ -148,7 +180,7 @@
   
       if (DTM.NULL != n)
       {
  -      ((NodeSetDTM) m_obj).addNode(n);
  +      ((NodeSetDTM)m_obj).addNode(n);
         m_last = 1;
       }
       else
  @@ -164,6 +196,22 @@
     {
       return CLASS_NODESET;
     }
  +  
  +  /**
  +   * @see org.apache.xpath.objects.XObject#getValueType()
  +   */
  +  public int getValueType()
  +  {
  +    int nodeHandle = getCurrentNode();
  +    if (DTM.NULL != nodeHandle)
  +    {
  +      DTM dtm = getDTM(nodeHandle);
  +      
  +      return XType.getTypeID(dtm, nodeHandle);
  +    }
  +    else
  +      return XType.ANYTYPE;
  +  }
   
     /**
      * Given a request type, return the equivalent string.
  @@ -409,6 +457,15 @@
     }
     
     /**
  +   * Return the sequence representing this object.
  +   * @return XSequence
  +   */
  +  public XSequence xseq()
  +  {
  +    return this;
  +  }
  +  
  +  /**
      * Cast result object to a nodelist.
      *
      * @return The nodeset as a nodelist
  @@ -455,20 +512,19 @@
      */
     public NodeSetDTM mutableNodeset()
     {
  -    NodeSetDTM mnl;
  -
  -    if(m_obj instanceof NodeSetDTM)
  -    {
  -      mnl = (NodeSetDTM) m_obj;
  -    }
  -    else
  -    {
  -      mnl = new NodeSetDTM(iter());
  -      m_obj = mnl;
  -      setCurrentPos(0);
  -    }
  -
  -    return mnl;
  +     NodeSetDTM mnl;
  + 
  +     if(m_obj instanceof NodeSetDTM)
  +     {
  +       mnl = (NodeSetDTM) m_obj;
  +     }
  +     else
  +     {
  +       mnl = new NodeSetDTM(iter());
  +       m_obj = mnl;
  +       setCurrentPos(0);
  +     }
  +     return mnl;  	
     }
   
     /** Less than comparator         */
  @@ -507,7 +563,7 @@
       boolean result = false;
       int type = obj2.getType();
   
  -    if (XObject.CLASS_NODESET == type)
  +    if (obj2.isNodesetExpr())
       {
         // %OPT% This should be XMLString based instead of string based...
   
  @@ -719,7 +775,7 @@
     {
       return compare(obj2, S_GTE);
     }
  -
  +  
     /**
      * Tell if two objects are functionally equal.
      *
  @@ -731,6 +787,21 @@
      */
     public boolean equals(XObject obj2)
     {
  +    int nodeHandle = obj2.getNodeHandle();
  +    return nodeHandle == getNodeHandle();
  +  }
  +
  +  /**
  +   * Tell if two objects are functionally equal.
  +   *
  +   * @param obj2 object to compare this nodeset to
  +   *
  +   * @return see this.compare(...) 
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public boolean equalsExistential(XObject obj2)
  +  {
       try
       {
         return compare(obj2, S_EQ);
  @@ -754,6 +825,172 @@
     {
       return compare(obj2, S_NEQ);
     }
  +  
  +  /**
  +   * @see org.apache.xpath.Expression#cloneDeep()
  +   */
  +  public Object cloneDeep() throws CloneNotSupportedException
  +  {
  +    XNodeSet xns = (XNodeSet)super.clone();
  +    if(null != m_iter)
  +      xns.m_iter = (DTMIterator)m_iter.clone();
  +    return xns;
  +  }
  +
  +//  /**
  +//   * @see org.apache.xml.dtm.DTMIterator#cloneWithReset()
  +//   */
  +//  public DTMIterator cloneWithReset() throws CloneNotSupportedException
  +//  {
  +//    DTMIterator clone = super.cloneWithReset();
  +//    return clone;
  +//  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#getCurrent()
  +   */
  +  public XObject getCurrent()
  +  {
  +    if (null == m_current)
  +    {
  +      if (null != m_iter)
  +      {
  +        int nodeHandle = getCurrentNode();
  +        // I don't think it's a good idea here to have m_current 
  +        // get assigned, since next or previous didn't already assign it! 
  +        return new XNodeSequenceSingleton(
  +          nodeHandle,
  +          m_iter.getDTM(nodeHandle));
  +      }
  +      else
  +      {
  +        return null;
  +      }
  +    }
  +    return m_current;
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#getIsRandomAccess()
  +   */
  +  public boolean getIsRandomAccess()
  +  {
  +    return true; // though I'm not sure about this.
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#getTypeLocalName()
  +   */
  +  public String getTypeLocalName()
  +  {
  +    int nodeHandle = getCurrentNode();
  +    if (DTM.NULL != nodeHandle)
  +    {
  +      DTM dtm = getDTM(nodeHandle);
  +
  +      return dtm.getSchemaTypeLocalName(nodeHandle);
  +    }
  +    else
  +      return null;
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#getTypeNS()
  +   */
  +  public String getTypeNS()
  +  {
  +    int nodeHandle = getCurrentNode();
  +    if (DTM.NULL != nodeHandle)
  +    {
  +      DTM dtm = getDTM(nodeHandle);
  +      return dtm.getSchemaTypeNamespace(nodeHandle);
  +    }
  +    else
  +      return null;
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#getTypes()
  +   */
  +  public int getTypes()
  +  {
  +    return XType.ANYTYPE; // don't try to predict yet.
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#isPureNodeSequence()
  +   */
  +  public boolean isPureNodeSequence()
  +  {
  +    return true;
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#isSchemaType(String, String)
  +   */
  +  public boolean isSchemaType(String namespace, String localname)
  +  {
  +    int nodeHandle = getCurrentNode();
  +    if (DTM.NULL != nodeHandle)
  +    {
  +      DTM dtm = getDTM(nodeHandle);
  +      return dtm.isNodeSchemaType(nodeHandle, namespace, localname);
  +    }
  +    else
  +      return false;
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#isSingletonOrEmpty()
  +   */
  +  public boolean isSingletonOrEmpty()
  +  {
  +    return false;
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#next()
  +   */
  +  public XObject next()
  +  {
  +    int node = nextNode();
  +    if (DTM.NULL == node)
  +      m_current = null;
  +    else
  +      m_current = new XNodeSequenceSingleton(node, this);
  +    return m_current;
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XSequence#previous()
  +   */
  +  public XObject previous()
  +  {
  +    int node = previousNode();
  +    if (DTM.NULL == node)
  +      m_current = null;
  +    else
  +      m_current = new XNodeSequenceSingleton(node, this);
  +    return m_current;
  +  }
  +
  +  /**
  +   * @see org.apache.xpath.objects.XObject#isSequenceProper()
  +   */
  +  public boolean isSequenceProper()
  +  {
  +    return true;
  +  }
  +
  +
  +  /**
  +   * @see org.apache.xpath.objects.XObject#getNodeHandle()
  +   */
  +  public int getNodeHandle()
  +  {
  +    return getCurrentNode();
  +  }
  +
   }
   
   /**
  
  
  
  1.3.4.1   +35 -13    xml-xalan/java/src/org/apache/xpath/objects/XNodeSetForDOM.java
  
  Index: XNodeSetForDOM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XNodeSetForDOM.java,v
  retrieving revision 1.3
  retrieving revision 1.3.4.1
  diff -u -r1.3 -r1.3.4.1
  --- XNodeSetForDOM.java	14 May 2002 15:57:03 -0000	1.3
  +++ XNodeSetForDOM.java	14 Aug 2002 20:07:03 -0000	1.3.4.1
  @@ -16,43 +16,65 @@
   {
     Object m_origObj;
   
  -  public XNodeSetForDOM(Node node, DTMManager dtmMgr)
  -  {
  -    m_dtmMgr = dtmMgr;
  -    m_origObj = node;
  -    int dtmHandle = dtmMgr.getDTMHandleFromNode(node);
  -    m_obj = new NodeSetDTM(dtmMgr);
  -    ((NodeSetDTM) m_obj).addNode(dtmHandle);
  -  }
  -  
     /**
  -   * Construct a XNodeSet object.
  +   * Wrap an XNodeSetForDOM around another XNodeset
      *
      * @param val Value of the XNodeSet object
      */
  +  /*
     public XNodeSetForDOM(XNodeSet val)
     {
     	super(val);
     	if(val instanceof XNodeSetForDOM)
  +  	{
       	m_origObj = ((XNodeSetForDOM)val).m_origObj;
  +  	}
  +  }
  +  */
  +
  +  /**
  +   * Wrap an XNodeSetForDOM around a single DOM Node.
  +   * 
  +   * (Interesting that this one takes the DTM Manager explicitly
  +   * while others get it via the xctxt. Should we reconcile?)
  +   *
  +   */
  +  public XNodeSetForDOM(Node node, DTMManager dtmMgr)
  +  {
  +    super(dtmMgr);
  +    m_origObj = node;
  +    int dtmHandle = dtmMgr.getDTMHandleFromNode(node);
  +    
  +	NodeSetDTM nsdtm = new NodeSetDTM(dtmMgr);
  +    nsdtm.addNode(dtmHandle);  
  +    m_obj=nsdtm;
     }
     
  +  /**
  +   * Wrap an XNodeSetForDOM around a DOM NodeList
  +   *
  +   */
     public XNodeSetForDOM(NodeList nodeList, XPathContext xctxt)
     {
  -    m_dtmMgr = xctxt.getDTMManager();
  +    super(xctxt.getDTMManager());
       m_origObj = nodeList;
   
       // JKESS 20020514: Longer-term solution is to force
       // folks to request length through an accessor, so we can defer this
       // retrieval... but that requires an API change.
       // m_obj=new org.apache.xpath.NodeSetDTM(nodeList, xctxt);
  -    org.apache.xpath.NodeSetDTM nsdtm=new org.apache.xpath.NodeSetDTM(nodeList, xctxt);
  +    NodeSetDTM nsdtm=new org.apache.xpath.NodeSetDTM(nodeList, xctxt);
       m_last=nsdtm.getLength();
       m_obj = nsdtm;   
     }
   
  +  /**
  +   * Wrap an XNodeSetForDOM around a DOM NodeIterator
  +   *
  +   */
     public XNodeSetForDOM(NodeIterator nodeIter, XPathContext xctxt)
     {
  +    super(xctxt.getDTMManager());
       m_dtmMgr = xctxt.getDTMManager();
       m_origObj = nodeIter;
   
  @@ -60,7 +82,7 @@
       // folks to request length through an accessor, so we can defer this
       // retrieval... but that requires an API change.
       // m_obj = new org.apache.xpath.NodeSetDTM(nodeIter, xctxt);
  -    org.apache.xpath.NodeSetDTM nsdtm=new org.apache.xpath.NodeSetDTM(nodeIter, xctxt);
  +    NodeSetDTM nsdtm=new org.apache.xpath.NodeSetDTM(nodeIter, xctxt);
       m_last=nsdtm.getLength();
       m_obj = nsdtm;   
     }
  
  
  
  1.9.6.1   +12 -4     xml-xalan/java/src/org/apache/xpath/objects/XNull.java
  
  Index: XNull.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XNull.java,v
  retrieving revision 1.9
  retrieving revision 1.9.6.1
  diff -u -r1.9 -r1.9.6.1
  --- XNull.java	28 Mar 2002 21:00:04 -0000	1.9
  +++ XNull.java	14 Aug 2002 20:07:03 -0000	1.9.6.1
  @@ -60,10 +60,8 @@
   //import org.w3c.dom.DocumentFragment;
   
   import org.apache.xml.dtm.DTM;
  -import org.apache.xml.dtm.DTMIterator;
  -
  +import org.apache.xml.dtm.DTMManager;
   import org.apache.xpath.XPathContext;
  -import org.apache.xpath.NodeSetDTM;
   
   /**
    * <meta name="usage" content="general"/>
  @@ -78,7 +76,7 @@
      */
     public XNull()
     {
  -    super();
  +    super((DTMManager)null); // compile-time cast is needed
     }
   
     /**
  @@ -168,4 +166,14 @@
     {
       return obj2.getType() == CLASS_NULL;
     }
  +  
  +  /**
  +   * Return the sequence representing this object.
  +   * @return XSequence
  +   */
  +  public XSequence xseq()
  +  {
  +    return XSequence.EMPTY;
  +  }
  +
   }
  
  
  
  1.13.6.1  +39 -58    xml-xalan/java/src/org/apache/xpath/objects/XNumber.java
  
  Index: XNumber.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XNumber.java,v
  retrieving revision 1.13
  retrieving revision 1.13.6.1
  diff -u -r1.13 -r1.13.6.1
  --- XNumber.java	22 Mar 2002 01:04:44 -0000	1.13
  +++ XNumber.java	14 Aug 2002 20:07:03 -0000	1.13.6.1
  @@ -66,38 +66,29 @@
    * This class represents an XPath number, and is capable of
    * converting the number to other types, such as a string.
    */
  -public class XNumber extends XObject
  +public abstract class XNumber extends XObject
   {
  -
  -  /** Value of the XNumber object.
  -   *  @serial         */
  -  double m_val;
  -
     /**
      * Construct a XNodeSet object.
      *
      * @param d Value of the object
      */
  -  public XNumber(double d)
  +  protected XNumber()
     {
  -    super();
  -
  -    m_val = d;
     }
  -  
  +
  +
     /**
      * Construct a XNodeSet object.
      *
      * @param d Value of the object
      */
  +  /*
     public XNumber(Number num)
     {
  -
  -    super();
  -
  -    m_val = num.doubleValue();
  -    m_obj = num;
  +    super(num);
     }
  +  */
   
     /**
      * Tell that this is a CLASS_NUMBER.
  @@ -120,39 +111,6 @@
       return "#NUMBER";
     }
   
  -  /**
  -   * Cast result object to a number.
  -   *
  -   * @return the value of the XNumber object
  -   */
  -  public double num()
  -  {
  -    return m_val;
  -  }
  -  
  -  /**
  -   * Evaluate expression to a number.
  -   *
  -   * @return 0.0
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  public double num(XPathContext xctxt) 
  -    throws javax.xml.transform.TransformerException
  -  {
  -
  -    return m_val;
  -  }
  -
  -  /**
  -   * Cast result object to a boolean.
  -   *
  -   * @return false if the value is NaN or equal to 0.0
  -   */
  -  public boolean bool()
  -  {
  -    return (Double.isNaN(m_val) || (m_val == 0.0)) ? false : true;
  -  }
   
   //  /**
   //   * Cast result object to a string.
  @@ -312,20 +270,27 @@
      */
     public String str()
     {
  -
  -    if (Double.isNaN(m_val))
  +  	double num;
  +  	try 
  +  	{
  +    	num = num(); 
  +    } 
  +    catch(TransformerException te) 
  +    {
  +    	throw new RuntimeException(te.getMessage()); 
  +    }
  +    if (Double.isNaN(num))
       {
         return "NaN";
       }
  -    else if (Double.isInfinite(m_val))
  +    else if (Double.isInfinite(num))
       {
  -      if (m_val > 0)
  +      if (num > 0)
           return "Infinity";
         else
           return "-Infinity";
       }
   
  -    double num = m_val;
       String s = Double.toString(num);
       int len = s.length();
   
  @@ -401,12 +366,26 @@
      *
      * @return The value of this XNumber as a Double object
      */
  -  public Object object()
  +  abstract public Object object();
  +  /*
     {
       if(null == m_obj)
  -      m_obj = new Double(m_val);
  +    {
  +	  double num;
  +	  try 
  +	  {
  +	    num = num(); 
  +	  } 
  +	  catch(TransformerException te) 
  +	  {
  +	    throw new RuntimeException(te.getMessage()); 
  +	  }
  +
  +      m_obj = new Double(num);
  +    }
       return m_obj;
     }
  +  */
   
     /**
      * Tell if two objects are functionally equal.
  @@ -427,11 +406,13 @@
       try
       {
   	    if (t == XObject.CLASS_NODESET)
  -	      return obj2.equals(this);
  +	      return ((XNodeSet)obj2).equalsExistential(this);
   	    else if(t == XObject.CLASS_BOOLEAN)
   	      return obj2.bool() == bool();
   		else
  -	       return m_val == obj2.num();
  +		{
  +	       return num() == obj2.num();
  +		}
       }
       catch(javax.xml.transform.TransformerException te)
       {
  
  
  
  1.20.6.1  +316 -49   xml-xalan/java/src/org/apache/xpath/objects/XObject.java
  
  Index: XObject.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XObject.java,v
  retrieving revision 1.20
  retrieving revision 1.20.6.1
  diff -u -r1.20 -r1.20.6.1
  --- XObject.java	29 Mar 2002 15:18:39 -0000	1.20
  +++ XObject.java	14 Aug 2002 20:07:03 -0000	1.20.6.1
  @@ -56,24 +56,26 @@
    */
   package org.apache.xpath.objects;
   
  -import org.w3c.dom.DocumentFragment;
  -//import org.w3c.dom.Text;
  -//import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  -import org.w3c.dom.traversal.NodeIterator;
  -import org.apache.xml.dtm.*;
  -
   import java.io.Serializable;
   
  -import org.apache.xpath.res.XPATHErrorResources;
  +import org.apache.xalan.res.XSLMessages;
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xml.dtm.XType;
  +import org.apache.xml.utils.DateTimeObj;
  +import org.apache.xml.utils.Duration;
  +import org.apache.xml.utils.XMLString;
  +import org.apache.xpath.Expression;
   import org.apache.xpath.ExpressionOwner;
  -import org.apache.xpath.XPathContext;
   import org.apache.xpath.NodeSetDTM;
  +import org.apache.xpath.VariableComposeState;
  +import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathException;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xalan.res.XSLMessages;
  -import org.apache.xpath.Expression;
  -import org.apache.xml.utils.XMLString;
  +import org.apache.xpath.res.XPATHErrorResources;
  +import org.w3c.dom.DocumentFragment;
  +import org.w3c.dom.NodeList;
  +import org.w3c.dom.traversal.NodeIterator;
   
   /**
    * <meta name="usage" content="general"/>
  @@ -81,31 +83,36 @@
    * converting the object to various types, such as a string.
    * This class acts as the base class to other XPath type objects,
    * such as XString, and provides polymorphic casting capabilities.
  + * 
  + * Caveat: Default method implementations provided herein may be
  + * inefficient, since they have to retrieve the "contained object"
  + * which may not exist until demanded.
    */
  -public class XObject extends Expression implements Serializable, Cloneable
  +public abstract class XObject extends Expression implements Serializable, Cloneable
   {
  -
     /**
  -   * The java object which this object wraps.
  -   *  @serial  
  -   */
  -  protected Object m_obj;  // This may be NULL!!!
  -
  -  /**
  -   * Create an XObject.
  -   */
  -  public XObject(){}
  +   * Create an undifferentiated XObject.
  +   * Note: Abstract methods can't be constructed...
  +   * ... and constructors don't inherit, even as abstracts.
  +   */
  +  /*
  +  protected XObject(){}
  +  */
   
     /**
      * Create an XObject.
  +   * Note: Abstract methods can't be constructed...
  +   * ... and constructors don't inherit, even as abstracts.
      *
      * @param obj Can be any object, should be a specific type
      * for derived classes, or null.
      */
  -  public XObject(Object obj)
  +  /*
  +  protected XObject(Object obj)
     {
  -    m_obj = obj;
  +    //m_obj = obj;
     }
  +  */
   
     /**
      * For support of literal objects in xpaths.
  @@ -150,12 +157,15 @@
     public void destruct()
     {
   
  -    if (null != m_obj)
  +    if (null != object())
       {
         allowDetachToRelease(true);
         detach();
  -
  -      m_obj = null;
  +      
  +      // %BUG% When m_obj was part of this class, we were
  +      // nulling it out at this point. Do we need to move
  +      // this logic down into the subclasses?
  +	  //	  m_obj = null;
       }
     }
     
  @@ -216,22 +226,57 @@
     public static final int CLASS_NULL = -1;
   
     /** Constant for UNKNOWN object type */
  -  public static final int CLASS_UNKNOWN = 0;
  +  public static final int CLASS_UNKNOWN = XType.ANYTYPE;
   
     /** Constant for BOOLEAN  object type */
  -  public static final int CLASS_BOOLEAN = 1;
  +  public static final int CLASS_BOOLEAN = XType.BOOLEAN;
   
     /** Constant for NUMBER object type */
  -  public static final int CLASS_NUMBER = 2;
  +  public static final int CLASS_NUMBER = XType.DOUBLE;
   
     /** Constant for STRING object type */
  -  public static final int CLASS_STRING = 3;
  +  public static final int CLASS_STRING = XType.STRING;
   
     /** Constant for NODESET object type */
  -  public static final int CLASS_NODESET = 4;
  +  public static final int CLASS_NODESET = XType.NODE;
   
     /** Constant for RESULT TREE FRAGMENT object type */
  -  public static final int CLASS_RTREEFRAG = 5;
  +  public static final int CLASS_RTREEFRAG = XType.RTREEFRAG;
  +	
  +	/** Constant for DATE object type */
  +  public static final int CLASS_DATE = XType.DATE;
  +  
  +  /** Constant for DATETIME object type */
  +  public static final int CLASS_DATETIME = XType.DATETIME;
  +  
  +  /** Constant for DURATION object type */
  +  public static final int CLASS_DURATION = XType.DURATION;
  +  
  +  /** Constant for DURATION object type */
  +  public static final int CLASS_YMDURATION = XType.YEARMONTHDURATION;
  +
  +
  +/** Constant for DURATION object type */
  +  public static final int CLASS_DTDURATION = XType.DAYTIMEDURATION;
  +
  +  
  +  /** Constant for TIME object type */
  +  public static final int CLASS_TIME = XType.TIME;
  +  
  +  /** Constant for GDAY object type */
  +  public static final int CLASS_GDAY = XType.GDAY;
  +  
  +  /** Constant for GMONTH object type */
  +  public static final int CLASS_GMONTH = XType.GMONTH;
  +  
  +  /** Constant for GMONTHDAY object type */
  +  public static final int CLASS_GMONTHDAY = XType.GMONTHDAY;
  +  
  +  /** Constant for GYEAR object type */
  +  public static final int CLASS_GYEAR = XType.GYEAR;
  +  
  +  /** Constant for GYEARMONTH object type */
  +  public static final int CLASS_GYEARMONTH = XType.GYEARMONTH;
   
     /** Represents an unresolved variable type as an integer. */
     public static final int CLASS_UNRESOLVEDVARIABLE = 600;
  @@ -245,6 +290,19 @@
     {
       return CLASS_UNKNOWN;
     }
  +  
  +  /**
  +   * Get the type of the value that this object represents.
  +   * For most objects this is the same as getType(), but for 
  +   * nodes it is the type of the inner value.
  +   *
  +   * @return one of the 19 simple types from XType.
  +   */
  +  public int getValueType()
  +  {
  +    return getType();
  +  }
  +
   
     /**
      * Given a request type, return the equivalent string.
  @@ -274,6 +332,34 @@
     }
     
     /**
  +   * Get result object as a integer.
  +   *
  +   * @return At this level, the num() value cast to an integer.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public int integer() throws javax.xml.transform.TransformerException
  +  {
  +
  +    return (int)num();
  +  }
  +  
  +  /**
  +   * Get result object as a integer.
  +   *
  +   * @return At this level, the num() value cast to an integer.
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public float floatVal() throws javax.xml.transform.TransformerException
  +  {
  +
  +    return (float)num();
  +  }
  +
  +
  +  
  +  /**
      * Cast result object to a number, but allow side effects, such as the 
      * incrementing of an iterator.
      *
  @@ -330,7 +416,8 @@
      */
     public String str()
     {
  -    return (m_obj != null) ? m_obj.toString() : "";
  +  	Object obj=object();
  +    return (obj != null) ? obj.toString() : "";
     }
   
     /**
  @@ -426,9 +513,30 @@
      *
      * @return The object that this class wraps
      */
  -  public Object object()
  +  abstract public Object object();
  +  
  +  /**
  +   * Return the sequence representing this object.
  +   * @return XSequence
  +   */
  +  public XSequence xseq()
     {
  -    return m_obj;
  +  	Object obj=object();
  +    try
  +    {
  +      // This feels a bit heavy weight, but most of the 
  +      // derived classes will override this method.
  +      if(null == obj || getType() == CLASS_NULL)
  +        return XSequence.EMPTY;
  +      else if(obj instanceof XSequence)
  +        return (XSequence)((XSequence)obj).clone(); // Clone??
  +      else
  +        return new XSequenceSingleton(this);
  +    }
  +    catch (CloneNotSupportedException e)
  +    {
  +      return (XSequence)obj;
  +    }
     }
   
     /**
  @@ -489,6 +597,18 @@
   
       return null;
     }
  +  
  +  /**
  +   * Get the node representation of this object, or return DTM.NULL if 
  +   * there is no node representation.
  +   * 
  +   * @return int DTM.NULL if there is no node representation, or the 
  +   * node handle.
  +   */
  +  public int getNodeHandle()
  +  {
  +    return DTM.NULL;
  +  }
   
   
     /**
  @@ -505,7 +625,7 @@
       error(XPATHErrorResources.ER_CANT_CONVERT_TO_MUTABLENODELIST,
             new Object[]{ getTypeString() });  //"Can not convert "+getTypeString()+" to a NodeSetDTM!");
   
  -    return (NodeSetDTM) m_obj;
  +    return (NodeSetDTM) object();
     }
   
     /**
  @@ -539,7 +659,7 @@
         result = new Boolean(bool());
         break;
       case CLASS_UNKNOWN :
  -      result = m_obj;
  +      result = object();
         break;
   
       // %TBD%  What to do here?
  @@ -662,25 +782,44 @@
      *
      * @throws javax.xml.transform.TransformerException
      */
  -  public boolean equals(XObject obj2)
  +  public boolean equalsExistential(XObject obj2)
     {
  -
       // In order to handle the 'all' semantics of 
       // nodeset comparisons, we always call the 
       // nodeset function.
  -    if (obj2.getType() == XObject.CLASS_NODESET)
  -      return obj2.equals(this);
  -
  -    if (null != m_obj)
  +    if (obj2.isNodesetExpr())
       {
  -      return m_obj.equals(obj2.m_obj);
  +      // Note: obj2 _must_ overload this function, or we
  +      // dive into infinite recursion if "this" is also a
  +      // nodeset.
  +      return obj2.equalsExistential(this);
       }
  +
  +    return equals(obj2);
  +  }
  +
  +  /**
  +   * Tell if two objects are functionally equal.
  +   *
  +   * @param obj2 Object to compare this to
  +   *
  +   * @return True if this object is equal to the given object
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public boolean equals(XObject obj2)
  +  {
  +    Object obj = object();
  +    if (null != obj)
  +      return obj.equals(obj2.object());
       else
       {
  -      return obj2.m_obj == null;
  +      return obj2.object() == null;
       }
     }
   
  +  
  +
     /**
      * Tell if two objects are functionally not equal.
      *
  @@ -746,7 +885,7 @@
     /**
      * XObjects should not normally need to fix up variables.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       // no-op
     }
  @@ -782,10 +921,138 @@
     	// If equals at the expression level calls deepEquals, I think we're 
     	// still safe from infinite recursion since this object overrides 
     	// equals.  I hope.
  -  	if(!this.equals((XObject)expr))
  +  	if(!this.equalsExistential((XObject)expr))
     		return false;
     		
     	return true;
  +  }
  +  
  +  /**
  +   * Tell if this node should have it's PathExpr ancestory reduced.
  +   */
  +  public boolean isPathExprReduced()
  +  {
  +  	return true;
  +  }
  +  
  +  /**
  +   * Tell if this item is a proper sequence, or should be treated as a 
  +   * value.  This is needed for nested sequences (we implement sequences 
  +   * as nested, even though it appears from the caller's perspective and 
  +   * from XPath's perspective that sequences are not nested).  XObjects 
  +   * that return true from this method must implement XSequence, though not 
  +   * all XObjects that implement XSequence must return true from this 
  +   * method.
  +   * @return true if this sequence can be treated as a value or node, falst 
  +   *          if this is a proper sequence.
  +   */
  +  public boolean isSequenceProper()
  +  {
  +    return false;
  +  }
  +
  +  /**
  +   * @see org.apache.xml.dtm.XSequence#isSingletonOrEmpty()
  +   */
  +  public boolean isSingletonOrEmpty()
  +  {
  +    return true;
  +  }
  +
  +  /**
  +   * Cast result object to a DURATION.
  +   *
  +   * @return Duration
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public Duration duration() throws javax.xml.transform.TransformerException
  +  {
  +
  +    error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
  +          new Object[]{ getTypeString(), "DURATION" });  //"Can not convert "+getTypeString()+" to a number");
  +
  +    return null; // To shut up compiler
  +  }
  +  
  +  /**
  +   * Cast result object to a DAYTIMEDURATION.
  +   *
  +   * @return Duration
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public Duration daytimeDuration() throws javax.xml.transform.TransformerException
  +  {
  +
  +    error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
  +          new Object[]{ getTypeString(), "DAYTIMEDURATION" });  //"Can not convert "+getTypeString()+" to a number");
  +
  +    return null; // To shut up compiler
  +  }
  +  
  +  /**
  +   * Cast result object to a YEARMONTHDURATION.
  +   *
  +   * @return Duration
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public Duration yearmonthDuration() throws javax.xml.transform.TransformerException
  +  {
  +
  +    error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
  +          new Object[]{ getTypeString(), "YEARMONTHDURATION" });  //"Can not convert "+getTypeString()+" to a number");
  +
  +    return null; // To shut up compiler
  +  }
  +
  +  /**
  +   * Cast result object to a DATE.
  +   *
  +   * @return DateTimeObj
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public DateTimeObj date() throws javax.xml.transform.TransformerException
  +  {
  +
  +    error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
  +          new Object[]{ getTypeString(), "DATE" });  //"Can not convert "+getTypeString()+" to a number");
  +
  +    return null; // To shut up compiler
  +  }
  +  
  +  /**
  +   * Cast result object to a DATETIME.
  +   *
  +   * @return DateTimeObj
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public DateTimeObj datetime() throws javax.xml.transform.TransformerException
  +  {
  +
  +    error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
  +          new Object[]{ getTypeString(), "DATETIME" });  //"Can not convert "+getTypeString()+" to a number");
  +
  +    return null; // To shut up compiler
  +  }
  +
  +  /**
  +   * Cast result object to a TIME.
  +   *
  +   * @return DateTimeObj
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public DateTimeObj time() throws javax.xml.transform.TransformerException
  +  {
  +
  +    error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
  +          new Object[]{ getTypeString(), "TIME" });  //"Can not convert "+getTypeString()+" to a number");
  +
  +    return null; // To shut up compiler
     }
   
   }
  
  
  
  1.2.14.1  +25 -6     xml-xalan/java/src/org/apache/xpath/objects/XObjectFactory.java
  
  Index: XObjectFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XObjectFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.2.14.1
  diff -u -r1.2 -r1.2.14.1
  --- XObjectFactory.java	7 Aug 2001 19:16:43 -0000	1.2
  +++ XObjectFactory.java	14 Aug 2002 20:07:03 -0000	1.2.14.1
  @@ -1,6 +1,8 @@
   package org.apache.xpath.objects;
   
   import org.apache.xml.dtm.*;
  +import org.apache.xml.utils.DateTimeObj;
  +import org.apache.xml.utils.Duration;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.NodeSetDTM;
   import org.apache.xpath.axes.OneStepIterator;
  @@ -37,16 +39,21 @@
       }
       else if (val instanceof Double)
       {
  -      result = new XNumber(((Double) val));
  +      result = new XDouble(((Double) val));
       }
  -    else
  +    else if (val instanceof Integer)
       {
  -      result = new XObject(val);
  +      result = new XInteger(((Integer) val)); 
  +    }
  +    else
  +    { 
  +      result = new XJavaObject(val);
       }
   
       return result;
     }
     
  +  
     /**
      * Create the right XObject based on the type of the object passed.
      * This function <emph>can</emph> make an XObject that exposes DOM Nodes, NodeLists, and 
  @@ -74,9 +81,21 @@
       {
         result = new XBoolean((Boolean)val);
       }
  -    else if (val instanceof Number)
  +    else if (val instanceof Double)
  +    {
  +      result = new XDouble(((Double) val));
  +    }
  +    else if (val instanceof Integer)
  +    {
  +      result = new XInteger(((Integer) val));
  +    }
  +    else if (val instanceof DateTimeObj)
  +    {
  +      result = new XDateTime((DateTimeObj) val);
  +    }
  +    else if (val instanceof Duration)
       {
  -      result = new XNumber(((Number) val));
  +      result = new XDuration((Duration) val);
       }
       else if (val instanceof DTM)
       {
  @@ -131,7 +150,7 @@
       }
       else
       {
  -      result = new XObject(val);
  +      result = new XJavaObject(val);
       }
   
       return result;
  
  
  
  1.25.2.1  +81 -79    xml-xalan/java/src/org/apache/xpath/objects/XRTreeFrag.java
  
  Index: XRTreeFrag.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XRTreeFrag.java,v
  retrieving revision 1.25
  retrieving revision 1.25.2.1
  diff -u -r1.25 -r1.25.2.1
  --- XRTreeFrag.java	7 Aug 2002 22:13:56 -0000	1.25
  +++ XRTreeFrag.java	14 Aug 2002 20:07:03 -0000	1.25.2.1
  @@ -58,6 +58,7 @@
   
   import javax.xml.transform.TransformerException;
   import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMManager;
   import org.apache.xml.dtm.DTMIterator;
   import org.apache.xml.utils.FastStringBuffer;
   import org.apache.xml.utils.XMLString;
  @@ -66,34 +67,16 @@
   import org.apache.xpath.XPathContext;
   import org.w3c.dom.NodeList;
   
  -import org.apache.xml.dtm.Axis;
  -import org.apache.xpath.axes.RTFIterator;
  -
   /**
    * <meta name="usage" content="general"/>
    * This class represents an XPath result tree fragment object, and is capable of
    * converting the RTF to other types, such as a string.
    */
  -public class XRTreeFrag extends XObject implements Cloneable
  +public class XRTreeFrag extends XNodeSet implements Cloneable
   {
  -  DTM m_dtm;
  -  int m_dtmRoot;
  -  XPathContext m_xctxt;
  -  boolean m_allowRelease = false;
  -
  -//  /**
  -//   * Create an XRTreeFrag Object.
  -//   *
  -//   * @param frag Document fragment this will wrap
  -//   */
  -//  public XRTreeFrag(DTMIterator frag)
  -//  {
  -//    super(frag);
  -//    
  -//    // Obviously, this constructor should be avoided when possible.
  -//    m_dtmRoot = frag.cloneWithReset().nextNode();
  -//  }
  -  
  +  DTM m_dtm=null; // For possible storage management during finalize/destruct
  +  boolean m_allowRelease;
  +
     /**
      * Create an XRTreeFrag Object.
      *
  @@ -101,13 +84,13 @@
      */
     public XRTreeFrag(int root, XPathContext xctxt, ExpressionNode parent)
     {
  -    super(null);
  +    super(root,xctxt);
       
  -    // Obviously, this constructor should be avoided when possible.
       exprSetParent(parent);
  -    m_dtmRoot = root;
  -    m_xctxt = xctxt;
  +
       m_dtm = xctxt.getDTM(root);
  +    
  +    m_iter=xctxt.createDTMIterator(root);
     }
     
     /**
  @@ -117,43 +100,36 @@
      */
     public XRTreeFrag(int root, XPathContext xctxt)
     {
  -    super(null);
  -    
  -    // Obviously, this constructor should be avoided when possible.
  -    m_dtmRoot = root;
  -    m_xctxt = xctxt;
  +    super(root,xctxt);
  +
       m_dtm = xctxt.getDTM(root);
  +    m_iter=xctxt.createDTMIterator(root);
     }
   
  -  
  -  /**
  -   * Return a java object that's closest to the representation
  -   * that should be handed to an extension.
  -   *
  -   * @return The object that this class wraps
  -   */
  -  public Object object()
  -  {
  -    if (m_xctxt != null)
  -      return new org.apache.xml.dtm.ref.DTMNodeIterator((DTMIterator)(new org.apache.xpath.NodeSetDTM(m_dtmRoot, m_xctxt.getDTMManager())));
  -    else
  -      return super.object();
  -  }
  -  
     /**
      * Create an XRTreeFrag Object.
      *
      * @param frag Document fragment this will wrap
      */
  -  public XRTreeFrag(Expression expr)
  +  /*
  +  private XRTreeFrag(Expression expr)
     {
       super(expr);
  +    
  +    // Can't retrieve m_iter until the expression has been executed.
  +    // Can't execute without an XCTXT.
  +    // Can't win.
  +    // Should this constructor exist at all? It seems to be here to support
  +    // XRTreeFragSelectWrapper... but I'm not sure that should be considered
  +    // an RTF rather than an XNodeSet!!!
     }
  -  
  +  */
  +
     /**
      * Release any resources this object may have by calling destruct().
  -   * %ISSUE% This release will occur asynchronously. Resources it manipulates
  -   * MUST be thread-safe!
  +   * 
  +   * STRONG WARNING: This release will occur asynchronously. Resources it 
  +   * manipulates MUST be thread-safe!
      *
      * @throws Throwable
      */
  @@ -193,16 +169,14 @@
     {
       if(m_allowRelease)
       {
  -    	// %REVIEW% Do we actually _need_ detach, now that DTM RTF
  -    	// storage is managed as a stack?
         // See #destruct() for a comment about this next check.
  -      int ident = m_xctxt.getDTMIdentity(m_dtm);
  -      DTM foundDTM = m_xctxt.getDTM(ident);      
  +      int ident = m_dtmMgr.getDTMIdentity(m_dtm);
  +      DTM foundDTM = m_dtmMgr.getDTM(ident);      
         if(foundDTM == m_dtm)
         {
  -        m_xctxt.release(m_dtm, true);
  +        m_dtmMgr.release(m_dtm, true);
           m_dtm = null;
  -        m_xctxt = null;
  +        m_dtmMgr = null;
         }
         m_obj = null;
       }
  @@ -234,13 +208,13 @@
         //    getDTMIdentity(dtm)).
         // 6) Transform#2 tries to reference DTMManagerDefault#m_dtms[2], finds it is 
         //    null, and chaos results.
  -      int ident = m_xctxt.getDTMIdentity(m_dtm);
  -      DTM foundDTM = m_xctxt.getDTM(ident);      
  +      int ident = m_dtmMgr.getDTMIdentity(m_dtm);
  +      DTM foundDTM = m_dtmMgr.getDTM(ident);      
         if(foundDTM == m_dtm)
         {
  -        m_xctxt.release(m_dtm, true);
  +        m_dtmMgr.release(m_dtm, true);
           m_dtm = null;
  -        m_xctxt = null;
  +        m_dtmMgr = null;
         }
       }
       m_obj = null;
  @@ -248,6 +222,7 @@
   
     /**
      * Tell what kind of class this is.
  +   * %REVIEW% Should we really be distinguishing RTF from other NodeSets?
      *
      * @return type CLASS_RTREEFRAG 
      */
  @@ -259,6 +234,7 @@
     /**
      * Given a request type, return the equivalent string.
      * For diagnostic purposes.
  +   * %REVIEW% Should we really be distinguishing RTF from other NodeSets?
      *
      * @return type string "#RTREEFRAG"
      */
  @@ -269,13 +245,13 @@
   
     /**
      * Cast result object to a number.
  +   * Note that this is different from XNodeSet's definition; we convert
  +   * the entire string content, not just item(0).
      *
      * @return The result tree fragment as a number or NaN
      */
     public double num()
  -    throws javax.xml.transform.TransformerException
     {
  -
       XMLString s = xstr();
   
       return s.toDouble();
  @@ -296,19 +272,23 @@
     
     /**
      * Cast result object to an XMLString.
  +   * Note that this is different from XNodeSet's definition; we convert
  +   * the entire string content, not just item(0).
      *
      * @return The document fragment node data or the empty string. 
      */
     public XMLString xstr()
     {
       if(null == m_xmlStr)
  -      m_xmlStr = m_dtm.getStringValue(m_dtmRoot);
  +      m_xmlStr = m_dtm.getStringValue(item(0));
       
       return m_xmlStr;
     }
     
     /**
  -   * Cast result object to a string.
  +   * Append result object's content to a FastStringBuffer.
  +   * Note that this is different from XNodeSet's definition; we convert
  +   * the entire string content, not just item(0).
      *
      * @return The string this wraps or the empty string if null
      */
  @@ -321,12 +301,14 @@
   
     /**
      * Cast result object to a string.
  +   * Note that this is different from XNodeSet's definition; we convert
  +   * the entire string content, not just item(0).
      *
      * @return The document fragment node data or the empty string. 
      */
     public String str()
     {
  -    String str = m_dtm.getStringValue(m_dtmRoot).toString();
  +    String str = m_dtm.getStringValue(item(0)).toString();
   
       return (null == str) ? "" : str;
     }
  @@ -334,41 +316,61 @@
     /**
      * Cast result object to a result tree fragment.
      *
  -   * @return The document fragment this wraps
  +   * @return The DTM Node Handle of the root node of the 
  +   * document fragment this wraps
      */
     public int rtf()
     {
  -    return m_dtmRoot;
  +    return item(0);
     }
   
     /**
  -   * Cast result object to a DTMIterator.
  -   * dml - modified to return an RTFIterator for
  -   * benefit of EXSLT object-type function in 
  -   * {@link org.apache.xalan.lib.ExsltCommon}.
  +   * Cast result object to a DTMIterator. Standard XObject method,
  +   * replaces special-case asNodeIterator()
      * @return The document fragment as a DTMIterator
      */
  +  public DTMIterator iter()
  +  {
  +    //return m_dtmMgr.createDTMIterator(item(0));
  +    return super.iter();
  +  }
  +  
  +  /** @deprecated Unnecessarily nonstandard.
  +   * @see iter()
  +   * */
     public DTMIterator asNodeIterator()
     {
  -    DTMIterator iter = new RTFIterator(Axis.SELF);
  -    iter.setRoot(m_dtmRoot, m_xctxt);    
  -    return iter;
  +    return iter();
     }
  +  
   
     /**
  -   * Cast result object to a nodelist. (special function).
  +   * Cast result object to a DOM nodelist, primarily
  +   * for use as an extension function argument.
  +   * (tandard XObject function, replaces special-case convertToNodeset()
      *
      * @return The document fragment as a nodelist
      */
  -  public NodeList convertToNodeset()
  +  public NodeList nodelist() throws javax.xml.transform.TransformerException
     {
  -
  +  	return super.nodelist();
  +	/*
       if (m_obj instanceof NodeList)
         return (NodeList) m_obj;
       else
  -      return new org.apache.xml.dtm.ref.DTMNodeList(asNodeIterator());
  +      return new org.apache.xml.dtm.ref.DTMNodeList(iter());
  +     */
     }
   
  +  /** @deprecated Unnecessarily nonstandard.
  +   * @see nodeList()
  +   * */
  +  public NodeList convertToNodeset() throws javax.xml.transform.TransformerException
  +  {
  +  	return nodelist();
  +  }
  +
  +
     /**
      * Tell if two objects are functionally equal.
      *
  @@ -389,7 +391,7 @@
           // In order to handle the 'all' semantics of 
           // nodeset comparisons, we always call the 
           // nodeset function.
  -        return obj2.equals(this);
  +        return ((XNodeSet)obj2).equalsExistential(this);
         }
         else if (XObject.CLASS_BOOLEAN == obj2.getType())
         {
  
  
  
  1.5.6.1   +124 -23   xml-xalan/java/src/org/apache/xpath/objects/XRTreeFragSelectWrapper.java
  
  Index: XRTreeFragSelectWrapper.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XRTreeFragSelectWrapper.java,v
  retrieving revision 1.5
  retrieving revision 1.5.6.1
  diff -u -r1.5 -r1.5.6.1
  --- XRTreeFragSelectWrapper.java	22 Mar 2002 01:04:44 -0000	1.5
  +++ XRTreeFragSelectWrapper.java	14 Aug 2002 20:07:03 -0000	1.5.6.1
  @@ -6,22 +6,37 @@
   
   import org.apache.xml.utils.XMLString;
   
  -import org.apache.xpath.DOMHelper;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.Expression;
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xpath.res.XPATHErrorResources;
   
   /**
  - * This class makes an select statement act like an result tree fragment.
  + * This class makes an select statement act like an result tree fragment...
  + * at least in its returned values and comparisons. Actually, a
  + * more accurate description might be that its "values", like those of an
  + * RTF, spans all the selected content rather than being taken only from the
  + * first matching node.
  + * 
  + * But this really  _isn't_ a result tree fragment. The rtf() method is 
  + * hardwired to throw an exception, and the type() method returns STRING.
  + * 
  + * (Some of the logic is swiped from XRTreeFrag, but we no longer
  + * inherit from that class. Doing so was a bit of a kluge, and became
  + * impractical when XRTreeFrag was rewritten as an XNodeSet derivitive.)
  + * 
  + * %REVIEW% Should we rename this class?
    */
  -public class XRTreeFragSelectWrapper extends XRTreeFrag implements Cloneable
  +public class XRTreeFragSelectWrapper extends XObject implements Cloneable
   {
     XObject m_selected;
  +  boolean m_allowRelease;
  +  Expression m_expr;
   
     public XRTreeFragSelectWrapper(Expression expr)
     {
  -    super(expr);
  +    m_expr=expr;
     }
     
     /**
  @@ -34,9 +49,9 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    ((Expression)m_obj).fixupVariables(vars, globalsSize);
  +    m_expr.fixupVariables(vcs);
     }
     
     /**
  @@ -53,7 +68,7 @@
     {
       try
       {
  -      m_selected = ((Expression)m_obj).execute(xctxt);
  +      m_selected = m_expr.execute(xctxt);
         m_selected.allowDetachToRelease(m_allowRelease);
         XRTreeFragSelectWrapper xrtf = (XRTreeFragSelectWrapper)this.clone();
         return xrtf;
  @@ -80,24 +95,12 @@
       {
         m_selected.detach();
         m_selected = null;
  +      m_expr=null;
       }
       
       super.detach();
     }
  -  
  -  /**
  -   * Cast result object to a number.
  -   *
  -   * @return The result tree fragment as a number or NaN
  -   */
  -  public double num()
  -    throws javax.xml.transform.TransformerException
  -  {
  -
  -    return m_selected.num();
  -  }
  -
  -  
  +   
     /**
      * Cast result object to an XMLString.
      *
  @@ -125,13 +128,14 @@
      */
     public int getType()
     {
  -    return CLASS_STRING; // hmm...
  +    return CLASS_STRING;
     }
   
     /**
      * Cast result object to a result tree fragment.
  +   * Probably not needed since we no longer claim to inherit XRTreeFrag...
      *
  -   * @return The document fragment this wraps
  +   * @throws method-not-supported runtime expection.
      */
     public int rtf()
     {
  @@ -147,5 +151,102 @@
     {
       throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_RTF_NOT_SUPPORTED_XRTREEFRAGSELECTWRAPPER, null)); //"asNodeIterator() not supported by XRTreeFragSelectWrapper!");
     }
  +  
  +  public Object object()
  +  {
  +  	/* Would this be preferable?
  +  	if(m_selected!=null)
  +  		return m_selected.object();
  +  	else
  +  	*/
  +  		return m_expr;
  +  }
  +  
  +
  +  //-------------------------------------------------------------
  +  // Code swiped from XRTreeFrag since we no longer inherit therefrom
  +
  + /**
  +   * Tell if two objects are functionally equal.
  +   * Use logic from XRTreeFrag, not standard XObject.equals()
  +   *
  +   * @param obj2 Object to compare this to
  +   *
  +   * @return True if the two objects are equal
  +   *
  +   * @throws javax.xml.transform.TransformerException
  +   */
  +  public boolean equals(XObject obj2)
  +  {
  +
  +    try
  +    {
  +      if (XObject.CLASS_NODESET == obj2.getType())
  +      {
  +  
  +        // In order to handle the 'all' semantics of 
  +        // nodeset comparisons, we always call the 
  +        // nodeset function.
  +        return ((XNodeSet)obj2).equalsExistential(this);
  +      }
  +      else if (XObject.CLASS_BOOLEAN == obj2.getType())
  +      {
  +        return bool() == obj2.bool();
  +      }
  +      else if (XObject.CLASS_NUMBER == obj2.getType())
  +      {
  +        return num() == obj2.num();
  +      }
  +      else if (XObject.CLASS_NODESET == obj2.getType())
  +      {
  +        return xstr().equals(obj2.xstr());
  +      }
  +      else if (XObject.CLASS_STRING == obj2.getType())
  +      {
  +        return xstr().equals(obj2.xstr());
  +      }
  +      else if (XObject.CLASS_RTREEFRAG == obj2.getType())
  +      {
  +  
  +        // Probably not so good.  Think about this.
  +        return xstr().equals(obj2.xstr());
  +      }
  +      else
  +      {
  +        return super.equals(obj2);
  +      }
  +    }
  +    catch(javax.xml.transform.TransformerException te)
  +    {
  +      throw new org.apache.xml.utils.WrappedRuntimeException(te);
  +    }
  +  }
  +
  +  /**
  +   * Cast result object to a number.
  +   * Note that this is different from XNodeSet's definition; we convert
  +   * the entire string content, not just item(0).
  +   *
  +   * @return The result tree fragment as a number or NaN
  +   */
  +  public double num()
  +  {
  +    XMLString s = xstr();
  +
  +    return s.toDouble();
  +  }
  +  
  +  /**
  +   * Cast result object to a boolean.  This always returns true for an
  +   * XRTreeFragSelectWrapper. (I'm not entirely sure why it should, but some
  +   * of the regression tests fail if it doesn't.)
  +   *
  +   * @return true
  +   */
  +  public boolean bool()
  +  {
  +    return true;
  +  }
  +    
   
   }
  
  
  
  1.10.6.1  +71 -8     xml-xalan/java/src/org/apache/xpath/objects/XString.java
  
  Index: XString.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XString.java,v
  retrieving revision 1.10
  retrieving revision 1.10.6.1
  diff -u -r1.10 -r1.10.6.1
  --- XString.java	22 Mar 2002 01:04:44 -0000	1.10
  +++ XString.java	14 Aug 2002 20:07:03 -0000	1.10.6.1
  @@ -60,15 +60,14 @@
   import java.util.Locale;
   
   import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.XType;
   import org.apache.xml.utils.XMLCharacterRecognizer;
   import org.apache.xml.utils.XMLString;
   import org.apache.xml.utils.XMLStringFactory;
   import org.apache.xpath.ExpressionOwner;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.ext.LexicalHandler;
  +import org.apache.xpath.parser.Token;
   
   /**
    * <meta name="usage" content="general"/>
  @@ -77,19 +76,38 @@
    */
   public class XString extends XObject implements XMLString
   {
  +	/** Java String object representing this XString.
  +	 * Note that this field is also used as a cache by
  +	 * XString's subclasses
  +	 * */
  +	protected String m_stringValue=null;
   
     /** Empty string XString object */
     public static XString EMPTYSTRING = new XString("");
  +  
  +  /**
  +   * Construct a XString object, with a null value.
  +   * 
  +   * This one's actually being used, unlike most XObject empty ctors,
  +   * because it may be created and _then_ set (by processToken)
  +   * during stylesheet parsing.
  +   */
  +  public XString()
  +  {
  +  }
  +
   
     /**
      * Construct a XString object.  This constructor exists for derived classes.
      *
      * @param val String object this will wrap.
      */
  +  /*
     protected XString(Object val)
     {
       super(val);
     }
  +  */
   
     /**
      * Construct a XNodeSet object.
  @@ -98,9 +116,19 @@
      */
     public XString(String val)
     {
  -    super(val);
  +    m_stringValue=val;
  +  }
  +  
  +  /**
  +   * Return the sequence representing this object.
  +   * @return XSequence
  +   */
  +  public XSequence xseq()
  +  {
  +    return new XSequenceSingleton(this);
     }
   
  +
     /**
      * Tell that this is a CLASS_STRING.
      *
  @@ -131,6 +159,11 @@
     {
       return true;
     }
  +  
  +  public Object object()
  +  {
  +  	return m_stringValue; // str()?
  +  }
   
     /**
      * Cast result object to a number.
  @@ -271,7 +304,17 @@
      */
     public String str()
     {
  -    return (null != m_obj) ? ((String) m_obj) : "";
  +  	// Should this actively replace null with ""?
  +  	return (m_stringValue==null) ? "" : m_stringValue;
  +  }
  +  
  +  /** Yield result object's string value as a sequence of Character Blocks
  +	* @return a CharacterBlockEnumeration displaying the contents of
  +	* this object's string value (as in str()). May be empty.
  +	* */
  +  public org.apache.xml.utils.CharacterBlockEnumeration enumerateCharacterBlocks()
  +  {
  +  	return new org.apache.xml.utils.CharacterBlockEnumeration(str());
     }
   
     /**
  @@ -402,8 +445,8 @@
       int t = obj2.getType();
       try
       {
  -	    if (XObject.CLASS_NODESET == t)
  -	      return obj2.equals(this);
  +	    if (obj2.isNodesetExpr())
  +	      return ((XNodeSet)obj2).equalsExistential(this);
   	    // If at least one object to be compared is a boolean, then each object 
   	    // to be compared is converted to a boolean as if by applying the 
   	    // boolean function. 
  @@ -471,7 +514,7 @@
         // nodeset comparisons, we always call the 
         // nodeset function.
       else if (obj2 instanceof XNodeSet)
  -      return obj2.equals(this);
  +      return ((XNodeSet)obj2).equalsExistential(this);
       else if(obj2 instanceof XNumber)
       	return obj2.equals(this);
       else
  @@ -1207,5 +1250,25 @@
     {
     	visitor.visitStringLiteral(owner, this);
     }
  +  
  +  public void processToken(Token t) 
  +  { 
  +  	int strLen = t.image.length();
  +  	
  +  	if(strLen >= 2)
  +  	{
  +  		assertion(t.image.charAt(0) == '"' || t.image.charAt(0) == '\'', 
  +  			"First character of string literal must be a quote or apos!");
  +  		assertion(t.image.charAt(strLen-1) == '"' || t.image.charAt(strLen-1) == '\'', 
  +  			"Last character of string literal must be a quote or apos!");
  +  		m_stringValue = t.image.substring(1, strLen-1);
  +  	}
  +  	else
  +  	{
  +      m_stringValue = "";
  +  	}
  +  		
  +  }
  +
   
   }
  
  
  
  1.5.14.1  +29 -16    xml-xalan/java/src/org/apache/xpath/objects/XStringForChars.java
  
  Index: XStringForChars.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XStringForChars.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- XStringForChars.java	26 Aug 2001 06:00:35 -0000	1.5
  +++ XStringForChars.java	14 Aug 2002 20:07:03 -0000	1.5.14.1
  @@ -16,14 +16,15 @@
    */
   public class XStringForChars extends XString
   {
  -  /** The start position in the fsb. */
  +	/** Pointer to the block containing this string */
  +	char[] m_chars;
  +	
  +  /** The start position in the character array. */
     int m_start;
     
     /** The length of the string. */
     int m_length;
     
  -  protected String m_strCache = null;
  -  
     /**
      * Construct a XNodeSet object.
      *
  @@ -33,26 +34,28 @@
      */
     public XStringForChars(char[] val, int start, int length)
     {
  -    super(val);
  -    m_start = start;
  -    m_length = length;
       if(null == val)
         throw new IllegalArgumentException(
                             XSLMessages.createXPATHMessage(XPATHErrorResources.ER_FASTSTRINGBUFFER_CANNOT_BE_NULL, null)); //"The FastStringBuffer argument can not be null!!");
  +    m_chars=val;
  +    m_start = start;
  +    m_length = length;
     }
   
   
     /**
  -   * Construct a XNodeSet object.
  +   * Block inherited constructor. (DO ctors inherit?)
      *
      * @param val String object this will wrap.
      */
  +  /*
     private XStringForChars(String val)
     {
       super(val);
       throw new IllegalArgumentException(
                         XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XSTRINGFORCHARS_CANNOT_TAKE_STRING, null)); //"XStringForChars can not take a string for an argument!");
     }
  +  */
     
     /**
      * Cast result object to a string.
  @@ -71,7 +74,7 @@
      */
     public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb)
     {
  -    fsb.append((char[])m_obj, m_start, m_length);
  +    fsb.append(m_chars, m_start, m_length);
     }
   
     
  @@ -82,7 +85,7 @@
      */
     public boolean hasString()
     {
  -    return (null != m_strCache);
  +    return (null != m_stringValue);
     }
   
     
  @@ -93,13 +96,23 @@
      */
     public String str()
     {
  -    if(null == m_strCache)
  -      m_strCache = new String((char[])m_obj, m_start, m_length);
  +    if(null == m_stringValue)
  +      m_stringValue = new String(m_chars, m_start, m_length);
       
  -    return m_strCache;
  +    return m_stringValue;
     }
     
   
  +  /** Yield result object's string value as a sequence of Character Blocks
  +	* @return a CharacterBlockEnumeration displaying the contents of
  +	* this object's string value (as in str()). May be empty.
  +	* */
  +  public org.apache.xml.utils.CharacterBlockEnumeration enumerateCharacterBlocks()
  +  {
  +  	return new org.apache.xml.utils.CharacterBlockEnumeration(
  +		m_chars, m_start, m_length);
  +  }
  +
     /**
      * Since this object is incomplete without the length and the offset, we 
      * have to convert to a string when this function is called.
  @@ -125,7 +138,7 @@
     public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
         throws org.xml.sax.SAXException
     {
  -    ch.characters((char[])m_obj, m_start, m_length);
  +    ch.characters(m_chars, m_start, m_length);
     }
         
     /**
  @@ -140,7 +153,7 @@
     public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
         throws org.xml.sax.SAXException
     {
  -    lh.comment((char[])m_obj, m_start, m_length);
  +    lh.comment(m_chars, m_start, m_length);
     }
     
     /**
  @@ -169,7 +182,7 @@
      */
     public char charAt(int index)
     {
  -    return ((char[])m_obj)[index+m_start];
  +    return (m_chars)[index+m_start];
     }
   
     /**
  @@ -195,7 +208,7 @@
      */
     public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin)
     {
  -    System.arraycopy((char[])m_obj, m_start+srcBegin, dst, dstBegin, srcEnd);
  +    System.arraycopy(m_chars, m_start+srcBegin, dst, dstBegin, srcEnd);
     }
     
   }
  
  
  
  1.16.2.1  +35 -27    xml-xalan/java/src/org/apache/xpath/objects/XStringForFSB.java
  
  Index: XStringForFSB.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XStringForFSB.java,v
  retrieving revision 1.16
  retrieving revision 1.16.2.1
  diff -u -r1.16 -r1.16.2.1
  --- XStringForFSB.java	27 Jun 2002 14:50:42 -0000	1.16
  +++ XStringForFSB.java	14 Aug 2002 20:07:03 -0000	1.16.2.1
  @@ -61,9 +61,6 @@
   import org.apache.xml.utils.XMLStringFactory;
   import org.apache.xml.utils.XMLCharacterRecognizer;
   
  -import org.apache.xpath.res.XPATHErrorResources;
  -import org.apache.xalan.res.XSLMessages;
  -
   import java.util.Locale;
   
   /**
  @@ -71,6 +68,7 @@
    */
   public class XStringForFSB extends XString
   {
  +	FastStringBuffer m_fsb;
   
     /** The start position in the fsb. */
     int m_start;
  @@ -78,9 +76,6 @@
     /** The length of the string. */
     int m_length;
   
  -  /** If the str() function is called, the string will be cached here. */
  -  protected String m_strCache = null;
  -
     /** cached hash code */
     protected int m_hash = 0;
   
  @@ -93,30 +88,30 @@
      */
     public XStringForFSB(FastStringBuffer val, int start, int length)
     {
  +    if (null == val)
  +      throw new IllegalArgumentException(
  +        "The FastStringBuffer argument can not be null!!");
   
  -    super(val);
  -
  +    m_fsb=val;
       m_start = start;
       m_length = length;
  -
  -    if (null == val)
  -      throw new IllegalArgumentException(
  -        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_FASTSTRINGBUFFER_CANNOT_BE_NULL, null));
     }
   
     /**
  -   * Construct a XNodeSet object.
  +   * Block inherited ctor. (DO ctors inherit?)
      *
      * @param val String object this will wrap.
      */
  +  /*
     private XStringForFSB(String val)
     {
   
       super(val);
   
       throw new IllegalArgumentException(
  -      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_FSB_CANNOT_TAKE_STRING, null)); // "XStringForFSB can not take a string for an argument!");
  +      "XStringForFSB can not take a string for an argument!");
     }
  +  */
   
     /**
      * Cast result object to a string.
  @@ -125,7 +120,7 @@
      */
     public FastStringBuffer fsb()
     {
  -    return ((FastStringBuffer) m_obj);
  +    return (m_fsb);
     }
     
     /**
  @@ -146,15 +141,9 @@
      */
     public boolean hasString()
     {
  -    return (null != m_strCache);
  +    return (null != m_stringValue);
     }
   
  -//  /** NEEDSDOC Field strCount */
  -//  public static int strCount = 0;
  -//
  -//  /** NEEDSDOC Field xtable */
  -//  static java.util.Hashtable xtable = new java.util.Hashtable();
  -
     /**
      * Since this object is incomplete without the length and the offset, we 
      * have to convert to a string when this function is called.
  @@ -174,9 +163,9 @@
     public String str()
     {
   
  -    if (null == m_strCache)
  +    if (null == m_stringValue)
       {
  -      m_strCache = fsb().getString(m_start, m_length);
  +      m_stringValue = fsb().getString(m_start, m_length);
   
   //      strCount++;
   //
  @@ -202,8 +191,26 @@
         // System.exit(-1);
       }
   
  -    return m_strCache;
  +    return m_stringValue;
  +  }
  +  
  +  /** Yield result object's string value as a sequence of Character Blocks
  +	* @return a CharacterBlockEnumeration displaying the contents of
  +	* this object's string value (as in str()). May be empty, may
  +	* yield multiple blocks depending on the FSB's contents. (The latter
  +	* case is why we need to enumerate, of course!)
  +	* */
  +  public org.apache.xml.utils.CharacterBlockEnumeration enumerateCharacterBlocks()
  +  {
  +  	// %REVIEW% %OPT% I'm not sure this is an optimization. Depends on
  +  	// how retrieval of char[] from String works in any given JVM.
  +  	// See comments in CharacterBlockEnumeration, and run some tests.
  +    if (null != m_stringValue)
  +    	return new org.apache.xml.utils.CharacterBlockEnumeration(m_stringValue);
  +	else  	
  +	  	return fsb().enumerateCharacterBlocks(m_start,m_length);
     }
  +  
   
     /**
      * Directly call the
  @@ -375,7 +382,7 @@
         return true;
       }
       if(obj2.getType() == XObject.CLASS_NUMBER)
  -    	return obj2.equals(this);
  +    	return ((XNodeSet)obj2).equalsExistential(this);
   
       String str = obj2.str();
       int n = m_length;
  @@ -470,7 +477,7 @@
         // nodeset comparisons, we always call the 
         // nodeset function.
       else if (obj2 instanceof XNodeSet)
  -      return obj2.equals(this);
  +      return ((XNodeSet)obj2).equalsExistential(this);
       else if (obj2 instanceof XStringForFSB)
         return equals((XMLString) this);
       else
  @@ -697,6 +704,7 @@
     {
       return startsWith(prefix, 0);
     }
  +
   
     /**
      * Returns the index within this string of the first occurrence of the
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +717 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/NodeSequence.java
  
  
  
  
  1.1.2.1   +311 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/TypeOperations.java
  
  
  
  
  1.1.2.1   +278 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XDTDuration.java
  
  
  
  
  1.1.2.1   +560 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XDTMSequence.java
  
  
  
  
  1.1.2.1   +152 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XDate.java
  
  
  
  
  1.1.2.1   +405 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XDateTime.java
  
  
  
  
  1.1.2.1   +20 -0     xml-xalan/java/src/org/apache/xpath/objects/Attic/XDecimal.java
  
  
  
  
  1.1.2.1   +94 -0     xml-xalan/java/src/org/apache/xpath/objects/Attic/XDouble.java
  
  
  
  
  1.1.2.1   +401 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XDuration.java
  
  
  
  
  1.1.2.1   +101 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XFloat.java
  
  
  
  
  1.1.2.1   +196 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XGDay.java
  
  
  
  
  1.1.2.1   +195 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XGMonth.java
  
  
  
  
  1.1.2.1   +200 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XGMonthDay.java
  
  
  
  
  1.1.2.1   +199 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XGYearMonth.java
  
  
  
  
  1.1.2.1   +181 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XGYearObj.java
  
  
  
  
  1.1.2.1   +121 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XInteger.java
  
  
  
  
  1.1.2.1   +44 -0     xml-xalan/java/src/org/apache/xpath/objects/Attic/XJavaObject.java
  
  
  
  
  1.1.2.1   +884 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XNodeSequenceSingleton.java
  
  
  
  
  1.1.2.1   +277 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XSequence.java
  
  
  
  
  1.1.2.1   +349 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XSequenceCachedBase.java
  
  
  
  
  1.1.2.1   +272 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XSequenceEmpty.java
  
  
  
  
  1.1.2.1   +598 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XSequenceImpl.java
  
  
  
  
  1.1.2.1   +149 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XSequenceMutable.java
  
  
  
  
  1.1.2.1   +862 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XSequenceSingleton.java
  
  
  
  
  1.1.2.1   +185 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XTime.java
  
  
  
  
  1.1.2.1   +278 -0    xml-xalan/java/src/org/apache/xpath/objects/Attic/XYMDuration.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.14.1  +0 -2      xml-xalan/java/src/org/apache/xpath/operations/And.java
  
  Index: And.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/And.java,v
  retrieving revision 1.6
  retrieving revision 1.6.14.1
  diff -u -r1.6 -r1.6.14.1
  --- And.java	12 Jun 2001 19:16:55 -0000	1.6
  +++ And.java	14 Aug 2002 20:07:05 -0000	1.6.14.1
  @@ -69,7 +69,6 @@
    */
   public class And extends Operation
   {
  -
     /**
      * AND two expressions and return the boolean result. Override
      * superclass method for optimization purposes.
  @@ -83,7 +82,6 @@
      */
     public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
     {
  -
       XObject expr1 = m_left.execute(xctxt);
   
       if (expr1.bool())
  
  
  
  1.5.14.1  +84 -29    xml-xalan/java/src/org/apache/xpath/operations/Div.java
  
  Index: Div.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Div.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- Div.java	12 Jun 2001 19:16:56 -0000	1.5
  +++ Div.java	14 Aug 2002 20:07:05 -0000	1.5.14.1
  @@ -56,47 +56,102 @@
    */
   package org.apache.xpath.operations;
   
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  +import javax.xml.transform.TransformerException;
  +
  +import org.apache.xml.dtm.XType;
   import org.apache.xpath.XPathContext;
  +import org.apache.xpath.objects.XDouble;
  +import org.apache.xpath.objects.XFloat;
  +import org.apache.xpath.objects.XInteger;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.objects.XYMDuration;
  +import org.apache.xpath.objects.XDTDuration;
  +import org.apache.xml.utils.Duration;
   
   /**
    * The 'div' operation expression executer.
    */
  -public class Div extends Operation
  +public class Div extends OperationNormalized
   {
  -
  -  /**
  -   * Apply the operation to two operands, and return the result.
  -   *
  -   *
  -   * @param left non-null reference to the evaluated left operand.
  -   * @param right non-null reference to the evaluated right operand.
  -   *
  -   * @return non-null reference to the XObject that represents the result of the operation.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  public XObject operate(XObject left, XObject right)
  -          throws javax.xml.transform.TransformerException
  +  static OpFuncLookupTable m_funcs;
     {
  -    return new XNumber(left.num() / right.num());
  +    m_funcs = new OpFuncLookupTable();
  +    m_funcs.setFunc(XType.DOUBLE, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XDouble(lhs.num() / rhs.num());
  +      }
  +    });
  +    m_funcs.setFunc(XType.FLOAT, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XFloat(lhs.floatVal() / rhs.floatVal());
  +      }
  +    });
  +    m_funcs.setFunc(XType.INTEGER, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XInteger(lhs.integer() / rhs.integer());
  +      }
  +    });
  +    m_funcs.setFunc(XType.DAYTIMEDURATION, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +      	Duration duration = lhs.duration();
  +        Duration du = duration.divideDTDuration(rhs.num());
  +        
  +        return new XDTDuration(du);
  +      }
  +    });
  +    m_funcs.setFunc(XType.YEARMONTHDURATION, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        Duration duration = lhs.duration();
  +        Duration du = duration.divideYMDuration(rhs.num());
  +        
  +        return new XYMDuration(du);
  +      }
  +    });
  +    m_funcs.setFunc(XType.DECIMAL, NOTSUPPORTED);
  +
  +    m_funcs.setFunc(XType.DURATION, NOTSUPPORTED);
  +   // m_funcs.setFunc(XType.DAYTIMEDURATION, NOTSUPPORTED);
  +   // m_funcs.setFunc(XType.YEARMONTHDURATION, NOTSUPPORTED);
  +    
  +    m_funcs.setFunc(XType.DATETIME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.TIME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.DATE, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GYEARMONTH, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GYEAR, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GMONTHDAY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GDAY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GMONTH, NOTSUPPORTED);
  +
  +    m_funcs.setFunc(XType.BOOLEAN, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.STRING, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.BASE64BINARY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.HEXBINARY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.ANYURI, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.QNAME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.NOTATION, NOTSUPPORTED);
     }
     
     /**
  -   * Evaluate this operation directly to a double.
  -   *
  -   * @param xctxt The runtime execution context.
  -   *
  -   * @return The result of the operation as a double.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * @see org.apache.xpath.operations.Operation#getLookupTable()
      */
  -  public double num(XPathContext xctxt)
  -          throws javax.xml.transform.TransformerException
  +  public OpFuncLookupTable getLookupTable()
     {
  -
  -    return (m_left.num(xctxt) / m_right.num(xctxt));
  +    return m_funcs;
     }
   
   }
  
  
  
  1.6.4.1   +6 -8      xml-xalan/java/src/org/apache/xpath/operations/Equals.java
  
  Index: Equals.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Equals.java,v
  retrieving revision 1.6
  retrieving revision 1.6.4.1
  diff -u -r1.6 -r1.6.4.1
  --- Equals.java	22 Mar 2002 01:04:45 -0000	1.6
  +++ Equals.java	14 Aug 2002 20:07:05 -0000	1.6.4.1
  @@ -56,7 +56,6 @@
    */
   package org.apache.xpath.operations;
   
  -import javax.xml.transform.TransformerException;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.objects.XBoolean;
   import org.apache.xpath.objects.XObject;
  @@ -64,9 +63,8 @@
   /**
    * The '=' operation expression executer.
    */
  -public class Equals extends Operation
  +public class Equals extends OperationSimple
   {
  -
     /**
      * Apply the operation to two operands, and return the result.
      *
  @@ -81,7 +79,7 @@
     public XObject operate(XObject left, XObject right)
             throws javax.xml.transform.TransformerException
     {
  -    return left.equals(right) ? XBoolean.S_TRUE : XBoolean.S_FALSE;
  +    return left.equalsExistential(right) ? XBoolean.S_TRUE : XBoolean.S_FALSE;
     }
     
     /**
  @@ -96,14 +94,14 @@
      * @throws javax.xml.transform.TransformerException
      */
     public boolean bool(XPathContext xctxt)
  -          throws javax.xml.transform.TransformerException
  +    throws javax.xml.transform.TransformerException
     {
       XObject left = m_left.execute(xctxt, true);
       XObject right = m_right.execute(xctxt, true);
   
  -    boolean result = left.equals(right) ? true : false;
  -	left.detach();
  -	right.detach();
  +    boolean result = left.equalsExistential(right) ? true : false;
  +    left.detach();
  +    right.detach();
       return result;
     }
   
  
  
  
  1.4.18.1  +1 -2      xml-xalan/java/src/org/apache/xpath/operations/Gt.java
  
  Index: Gt.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Gt.java,v
  retrieving revision 1.4
  retrieving revision 1.4.18.1
  diff -u -r1.4 -r1.4.18.1
  --- Gt.java	17 Dec 2000 05:21:15 -0000	1.4
  +++ Gt.java	14 Aug 2002 20:07:05 -0000	1.4.18.1
  @@ -62,9 +62,8 @@
   /**
    * The '>' operation expression executer.
    */
  -public class Gt extends Operation
  +public class Gt extends OperationSimple
   {
  -
     /**
      * Apply the operation to two operands, and return the result.
      *
  
  
  
  1.4.18.1  +1 -2      xml-xalan/java/src/org/apache/xpath/operations/Gte.java
  
  Index: Gte.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Gte.java,v
  retrieving revision 1.4
  retrieving revision 1.4.18.1
  diff -u -r1.4 -r1.4.18.1
  --- Gte.java	17 Dec 2000 05:21:15 -0000	1.4
  +++ Gte.java	14 Aug 2002 20:07:05 -0000	1.4.18.1
  @@ -62,9 +62,8 @@
   /**
    * The '>=' operation expression executer.
    */
  -public class Gte extends Operation
  +public class Gte extends OperationSimple
   {
  -
     /**
      * Apply the operation to two operands, and return the result.
      *
  
  
  
  1.4.18.1  +1 -2      xml-xalan/java/src/org/apache/xpath/operations/Lt.java
  
  Index: Lt.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Lt.java,v
  retrieving revision 1.4
  retrieving revision 1.4.18.1
  diff -u -r1.4 -r1.4.18.1
  --- Lt.java	17 Dec 2000 05:21:15 -0000	1.4
  +++ Lt.java	14 Aug 2002 20:07:05 -0000	1.4.18.1
  @@ -62,9 +62,8 @@
   /**
    * The '<' operation expression executer.
    */
  -public class Lt extends Operation
  +public class Lt extends OperationSimple
   {
  -
     /**
      * Apply the operation to two operands, and return the result.
      *
  
  
  
  1.4.18.1  +1 -2      xml-xalan/java/src/org/apache/xpath/operations/Lte.java
  
  Index: Lte.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Lte.java,v
  retrieving revision 1.4
  retrieving revision 1.4.18.1
  diff -u -r1.4 -r1.4.18.1
  --- Lte.java	17 Dec 2000 05:21:16 -0000	1.4
  +++ Lte.java	14 Aug 2002 20:07:05 -0000	1.4.18.1
  @@ -62,9 +62,8 @@
   /**
    * The '<=' operation expression executer.
    */
  -public class Lte extends Operation
  +public class Lte extends OperationSimple
   {
  -
     /**
      * Apply the operation to two operands, and return the result.
      *
  
  
  
  1.5.14.1  +59 -29    xml-xalan/java/src/org/apache/xpath/operations/Mod.java
  
  Index: Mod.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Mod.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- Mod.java	12 Jun 2001 19:16:56 -0000	1.5
  +++ Mod.java	14 Aug 2002 20:07:05 -0000	1.5.14.1
  @@ -56,47 +56,77 @@
    */
   package org.apache.xpath.operations;
   
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  +import javax.xml.transform.TransformerException;
  +
  +import org.apache.xml.dtm.XType;
   import org.apache.xpath.XPathContext;
  +import org.apache.xpath.objects.XDouble;
  +import org.apache.xpath.objects.XFloat;
  +import org.apache.xpath.objects.XInteger;
  +import org.apache.xpath.objects.XObject;
   
   /**
    * The 'mod' operation expression executer.
    */
  -public class Mod extends Operation
  +public class Mod extends OperationNormalized
   {
  -
  -  /**
  -   * Apply the operation to two operands, and return the result.
  -   *
  -   *
  -   * @param left non-null reference to the evaluated left operand.
  -   * @param right non-null reference to the evaluated right operand.
  -   *
  -   * @return non-null reference to the XObject that represents the result of the operation.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  public XObject operate(XObject left, XObject right)
  -          throws javax.xml.transform.TransformerException
  +  static OpFuncLookupTable m_funcs;
     {
  -    return new XNumber(left.num() % right.num());
  +    m_funcs = new OpFuncLookupTable();
  +    m_funcs.setFunc(XType.DOUBLE, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XDouble(lhs.num() % rhs.num());
  +      }
  +    });
  +    m_funcs.setFunc(XType.FLOAT, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XFloat(lhs.floatVal() % rhs.floatVal());
  +      }
  +    });
  +    m_funcs.setFunc(XType.INTEGER, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XInteger(lhs.integer() % rhs.integer());
  +      }
  +    });
  +    m_funcs.setFunc(XType.DECIMAL, NOTSUPPORTED);
  +
  +    m_funcs.setFunc(XType.DURATION, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.DAYTIMEDURATION, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.YEARMONTHDURATION, NOTSUPPORTED);
  +    
  +    m_funcs.setFunc(XType.DATETIME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.TIME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.DATE, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GYEARMONTH, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GYEAR, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GMONTHDAY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GDAY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GMONTH, NOTSUPPORTED);
  +
  +    m_funcs.setFunc(XType.BOOLEAN, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.STRING, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.BASE64BINARY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.HEXBINARY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.ANYURI, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.QNAME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.NOTATION, NOTSUPPORTED);
     }
     
     /**
  -   * Evaluate this operation directly to a double.
  -   *
  -   * @param xctxt The runtime execution context.
  -   *
  -   * @return The result of the operation as a double.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * @see org.apache.xpath.operations.Operation#getLookupTable()
      */
  -  public double num(XPathContext xctxt)
  -          throws javax.xml.transform.TransformerException
  +  public OpFuncLookupTable getLookupTable()
     {
  -
  -    return (m_left.num(xctxt) % m_right.num(xctxt));
  +    return m_funcs;
     }
   
   }
  
  
  
  1.5.14.1  +84 -28    xml-xalan/java/src/org/apache/xpath/operations/Mult.java
  
  Index: Mult.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Mult.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- Mult.java	12 Jun 2001 19:16:56 -0000	1.5
  +++ Mult.java	14 Aug 2002 20:07:05 -0000	1.5.14.1
  @@ -56,46 +56,102 @@
    */
   package org.apache.xpath.operations;
   
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  +import javax.xml.transform.TransformerException;
  +
  +import org.apache.xml.dtm.XType;
   import org.apache.xpath.XPathContext;
  +import org.apache.xpath.objects.XDouble;
  +import org.apache.xpath.objects.XFloat;
  +import org.apache.xpath.objects.XInteger;
  +import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.objects.XYMDuration;
  +import org.apache.xpath.objects.XDTDuration;
  +import org.apache.xml.utils.Duration;
   
   /**
    * The '*' operation expression executer.
    */
  -public class Mult extends Operation
  +public class Mult extends OperationNormalized
   {
  -
  -  /**
  -   * Apply the operation to two operands, and return the result.
  -   *
  -   *
  -   * @param left non-null reference to the evaluated left operand.
  -   * @param right non-null reference to the evaluated right operand.
  -   *
  -   * @return non-null reference to the XObject that represents the result of the operation.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  public XObject operate(XObject left, XObject right)
  -          throws javax.xml.transform.TransformerException
  +  static OpFuncLookupTable m_funcs;
     {
  -    return new XNumber(left.num() * right.num());
  +    m_funcs = new OpFuncLookupTable();
  +    m_funcs.setFunc(XType.DOUBLE, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XDouble(lhs.num() * rhs.num());
  +      }
  +    });
  +    m_funcs.setFunc(XType.FLOAT, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XFloat(lhs.floatVal() * rhs.floatVal());
  +      }
  +    });
  +    m_funcs.setFunc(XType.INTEGER, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        return new XInteger(lhs.integer() * rhs.integer());
  +      }
  +    });
  +    m_funcs.setFunc(XType.DAYTIMEDURATION, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +      	Duration duration = lhs.duration();
  +        Duration du = duration.multiplyDTDuration(rhs.num());
  +        
  +        return new XDTDuration(du);
  +      }
  +    });
  +    m_funcs.setFunc(XType.YEARMONTHDURATION, new GenericOpFunc()
  +    {
  +      public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +        throws TransformerException
  +      {
  +        Duration duration = lhs.duration();
  +        Duration du = duration.multiplyYMDuration(rhs.num());
  +        
  +        return new XYMDuration(du);
  +      }
  +    });    
  +    m_funcs.setFunc(XType.DECIMAL, NOTSUPPORTED);
  +
  +    m_funcs.setFunc(XType.DURATION, NOTSUPPORTED);
  +    //m_funcs.setFunc(XType.DAYTIMEDURATION, NOTSUPPORTED);
  +    //m_funcs.setFunc(XType.YEARMONTHDURATION, NOTSUPPORTED);
  +    
  +    m_funcs.setFunc(XType.DATETIME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.TIME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.DATE, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GYEARMONTH, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GYEAR, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GMONTHDAY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GDAY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.GMONTH, NOTSUPPORTED);
  +
  +    m_funcs.setFunc(XType.BOOLEAN, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.STRING, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.BASE64BINARY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.HEXBINARY, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.ANYURI, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.QNAME, NOTSUPPORTED);
  +    m_funcs.setFunc(XType.NOTATION, NOTSUPPORTED);
     }
     
     /**
  -   * Evaluate this operation directly to a double.
  -   *
  -   * @param xctxt The runtime execution context.
  -   *
  -   * @return The result of the operation as a double.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * @see org.apache.xpath.operations.Operation#getLookupTable()
      */
  -  public double num(XPathContext xctxt)
  -          throws javax.xml.transform.TransformerException
  +  public OpFuncLookupTable getLookupTable()
     {
  -    return (m_left.num(xctxt) * m_right.num(xctxt));
  +    return m_funcs;
     }
   
   }
  
  
  
  1.5.14.1  +4 -3      xml-xalan/java/src/org/apache/xpath/operations/Neg.java
  
  Index: Neg.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Neg.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- Neg.java	12 Jun 2001 19:16:56 -0000	1.5
  +++ Neg.java	14 Aug 2002 20:07:05 -0000	1.5.14.1
  @@ -56,9 +56,10 @@
    */
   package org.apache.xpath.operations;
   
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  +import javax.xml.transform.TransformerException;
   import org.apache.xpath.XPathContext;
  +import org.apache.xpath.objects.XDouble;
  +import org.apache.xpath.objects.XObject;
   
   /**
    * The unary '-' operation expression executer.
  @@ -78,7 +79,7 @@
      */
     public XObject operate(XObject right) throws javax.xml.transform.TransformerException
     {
  -    return new XNumber(-right.num());
  +    return new XDouble(-right.num());
     }
     
     /**
  
  
  
  1.4.18.1  +1 -2      xml-xalan/java/src/org/apache/xpath/operations/NotEquals.java
  
  Index: NotEquals.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/NotEquals.java,v
  retrieving revision 1.4
  retrieving revision 1.4.18.1
  diff -u -r1.4 -r1.4.18.1
  --- NotEquals.java	17 Dec 2000 05:21:16 -0000	1.4
  +++ NotEquals.java	14 Aug 2002 20:07:05 -0000	1.4.18.1
  @@ -62,9 +62,8 @@
   /**
    * The '!=' operation expression executer.
    */
  -public class NotEquals extends Operation
  +public class NotEquals extends OperationSimple
   {
  -
     /**
      * Apply the operation to two operands, and return the result.
      *
  
  
  
  1.5.14.1  +4 -3      xml-xalan/java/src/org/apache/xpath/operations/Number.java
  
  Index: Number.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Number.java,v
  retrieving revision 1.5
  retrieving revision 1.5.14.1
  diff -u -r1.5 -r1.5.14.1
  --- Number.java	12 Jun 2001 19:16:56 -0000	1.5
  +++ Number.java	14 Aug 2002 20:07:05 -0000	1.5.14.1
  @@ -56,9 +56,10 @@
    */
   package org.apache.xpath.operations;
   
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
  +import javax.xml.transform.TransformerException;
   import org.apache.xpath.XPathContext;
  +import org.apache.xpath.objects.XDouble;
  +import org.apache.xpath.objects.XObject;
   
   /**
    * The 'number()' operation expression executer.
  @@ -82,7 +83,7 @@
       if (XObject.CLASS_NUMBER == right.getType())
         return right;
       else
  -      return new XNumber(right.num());
  +      return new XDouble(right.num());
     }
     
     /**
  
  
  
  1.9.4.1   +62 -45    xml-xalan/java/src/org/apache/xpath/operations/Operation.java
  
  Index: Operation.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Operation.java,v
  retrieving revision 1.9
  retrieving revision 1.9.4.1
  diff -u -r1.9 -r1.9.4.1
  --- Operation.java	22 Mar 2002 01:04:45 -0000	1.9
  +++ Operation.java	14 Aug 2002 20:07:05 -0000	1.9.4.1
  @@ -56,11 +56,10 @@
    */
   package org.apache.xpath.operations;
   
  -import java.util.Vector;
  -
  -import javax.xml.transform.TransformerException;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
   import org.apache.xpath.objects.XObject;
  @@ -68,7 +67,7 @@
   /**
    * The baseclass for a binary operation.
    */
  -public class Operation extends Expression implements ExpressionOwner
  +public abstract class Operation extends Expression implements ExpressionOwner
   {
   
     /** The left operand expression.
  @@ -79,6 +78,18 @@
      *  @serial */
     protected Expression m_right;
     
  +  static GenericOpFunc NOTSUPPORTED = new GenericOpFunc()
  +  {
  +    /**
  +     * @see org.apache.xpath.operations.opfuncs.GenericOpFunc#operate(XPathContext, XObject, XObject)
  +     */
  +    public XObject operate(XPathContext xctxt, XObject lhs, XObject rhs)
  +    {
  +      return null;
  +    }
  +
  +  };
  +  
     /**
      * This function is used to fixup variables from QNames to stack frame 
      * indexes at stylesheet build time.
  @@ -89,10 +100,10 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    m_left.fixupVariables(vars, globalsSize);
  -    m_right.fixupVariables(vars, globalsSize);
  +    m_left.fixupVariables(vcs);
  +    m_right.fixupVariables(vcs);
     }
   
   
  @@ -123,51 +134,49 @@
      */
     public void setLeftRight(Expression l, Expression r)
     {
  -    m_left = l;
  -    m_right = r;
  -    l.exprSetParent(this);
  -    r.exprSetParent(this);
  +    jjtAddChild(l, 0); 
  +    jjtAddChild(r, 1); 
     }
  -
  +  
  +  
     /**
  -   * Execute a binary operation by calling execute on each of the operands,
  -   * and then calling the operate method on the derived class.
  -   *
  -   *
  -   * @param xctxt The runtime execution context.
  -   *
  -   * @return The XObject result of the operation.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * Add the left or right node of the operation.
      */
  -  public XObject execute(XPathContext xctxt)
  -          throws javax.xml.transform.TransformerException
  +  public void jjtAddChild(org.apache.xpath.parser.Node n, int i) 
     {
  -
  -    XObject left = m_left.execute(xctxt, true);
  -    XObject right = m_right.execute(xctxt, true);
  -
  -    XObject result = operate(left, right);
  -    left.detach();
  -    right.detach();
  -    return result;
  +  	n = fixupPrimarys(n);  // yuck.
  +  	if(0 == i)
  +  	{
  +    	m_left = (Expression)n;
  +    	m_left.jjtSetParent(this);
  +  	}
  +  	else if(1 == i)
  +  	{
  +    	m_right = (Expression)n;
  +    	m_right.jjtSetParent(this);
  +  	}
  +  	else
  +  	{
  +  		// assertion... should not be able to occur.
  +  		throw new RuntimeException("Can't add more than two children to an operation!");
  +  	}
  +  }
  +  
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	assertion(i <= 1, "Operation can only have one or two children!");
  +  	return (0 == i) ? m_left : m_right;
     }
   
  -  /**
  -   * Apply the operation to two operands, and return the result.
  -   *
  -   *
  -   * @param left non-null reference to the evaluated left operand.
  -   * @param right non-null reference to the evaluated right operand.
  -   *
  -   * @return non-null reference to the XObject that represents the result of the operation.
  -   *
  -   * @throws javax.xml.transform.TransformerException
  -   */
  -  public XObject operate(XObject left, XObject right)
  -          throws javax.xml.transform.TransformerException
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
     {
  -    return null;  // no-op
  +  	int count = 1;
  +   	if(null != m_right)
  +  		count++;
  +  	return count;
     }
   
     /** @return the left operand of binary operation, as an Expression.
  @@ -247,4 +256,12 @@
     		
     	return true;
     }
  +  /**
  +   * Tell if this node should have it's PathExpr ancestory reduced.
  +   */
  +  public boolean isPathExprReduced()
  +  {
  +  	return true;
  +  }
  +
   }
  
  
  
  1.6.14.1  +7 -0      xml-xalan/java/src/org/apache/xpath/operations/Or.java
  
  Index: Or.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Or.java,v
  retrieving revision 1.6
  retrieving revision 1.6.14.1
  diff -u -r1.6 -r1.6.14.1
  --- Or.java	12 Jun 2001 19:16:56 -0000	1.6
  +++ Or.java	14 Aug 2002 20:07:05 -0000	1.6.14.1
  @@ -69,6 +69,13 @@
    */
   public class Or extends Operation
   {
  +  /**
  +   * @see org.apache.xpath.operations.Operation#getLookupTable()
  +   */
  +  public OpFuncLookupTable getLookupTable()
  +  {
  +    return null;
  +  }
   
     /**
      * OR two expressions and return the boolean result. Override
  
  
  
  1.4.18.1  +4 -4      xml-xalan/java/src/org/apache/xpath/operations/Quo.java
  
  Index: Quo.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Quo.java,v
  retrieving revision 1.4
  retrieving revision 1.4.18.1
  diff -u -r1.4 -r1.4.18.1
  --- Quo.java	17 Dec 2000 05:21:17 -0000	1.4
  +++ Quo.java	14 Aug 2002 20:07:05 -0000	1.4.18.1
  @@ -56,16 +56,16 @@
    */
   package org.apache.xpath.operations;
   
  +import javax.xml.transform.TransformerException;
  +import org.apache.xpath.objects.XDouble;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XNumber;
   
   /**
    * The 'quo' operation expression executer. (no longer supported by XPath).
    * @deprecated.
    */
  -public class Quo extends Operation
  +public class Quo extends OperationSimple
   {
  -
     // Actually, this is no longer supported by xpath...
   
     /**
  @@ -82,6 +82,6 @@
     public XObject operate(XObject left, XObject right)
             throws javax.xml.transform.TransformerException
     {
  -    return new XNumber((int) (left.num() / right.num()));
  +    return new XDouble((int) (left.num() / right.num()));
     }
   }
  
  
  
  1.9.4.1   +48 -6     xml-xalan/java/src/org/apache/xpath/operations/UnaryOperation.java
  
  Index: UnaryOperation.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/UnaryOperation.java,v
  retrieving revision 1.9
  retrieving revision 1.9.4.1
  diff -u -r1.9 -r1.9.4.1
  --- UnaryOperation.java	22 Mar 2002 01:04:45 -0000	1.9
  +++ UnaryOperation.java	14 Aug 2002 20:07:05 -0000	1.9.4.1
  @@ -56,13 +56,12 @@
    */
   package org.apache.xpath.operations;
   
  -import java.util.Vector;
  -
  -import javax.xml.transform.TransformerException;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
  +import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.ExpressionOwner;
   import org.apache.xpath.objects.XObject;
   
   /**
  @@ -85,9 +84,9 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    m_right.fixupVariables(vars, globalsSize);
  +    m_right.fixupVariables(vcs);
     }
     
     /**
  @@ -194,6 +193,49 @@
     	if(!m_right.deepEquals(((UnaryOperation)expr).m_right))
     		return false;
     		
  +  	return true;
  +  }
  +  
  +  /**
  +   * Add the left or right node of the operation.
  +   */
  +  public void jjtAddChild(org.apache.xpath.parser.Node n, int i) 
  +  {
  +  	n = fixupPrimarys(n);  // yuck.
  +  	if(0 == i)
  +  	{
  +    	m_right = (Expression)n;
  +    	m_right.exprSetParent(this);
  +  	}
  +  	else
  +  	{
  +  		// assertion... should not be able to occur.
  +  		throw new RuntimeException("Can't add more than one child to an UnaryOperation!");
  +  	}
  +  }
  +  
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	assertion(i == 0, "UnaryOperation can only have one child!");
  +  	return m_right;
  +  }
  +
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
  +  {
  +  	int count = 0;
  +   	if(null != m_right)
  +  		count++;
  +  	return count;
  +  }
  +
  +  /**
  +   * Tell if this node should have it's PathExpr ancestory reduced.
  +   */
  +  public boolean isPathExprReduced()
  +  {
     	return true;
     }
   
  
  
  
  1.18.4.1  +39 -8     xml-xalan/java/src/org/apache/xpath/operations/Variable.java
  
  Index: Variable.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/operations/Variable.java,v
  retrieving revision 1.18
  retrieving revision 1.18.4.1
  diff -u -r1.18 -r1.18.4.1
  --- Variable.java	10 Apr 2002 20:33:37 -0000	1.18
  +++ Variable.java	14 Aug 2002 20:07:05 -0000	1.18.4.1
  @@ -59,15 +59,12 @@
   import java.util.Vector;
   
   import javax.xml.transform.TransformerException;
  +
   import org.apache.xalan.res.XSLMessages;
  -import org.apache.xalan.templates.ElemTemplateElement;
  -import org.apache.xalan.templates.ElemVariable;
  -import org.apache.xalan.templates.Stylesheet;
  -import org.apache.xml.utils.PrefixResolver;
   import org.apache.xml.utils.QName;
   import org.apache.xpath.Expression;
  -import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPath;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  @@ -75,9 +72,8 @@
   import org.apache.xpath.axes.WalkerFactory;
   import org.apache.xpath.objects.XNodeSet;
   import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.parser.Node;
   import org.apache.xpath.res.XPATHErrorResources;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.SAXException;
   
   
   /**
  @@ -157,9 +153,11 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       m_fixUpWasCalled = true;
  +    Vector vars = vcs.getVariableNames();
  +    int globalsSize = vcs.getGlobalsSize();
       int sz = vars.size();
   
       for (int i = vars.size()-1; i >= 0; i--) 
  @@ -427,5 +425,38 @@
     	return false;
     }
     
  +  /**
  +   * Tell if this node should have it's PathExpr ancestory reduced.
  +   */
  +  public boolean isPathExprReduced()
  +  {
  +  	// Assume that the parent of the parent is always a PathExpr when this 
  +  	// method is called.
  +  	Node pathOwner = jjtGetParent().jjtGetParent();
  +  	return pathOwner.jjtGetNumChildren() == 1 ? true : false;
  +  }
  +
  +  public java.lang.String toString()
  +  {
  +  	return "$"+m_qname;
  +  }
  +
  +  /**
  +   * Returns the fixUpWasCalled.
  +   * @return boolean
  +   */
  +  public boolean isFixUpWasCalled()
  +  {
  +    return m_fixUpWasCalled;
  +  }
  +
  +  /**
  +   * Sets the fixUpWasCalled.
  +   * @param fixUpWasCalled The fixUpWasCalled to set
  +   */
  +  public void setFixUpWasCalled(boolean fixUpWasCalled)
  +  {
  +    m_fixUpWasCalled = fixUpWasCalled;
  +  }
   
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +274 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/Add.java
  
  
  
  
  1.1.2.1   +83 -0     xml-xalan/java/src/org/apache/xpath/operations/Attic/Follows.java
  
  
  
  
  1.1.2.1   +148 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/FortranEq.java
  
  
  
  
  1.1.2.1   +148 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/FortranGe.java
  
  
  
  
  1.1.2.1   +148 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/FortranGt.java
  
  
  
  
  1.1.2.1   +163 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/FortranLe.java
  
  
  
  
  1.1.2.1   +148 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/FortranLt.java
  
  
  
  
  1.1.2.1   +141 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/FortranNe.java
  
  
  
  
  1.1.2.1   +115 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/GenericOpFunc.java
  
  
  
  
  1.1.2.1   +83 -0     xml-xalan/java/src/org/apache/xpath/operations/Attic/GtGt.java
  
  
  
  
  1.1.2.1   +122 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/Idiv.java
  
  
  
  
  1.1.2.1   +111 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/Is.java
  
  
  
  
  1.1.2.1   +84 -0     xml-xalan/java/src/org/apache/xpath/operations/Attic/IsNot.java
  
  
  
  
  1.1.2.1   +83 -0     xml-xalan/java/src/org/apache/xpath/operations/Attic/LtLt.java
  
  
  
  
  1.1.2.1   +99 -0     xml-xalan/java/src/org/apache/xpath/operations/Attic/OpFuncLookupTable.java
  
  
  
  
  1.1.2.1   +208 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/OperationNormalized.java
  
  
  
  
  1.1.2.1   +109 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/OperationSimple.java
  
  
  
  
  1.1.2.1   +41 -0     xml-xalan/java/src/org/apache/xpath/operations/Attic/Pos.java
  
  
  
  
  1.1.2.1   +83 -0     xml-xalan/java/src/org/apache/xpath/operations/Attic/Precedes.java
  
  
  
  
  1.1.2.1   +258 -0    xml-xalan/java/src/org/apache/xpath/operations/Attic/Subtract.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +377 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/ASCII_CharStream.java
  
  
  
  
  1.1.2.1   +21 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/AnyKindTest.java
  
  
  
  
  1.1.2.1   +100 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/AtomicType.java
  
  
  
  
  1.1.2.1   +21 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/CommentTest.java
  
  
  
  
  1.1.2.1   +153 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/ElemOrAttrType.java
  
  
  
  
  1.1.2.1   +87 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/Empty.java
  
  
  
  
  1.1.2.1   +64 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/ForClause.java
  
  
  
  
  1.1.2.1   +25 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/IfExpr.java
  
  
  
  
  1.1.2.1   +26 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/In.java
  
  
  
  
  1.1.2.1   +14 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/Instanceof.java
  
  
  
  
  1.1.2.1   +200 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/ItemType.java
  
  
  
  
  1.1.2.1   +123 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/JJTXPathState.java
  
  
  
  
  1.1.2.1   +28 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/KindTest.java
  
  
  
  
  1.1.2.1   +9 -0      xml-xalan/java/src/org/apache/xpath/parser/Attic/LbrackOrRbrack.java
  
  
  
  
  1.1.2.1   +30 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/NCNameColonStar.java
  
  
  
  
  1.1.2.1   +142 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/NameTest.java
  
  
  
  
  1.1.2.1   +37 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/Node.java
  
  
  
  
  1.1.2.1   +102 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/NodeTest.java
  
  
  
  
  1.1.2.1   +111 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/NodeTestType.java
  
  
  
  
  1.1.2.1   +132 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/NonExecutableExpression.java
  
  
  
  
  1.1.2.1   +88 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/OccurrenceIndicator.java
  
  
  
  
  1.1.2.1   +35 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/OfType.java
  
  
  
  
  1.1.2.1   +192 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/ParseException.java
  
  
  
  
  1.1.2.1   +117 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/PathExpr.java
  
  
  
  
  1.1.2.1   +86 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/Pattern.java
  
  
  
  
  1.1.2.1   +54 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/PatternAxis.java
  
  
  
  
  1.1.2.1   +43 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/Predicates.java
  
  
  
  
  1.1.2.1   +45 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/ProcessingInstructionTest.java
  
  
  
  
  1.1.2.1   +70 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/QName.java
  
  
  
  
  1.1.2.1   +22 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/QuantifiedExpr.java
  
  
  
  
  1.1.2.1   +22 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/Return.java
  
  
  
  
  1.1.2.1   +29 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/RootOfRoot.java
  
  
  
  
  1.1.2.1   +45 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/RootOfRootPattern.java
  
  
  
  
  1.1.2.1   +87 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/SchemaContext.java
  
  
  
  
  1.1.2.1   +77 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/SchemaContextStep.java
  
  
  
  
  1.1.2.1   +87 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/SchemaGlobalContext.java
  
  
  
  
  1.1.2.1   +89 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/SchemaType.java
  
  
  
  
  1.1.2.1   +187 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/SequenceType.java
  
  
  
  
  1.1.2.1   +1308 -0   xml-xalan/java/src/org/apache/xpath/parser/Attic/SimpleNode.java
  
  
  
  
  1.1.2.1   +65 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/SlashOrSlashSlash.java
  
  
  
  
  1.1.2.1   +22 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/Star.java
  
  
  
  
  1.1.2.1   +29 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/StarColonNCName.java
  
  
  
  
  1.1.2.1   +262 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/StepExpr.java
  
  
  
  
  1.1.2.1   +38 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/TempFunctionHolder.java
  
  
  
  
  1.1.2.1   +21 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/TextTest.java
  
  
  
  
  1.1.2.1   +81 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/Token.java
  
  
  
  
  1.1.2.1   +133 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/TokenMgrError.java
  
  
  
  
  1.1.2.1   +54 -0     xml-xalan/java/src/org/apache/xpath/parser/Attic/UnaryExpr.java
  
  
  
  
  1.1.2.1   +3909 -0   xml-xalan/java/src/org/apache/xpath/parser/Attic/XPath.java
  
  
  
  
  1.1.2.1   +286 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/XPathConstants.java
  
  
  
  
  1.1.2.1   +7912 -0   xml-xalan/java/src/org/apache/xpath/parser/Attic/XPathTokenManager.java
  
  
  
  
  1.1.2.1   +227 -0    xml-xalan/java/src/org/apache/xpath/parser/Attic/XPathTreeConstants.java
  
  
  
  
  1.1.2.1   +8 -0      xml-xalan/java/src/org/apache/xpath/parser/Attic/XPathVisitor.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.12.1  +12 -4     xml-xalan/java/src/org/apache/xpath/patterns/ContextMatchStepPattern.java
  
  Index: ContextMatchStepPattern.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/ContextMatchStepPattern.java,v
  retrieving revision 1.3
  retrieving revision 1.3.12.1
  diff -u -r1.3 -r1.3.12.1
  --- ContextMatchStepPattern.java	27 Jul 2001 17:42:40 -0000	1.3
  +++ ContextMatchStepPattern.java	14 Aug 2002 20:07:09 -0000	1.3.12.1
  @@ -71,15 +71,23 @@
   public class ContextMatchStepPattern extends StepPattern
   {
   
  +//  /**
  +//   * Construct a ContextMatchStepPattern.
  +//   *
  +//   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  +//   */
  +//  public ContextMatchStepPattern(int axis, int paxis)
  +//  {
  +//    super(DTMFilter.SHOW_ALL, axis, paxis);
  +//  }
  +  
     /**
      * Construct a ContextMatchStepPattern.
  -   *
  -   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
      */
  -  public ContextMatchStepPattern(int axis, int paxis)
  +  public ContextMatchStepPattern()
     {
  -    super(DTMFilter.SHOW_ALL, axis, paxis);
     }
  +
   
     /**
      * Execute this pattern step, including predicates.
  
  
  
  1.9.4.1   +74 -17    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.9
  retrieving revision 1.9.4.1
  diff -u -r1.9 -r1.9.4.1
  --- FunctionPattern.java	22 Mar 2002 01:04:45 -0000	1.9
  +++ FunctionPattern.java	14 Aug 2002 20:07:09 -0000	1.9.4.1
  @@ -61,13 +61,15 @@
   import javax.xml.transform.TransformerException;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xml.utils.QName;
   import org.apache.xpath.Expression;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
   import org.apache.xpath.objects.XNumber;
   import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.patterns.StepPattern.PredOwner;
  +import org.apache.xpath.parser.Node;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -76,22 +78,30 @@
   public class FunctionPattern extends StepPattern
   {
   
  +//  /**
  +//   * Construct a FunctionPattern from a
  +//   * {@link org.apache.xpath.functions.Function expression}.
  +//   *
  +//   *
  +//   * @param a should be a {@link org.apache.xpath.functions.Function expression}.
  +//   *
  +//   * NEEDSDOC @param expr
  +//   */
  +//  public FunctionPattern(Expression expr, int axis, int predaxis)
  +//  {
  +//
  +//    super(0, null, null, axis, predaxis);
  +//
  +//    m_functionExpr = expr;
  +//  }
  +
     /**
  -   * Construct a FunctionPattern from a
  -   * {@link org.apache.xpath.functions.Function expression}.
  -   *
  -   *
  -   * @param a should be a {@link org.apache.xpath.functions.Function expression}.
  -   *
  -   * NEEDSDOC @param expr
  +   * Construct a FunctionPattern.
      */
  -  public FunctionPattern(Expression expr, int axis, int predaxis)
  +  public FunctionPattern()
     {
  -
  -    super(0, null, null, axis, predaxis);
  -
  -    m_functionExpr = expr;
     }
  +  
   
     /**
      * Static calc of match score.
  @@ -109,7 +119,41 @@
      * Should be a {@link org.apache.xpath.functions.Function expression}.
      *  @serial   
      */
  -  Expression m_functionExpr;
  +  protected Expression m_functionExpr;
  +  
  +  /**
  +   * @see ExpressionOwner#setExpression(Expression)
  +   */
  +  public void setFunctionExpression(Expression exp)
  +  {
  +    exp.exprSetParent(this);
  +  	m_functionExpr = exp;
  +  }
  +  
  +  /**
  +   * Add parameters to the function expression.
  +   */
  +  public void jjtAddChild(Node n, int i) 
  +  {
  +  	if(!(n instanceof org.apache.xpath.parser.QName))
  +  	{
  +  		m_functionExpr.jjtAddChild(n, i-1);
  +  	}
  +  }
  +
  +//  public void jjtClose() 
  +//  {
  +//  	if(
  +//  }
  +
  +  public Node jjtGetChild(int i) 
  +  {
  +    return m_functionExpr.jjtGetChild(i);
  +  }
  +
  +  public int jjtGetNumChildren() {
  +    return m_functionExpr.jjtGetNumChildren();
  +  }
     
     /**
      * This function is used to fixup variables from QNames to stack frame 
  @@ -121,10 +165,10 @@
      * in the stack frame (but variables above the globalsTop value will need 
      * to be offset to the current stack frame).
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
  -    super.fixupVariables(vars, globalsSize);
  -    m_functionExpr.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
  +    m_functionExpr.fixupVariables(vcs);
     }
   
     
  @@ -286,5 +330,18 @@
       m_functionExpr.callVisitors(new FunctionOwner(), visitor);
       super.callSubtreeVisitors(visitor);
     }
  +  
  +  /**
  +   * Get the string represenentation of this step for diagnostic purposes.
  +   *
  +   *
  +   * @return A string representation of this step, built by reverse-engineering 
  +   * the contained info.
  +   */
  +  public String toString()
  +  {
  +  	return m_functionExpr.toString();
  +  }
  +
   
   }
  
  
  
  1.23.4.1  +40 -40    xml-xalan/java/src/org/apache/xpath/patterns/NodeTest.java
  
  Index: NodeTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/NodeTest.java,v
  retrieving revision 1.23
  retrieving revision 1.23.4.1
  diff -u -r1.23 -r1.23.4.1
  --- NodeTest.java	10 Apr 2002 20:33:37 -0000	1.23
  +++ NodeTest.java	14 Aug 2002 20:07:09 -0000	1.23.4.1
  @@ -61,13 +61,13 @@
   import javax.xml.transform.TransformerException;
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMFilter;
  -import org.apache.xml.dtm.ref.ExpandedNameTable;
   import org.apache.xpath.Expression;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPath;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
  -import org.apache.xpath.objects.XNumber;
  +import org.apache.xpath.objects.XDouble;
   import org.apache.xpath.objects.XObject;
   
   /**
  @@ -188,68 +188,68 @@
      *  {@link #SCORE_OTHER}.
      *  @serial
      */
  -  XNumber m_score;
  +  XDouble m_score;
   
     /**
      * The match score if the pattern consists of just a NodeTest.
      *  @see <a href="http://www.w3.org/TR/xslt#conflict">XSLT Specification - 5.5 Conflict Resolution for Template Rules</a> 
      */
  -  public static final XNumber SCORE_NODETEST =
  -    new XNumber(XPath.MATCH_SCORE_NODETEST);
  +  public static final XDouble SCORE_NODETEST =
  +    new XDouble(XPath.MATCH_SCORE_NODETEST);
   
     /**
      * The match score if the pattern pattern has the form NCName:*.
      *  @see <a href="http://www.w3.org/TR/xslt#conflict">XSLT Specification - 5.5 Conflict Resolution for Template Rules</a> 
      */
  -  public static final XNumber SCORE_NSWILD =
  -    new XNumber(XPath.MATCH_SCORE_NSWILD);
  +  public static final XDouble SCORE_NSWILD =
  +    new XDouble(XPath.MATCH_SCORE_NSWILD);
   
     /**
      * The match score if the pattern has the form
      * of a QName optionally preceded by an @ character.
      *  @see <a href="http://www.w3.org/TR/xslt#conflict">XSLT Specification - 5.5 Conflict Resolution for Template Rules</a> 
      */
  -  public static final XNumber SCORE_QNAME =
  -    new XNumber(XPath.MATCH_SCORE_QNAME);
  +  public static final XDouble SCORE_QNAME =
  +    new XDouble(XPath.MATCH_SCORE_QNAME);
   
     /**
      * The match score if the pattern consists of something
      * other than just a NodeTest or just a qname.
      *  @see <a href="http://www.w3.org/TR/xslt#conflict">XSLT Specification - 5.5 Conflict Resolution for Template Rules</a> 
      */
  -  public static final XNumber SCORE_OTHER =
  -    new XNumber(XPath.MATCH_SCORE_OTHER);
  +  public static final XDouble SCORE_OTHER =
  +    new XDouble(XPath.MATCH_SCORE_OTHER);
   
     /**
      * The match score if no match is made.
      *  @see <a href="http://www.w3.org/TR/xslt#conflict">XSLT Specification - 5.5 Conflict Resolution for Template Rules</a> 
      */
  -  public static final XNumber SCORE_NONE =
  -    new XNumber(XPath.MATCH_SCORE_NONE);
  +  public static final XDouble SCORE_NONE =
  +    new XDouble(XPath.MATCH_SCORE_NONE);
   
  -  /**
  -   * Construct an NodeTest that tests for namespaces and node names.
  -   *
  -   *
  -   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  -   * @param namespace The namespace to be tested.
  -   * @param name The local name to be tested.
  -   */
  -  public NodeTest(int whatToShow, String namespace, String name)
  -  {
  -    initNodeTest(whatToShow, namespace, name);
  -  }
  -
  -  /**
  -   * Construct an NodeTest that doesn't test for node names.
  -   *
  -   *
  -   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  -   */
  -  public NodeTest(int whatToShow)
  -  {
  -    initNodeTest(whatToShow);
  -  }
  +//  /**
  +//   * Construct an NodeTest that tests for namespaces and node names.
  +//   *
  +//   *
  +//   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  +//   * @param namespace The namespace to be tested.
  +//   * @param name The local name to be tested.
  +//   */
  +//  public NodeTest(int whatToShow, String namespace, String name)
  +//  {
  +//    initNodeTest(whatToShow, namespace, name);
  +//  }
  +//
  +//  /**
  +//   * Construct an NodeTest that doesn't test for node names.
  +//   *
  +//   *
  +//   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  +//   */
  +//  public NodeTest(int whatToShow)
  +//  {
  +//    initNodeTest(whatToShow);
  +//  }
     
     /**
      * @see Expression#deepEquals(Expression)
  @@ -334,13 +334,13 @@
      * True if this test has a null namespace and a local name of {@link #WILD}.
      *  @serial 
      */
  -  private boolean m_isTotallyWild;
  +  boolean m_isTotallyWild;
     
     /**
      * Get the static score for this node test.
      * @return Should be one of the SCORE_XXX constants.
      */
  -  public XNumber getStaticScore()
  +  public XDouble getStaticScore()
     {
       return m_score;
     }
  @@ -349,7 +349,7 @@
      * Set the static score for this node test.
      * @param score Should be one of the SCORE_XXX constants.
      */
  -  public void setStaticScore(XNumber score)
  +  public void setStaticScore(XDouble score)
     {
       m_score = score;
     }
  @@ -715,7 +715,7 @@
     /**
      * Node tests by themselves do not need to fix up variables.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       // no-op
     }
  
  
  
  1.24.4.1  +169 -43   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.24
  retrieving revision 1.24.4.1
  diff -u -r1.24 -r1.24.4.1
  --- StepPattern.java	22 Mar 2002 01:04:45 -0000	1.24
  +++ StepPattern.java	14 Aug 2002 20:07:09 -0000	1.24.4.1
  @@ -56,6 +56,11 @@
    */
   package org.apache.xpath.patterns;
   
  +import java.io.ByteArrayOutputStream;
  +import java.io.CharArrayWriter;
  +import java.io.OutputStream;
  +import java.io.PrintStream;
  +import java.io.PrintWriter;
   import java.util.Vector;
   
   import javax.xml.transform.TransformerException;
  @@ -64,12 +69,16 @@
   import org.apache.xml.dtm.DTMAxisTraverser;
   import org.apache.xml.dtm.DTMFilter;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
   import org.apache.xpath.axes.SubContextList;
  -import org.apache.xpath.compiler.PsuedoNames;
   import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.parser.Node;
  +import org.apache.xpath.parser.PatternAxis;
  +import org.apache.xpath.parser.Predicates;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -79,48 +88,86 @@
   {
   
     /** The axis for this test. */
  -  protected int m_axis;
  +  protected int m_axis = org.apache.xml.dtm.Axis.SELF;
  +
  +//  /**
  +//   * Construct a StepPattern that tests for namespaces and node names.
  +//   *
  +//   *
  +//   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  +//   * @param namespace The namespace to be tested.
  +//   * @param name The local name to be tested.
  +//   * @param axis The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
  +//   * @param axisForPredicate No longer used.
  +//   */
  +//  public StepPattern(int whatToShow, String namespace, String name, int axis,
  +//                     int axisForPredicate)
  +//  {
  +//
  +//    super(whatToShow, namespace, name);
  +//
  +//    m_axis = axis;
  +//  }
  +//
  +//  /**
  +//   * Construct a StepPattern that doesn't test for node names.
  +//   *
  +//   *
  +//   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  +//   * @param axis The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
  +//   * @param axisForPredicate No longer used.
  +//   */
  +//  public StepPattern(int whatToShow, int axis, int axisForPredicate)
  +//  {
  +//
  +//    super(whatToShow);
  +//
  +//    m_axis = axis;
  +//  }
   
     /**
  -   * Construct a StepPattern that tests for namespaces and node names.
  -   *
  -   *
  -   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  -   * @param namespace The namespace to be tested.
  -   * @param name The local name to be tested.
  -   * @param axis The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
  -   * @param axisForPredicate No longer used.
  +   * Construct a StepPattern.
      */
  -  public StepPattern(int whatToShow, String namespace, String name, int axis,
  -                     int axisForPredicate)
  +  public StepPattern()
     {
  +  }
   
  -    super(whatToShow, namespace, name);
   
  -    m_axis = axis;
  -  }
  +  /**
  +   * The target local name or psuedo name, for hash table lookup optimization.
  +   *  @serial
  +   */
  +  String m_targetString;  // only calculate on head
  +  
  +  /**
  +   * Psuedo name for a wild card pattern ('*').
  +   */
  +  public static final String PSEUDONAME_ANY = "*";
   
     /**
  -   * Construct a StepPattern that doesn't test for node names.
  -   *
  -   *
  -   * @param whatToShow Bit set defined mainly by {@link org.w3c.dom.traversal.NodeFilter}.
  -   * @param axis The Axis for this test, one of of Axes.ANCESTORORSELF, etc.
  -   * @param axisForPredicate No longer used.
  +   * Psuedo name for the root node.
      */
  -  public StepPattern(int whatToShow, int axis, int axisForPredicate)
  -  {
  +  public static final String PSEUDONAME_ROOT = "/";
   
  -    super(whatToShow);
  +  /**
  +   * Psuedo name for a text node.
  +   */
  +  public static final String PSEUDONAME_TEXT = "#text";
   
  -    m_axis = axis;
  -  }
  +  /**
  +   * Psuedo name for a comment node.
  +   */
  +  public static final String PSEUDONAME_COMMENT = "#comment";
   
     /**
  -   * The target local name or psuedo name, for hash table lookup optimization.
  -   *  @serial
  +   * Psuedo name for a processing instruction node.
      */
  -  String m_targetString;  // only calculate on head
  +  public static final String PSEUDONAME_PI = "#pi";
  +
  +  /**
  +   * Psuedo name for an unknown type value.
  +   */
  +  public static final String PSEUDONAME_OTHER = "*";
   
     /**
      * Calculate the local name or psuedo name of the node that this pattern will test,
  @@ -136,28 +183,28 @@
       switch (whatToShow)
       {
       case DTMFilter.SHOW_COMMENT :
  -      m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
  +      m_targetString = PSEUDONAME_COMMENT;
         break;
       case DTMFilter.SHOW_TEXT :
       case DTMFilter.SHOW_CDATA_SECTION :
       case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION) :
  -      m_targetString = PsuedoNames.PSEUDONAME_TEXT;
  +      m_targetString = PSEUDONAME_TEXT;
         break;
       case DTMFilter.SHOW_ALL :
  -      m_targetString = PsuedoNames.PSEUDONAME_ANY;
  +      m_targetString = PSEUDONAME_ANY;
         break;
       case DTMFilter.SHOW_DOCUMENT :
       case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  -      m_targetString = PsuedoNames.PSEUDONAME_ROOT;
  +      m_targetString = PSEUDONAME_ROOT;
         break;
       case DTMFilter.SHOW_ELEMENT :
         if (this.WILD == m_name)
  -        m_targetString = PsuedoNames.PSEUDONAME_ANY;
  +        m_targetString = PSEUDONAME_ANY;
         else
           m_targetString = m_name;
         break;
       default :
  -      m_targetString = PsuedoNames.PSEUDONAME_ANY;
  +      m_targetString = PSEUDONAME_ANY;
         break;
       }
     }
  @@ -193,22 +240,22 @@
      * to be offset to the current stack frame).
      * @param globalsSize The number of variables in the global variable area.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
   
  -    super.fixupVariables(vars, globalsSize);
  +    super.fixupVariables(vcs);
   
       if (null != m_predicates)
       {
         for (int i = 0; i < m_predicates.length; i++)
         {
  -        m_predicates[i].fixupVariables(vars, globalsSize);
  +        m_predicates[i].fixupVariables(vcs);
         }
       }
   
       if (null != m_relativePathPattern)
       {
  -      m_relativePathPattern.fixupVariables(vars, globalsSize);
  +      m_relativePathPattern.fixupVariables(vcs);
       }
     }
   
  @@ -345,6 +392,9 @@
       }
       else
         super.calcScore();
  +      
  +    if(null != m_relativePathPattern)
  +      m_relativePathPattern.calcScore();
   
       if (null == m_targetString)
         calcTargetString();
  @@ -814,11 +864,24 @@
   
       return result;
     }
  +  
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	assertion(i == 0, "StepPattern can only have one child!");
  +  	return m_relativePathPattern;
  +  }
  +
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
  +  {
  +  	return (null == m_relativePathPattern) ? 0 : 1;
  +  }
   
     /**
      * Get the string represenentation of this step for diagnostic purposes.
      *
  -   *
      * @return A string representation of this step, built by reverse-engineering 
      * the contained info.
      */
  @@ -826,8 +889,9 @@
     {
   
       StringBuffer buf = new StringBuffer();
  -
  -    for (StepPattern pat = this; pat != null; pat = pat.m_relativePathPattern)
  +	
  +	  StepPattern pat = this;
  +    // for (StepPattern pat = this; pat != null; pat = pat.m_relativePathPattern)
       {
         if (pat != this)
           buf.append("/");
  @@ -901,7 +965,11 @@
           for (int i = 0; i < pat.m_predicates.length; i++)
           {
             buf.append("[");
  -          buf.append(pat.m_predicates[i]);
  +          ByteArrayOutputStream baos = new ByteArrayOutputStream();
  +          PrintStream ps = new PrintStream(baos);
  +          pat.m_predicates[i].dump("  ", ps);
  +          ps.close();
  +          buf.append(baos.toString());
             buf.append("]");
           }
         }
  @@ -1053,6 +1121,56 @@
     }
     
     /**
  +   * This method is called by the parser to add the PatternAxis, 
  +   * NodeTest, and Predicates.  We only use the node the populate 
  +   * the fields of this class.
  +   */
  +  public void jjtAddChild(org.apache.xpath.parser.Node n, int index) 
  +  {
  +    if(n instanceof org.apache.xpath.parser.PatternAxis)
  +    {
  +    	m_axis = ((org.apache.xpath.parser.PatternAxis)n).getAxis();
  +    	if(Axis.ATTRIBUTE == m_axis)
  +    	{
  +    		m_whatToShow = DTMFilter.SHOW_ATTRIBUTE;
  +    		if(0 == index)
  +    			m_axis = Axis.SELF;
  +    	}
  +    } 
  +    else if(n instanceof org.apache.xpath.parser.NodeTest)
  +    {
  +    	org.apache.xpath.parser.NodeTest ntest = (org.apache.xpath.parser.NodeTest)n;
  +    	m_isTotallyWild = ntest.isTotallyWild();
  +    	m_namespace = ntest.getNamespaceURI();
  +    	m_name = ntest.getLocalName();
  +    	if(Axis.ATTRIBUTE == m_axis)
  +    		m_whatToShow = DTMFilter.SHOW_ATTRIBUTE;
  +    	else
  +    		m_whatToShow = ntest.getWhatToShow();
  +    }
  +    else if(n instanceof org.apache.xpath.parser.Predicates)
  +    {
  +    	Vector preds = ((org.apache.xpath.parser.Predicates)n).getPreds();
  +    	if(null != preds)
  +    	{
  +    		int nPreds = preds.size();
  +    		m_predicates = new Expression[nPreds];
  +    		for(int i = 0; i < nPreds; i++)
  +    		{
  +    			m_predicates[i] = (Expression)preds.elementAt(i);
  +    		}
  +    		
  +    	}
  +    }
  +    else
  +    {
  +    	// Assertion, should never happen.
  +    	throw new RuntimeException("node can only be a QName or Wildcard!");
  +    }
  +  }
  +
  +  
  +  /**
      * @see Expression#deepEquals(Expression)
      */
     public boolean deepEquals(Expression expr)
  @@ -1088,4 +1206,12 @@
     }
   
   
  +  /**
  +   * @see org.apache.xpath.parser.Node#jjtClose()
  +   */
  +  public void jjtClose()
  +  {
  +    super.jjtClose();
  +  }
  +
   }
  
  
  
  1.9.4.1   +96 -10    xml-xalan/java/src/org/apache/xpath/patterns/UnionPattern.java
  
  Index: UnionPattern.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/UnionPattern.java,v
  retrieving revision 1.9
  retrieving revision 1.9.4.1
  diff -u -r1.9 -r1.9.4.1
  --- UnionPattern.java	22 Mar 2002 01:04:45 -0000	1.9
  +++ UnionPattern.java	14 Aug 2002 20:07:09 -0000	1.9.4.1
  @@ -60,10 +60,14 @@
   
   import javax.xml.transform.TransformerException;
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.VariableComposeState;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPathVisitor;
   import org.apache.xpath.objects.XObject;
  +import org.apache.xpath.parser.Node;
  +import org.apache.xpath.parser.Pattern;
   
   /**
    * <meta name="usage" content="advanced"/>
  @@ -75,16 +79,16 @@
   
     /** Array of the contained step patterns to be tested.
      *  @serial  */
  -  private StepPattern[] m_patterns;
  +  private ExpressionNode[] m_patterns;
     
     /**
      * No arguments to process, so this does nothing.
      */
  -  public void fixupVariables(java.util.Vector vars, int globalsSize)
  +  public void fixupVariables(VariableComposeState vcs)
     {
       for (int i = 0; i < m_patterns.length; i++) 
       {
  -      m_patterns[i].fixupVariables(vars, globalsSize);
  +      ((Expression)m_patterns[i]).fixupVariables(vcs);
       }
     }
   
  @@ -102,7 +106,7 @@
         int n = m_patterns.length;
         for (int i = 0; i < n; i++) 
         {
  -        if(m_patterns[i].canTraverseOutsideSubtree())
  +        if(((StepPattern)m_patterns[i]).canTraverseOutsideSubtree())
             return true;
         }
        }
  @@ -127,6 +131,88 @@
       }
       
     }
  +  
  +  /** This method tells the node to add its argument to the node's
  +    list of children.  */
  +  public void exprAddChild(ExpressionNode n, int i)
  +  {
  +  	
  +  	if(null == m_patterns)
  +  	{
  +  		m_patterns = new ExpressionNode[i+1];
  +  	}
  +  	if(i >= m_patterns.length)
  +  	{
  +   		ExpressionNode newPats[] = new ExpressionNode[i+1];
  +  		System.arraycopy(m_patterns, 0, newPats, 0, m_patterns.length);
  +  		m_patterns = newPats;
  +  		
  +  	}
  +    m_patterns[i] = n;
  +  }
  +  
  +  public void jjtAddChild(org.apache.xpath.parser.Node n, int i) 
  +  {
  +  	if(n instanceof UnionPattern)
  +  	{
  +  		// Undo the work of having the unions as binary operators.
  +  		// Certainly, this makes no sense for match patters.
  +  		UnionPattern up = (UnionPattern)n;
  +  		int count = up.jjtGetNumChildren();
  +  		for(int j = 0; j < count; j++)
  +  		{
  +  			n = up.jjtGetChild(j);
  +  			if(n instanceof Pattern)
  +		  	{
  +		  		n = n.jjtGetChild(0);
  +		  		// n.jjtSetParent(this);  // Called in jjtClose
  +		  	}
  +
  +  			exprAddChild((ExpressionNode)n, i+j);
  +  		}
  +  	}
  +  	else
  +  	{
  +  		if(n instanceof Pattern)
  +		{
  +		  	n = n.jjtGetChild(0);
  +		  	// n.jjtSetParent(this); // Called in jjtClose
  +		}
  +    	exprAddChild((ExpressionNode)n, i);
  +  	}
  +  }
  +    
  +  /** This method returns a child node.  The children are numbered
  +     from zero, left to right. */
  +  public ExpressionNode exprGetChild(int i)
  +  {
  +  	return m_patterns[i];
  +  }
  +
  +  /** Return the number of children the node has. */
  +  public int exprGetNumChildren()
  +  {
  +  	if(null == m_patterns)
  +  	{
  +  		return 0;
  +  	}
  +  	else 
  +  	{
  +  		return m_patterns.length;
  +  	}
  +  }
  +  
  +  public void jjtClose() 
  +  {
  +  	super.jjtClose();
  +  	int childCount = jjtGetNumChildren();
  +  	for(int i = 0; i < childCount; i++)
  +  	{
  +  		Node child = jjtGetChild(i);
  +  		child.jjtSetParent(this);
  +  	}
  +  }
  +
   
     /**
      * Get the contained step patterns to be tested. 
  @@ -134,9 +220,9 @@
      *
      * @return an array of the contained step patterns to be tested. 
      */
  -  public StepPattern[] getPatterns()
  +  public ExpressionNode[] getPatterns()
     {
  -    return m_patterns;
  +    return (ExpressionNode[])m_patterns;
     }
   
     /**
  @@ -160,7 +246,7 @@
   
       for (int i = 0; i < n; i++)
       {
  -      XObject score = m_patterns[i].execute(xctxt);
  +      XObject score = ((Expression)m_patterns[i]).execute(xctxt);
   
         if (score != NodeTest.SCORE_NONE)
         {
  @@ -193,7 +279,7 @@
        */
       public Expression getExpression()
       {
  -      return m_patterns[m_index];
  +      return (Expression)m_patterns[m_index];
       }
   
   
  @@ -218,7 +304,7 @@
     		int n = m_patterns.length;
     		for(int i = 0; i < n; i++)
     		{
  -  			m_patterns[i].callVisitors(new UnionPathPartOwner(i), visitor);
  +  			((Expression)m_patterns[i]).callVisitors(new UnionPathPartOwner(i), visitor);
     		}
     	}
     }
  @@ -241,7 +327,7 @@
     			
     		for(int i = 0; i < n; i++)
     		{
  -  			if(!m_patterns[i].deepEquals(up.m_patterns[i]))
  +  			if(!((Expression)m_patterns[i]).deepEquals((Expression)up.m_patterns[i]))
     				return false;
     		}
     	}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +77 -0     xml-xalan/java/src/org/apache/xpath/quantified/Attic/Every.java
  
  
  
  
  1.1.2.1   +76 -0     xml-xalan/java/src/org/apache/xpath/quantified/Attic/In.java
  
  
  
  
  1.1.2.1   +76 -0     xml-xalan/java/src/org/apache/xpath/quantified/Attic/Satisfies.java
  
  
  
  
  1.1.2.1   +70 -0     xml-xalan/java/src/org/apache/xpath/quantified/Attic/Some.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.16.2.1  +0 -61     xml-xalan/java/src/org/apache/xpath/res/XPATHErrorResources.java
  
  Index: XPATHErrorResources.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/res/XPATHErrorResources.java,v
  retrieving revision 1.16
  retrieving revision 1.16.2.1
  diff -u -r1.16 -r1.16.2.1
  --- XPATHErrorResources.java	10 Jul 2002 16:06:32 -0000	1.16
  +++ XPATHErrorResources.java	14 Aug 2002 20:07:09 -0000	1.16.2.1
  @@ -464,68 +464,7 @@
     
   // Variable accessed before it is bound!
     public static final int ER_VARIABLE_ACCESSED_BEFORE_BIND = 85;
  -  
  -  // XStringForFSB can not take a string for an argument!
  -  public static final int ER_FSB_CANNOT_TAKE_STRING = 86;
  -  
  -  // Error! Setting the root of a walker to null!
  -  public static final int ER_SETTING_WALKER_ROOT_TO_NULL = 87;
  -  
  -  // This NodeSetDTM can not iterate to a previous node!
  -  public static final int ER_NODESETDTM_CANNOT_ITERATE = 88;
  -  
  -  // This NodeSet can not iterate to a previous node!
  -  public static final int ER_NODESET_CANNOT_ITERATE = 89;
   
  -  // This NodeSetDTM can not do indexing or counting functions!
  -  public static final int ER_NODESETDTM_CANNOT_INDEX = 90;
  -  
  -  // This NodeSet can not do indexing or counting functions!
  -  public static final int ER_NODESET_CANNOT_INDEX = 91;
  -
  -  // Can not call setShouldCacheNodes after nextNode has been called!
  -  public static final int ER_CANNOT_CALL_SETSHOULDCACHENODE = 92;
  -  
  -  // {0} only allows {1} arguments
  -  public static final int ER_ONLY_ALLOWS = 93;
  -  
  -  // Programmer's assertion in getNextStepPos: unknown stepType: {0}
  -  public static final int ER_UNKNOWN_STEP = 94;
  -  
  -  /** Problem with RelativeLocationPath */
  -  public static final int ER_EXPECTED_REL_LOC_PATH = 95;
  -
  -
  -   /** Problem with LocationPath */
  -  public static final int ER_EXPECTED_LOC_PATH = 96;
  -
  -
  -   /** Problem with Step */
  -  public static final int ER_EXPECTED_LOC_STEP = 97;
  -
  -
  -   /** Problem with NodeTest */
  -  public static final int ER_EXPECTED_NODE_TEST = 98;
  -
  -
  -   /** Expected step pattern */
  -  public static final int ER_EXPECTED_STEP_PATTERN = 99;
  -
  -  
  -   /** Expected relative path pattern */
  -  public static final int ER_EXPECTED_REL_PATH_PATTERN = 100;
  -  
  -  /** localname in QNAME should be a valid NCName */  
  -  public static final int ER_ARG_LOCALNAME_INVALID = 101;
  -
  -  /** prefix in QNAME should be a valid NCName */
  -  public static final int ER_ARG_PREFIX_INVALID = 102;
  -
  - 
  -
  -
  -
  -  
     // Warnings...
   
     /** Field WG_LOCALE_NAME_NOT_HANDLED          */
  
  
  
  1.7.2.1   +0 -35     xml-xalan/java/src/org/apache/xpath/res/XPATHErrorResources.properties
  
  Index: XPATHErrorResources.properties
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/res/XPATHErrorResources.properties,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- XPATHErrorResources.properties	10 Jul 2002 16:06:32 -0000	1.7
  +++ XPATHErrorResources.properties	14 Aug 2002 20:07:10 -0000	1.7.2.1
  @@ -176,41 +176,6 @@
   ER0084=2 or 3
   # ER_VARIABLE_ACCESSED_BEFORE_BIND
   ER0085=Variable accessed before it is bound!
  -# ER_FSB_CANNOT_TAKE_STRING 
  -ER0086=XStringForFSB can not take a string for an argument!
  -# ER_SETTING_WALKER_ROOT_T)_NULL 
  -ER0087=\n !!!! Error! Setting the root of a walker to null!!!
  -# ER_NODESETDTM_CANNOT_ITERATE
  -ER0088=This NodeSetDTM can not iterate to a previous node!
  -# ER_NODESET_CANNOT_ITERATE
  -ER0089=This NodeSet can not iterate to a previous node!
  -# ER_NODESETDTM_CANNOT_INDEX
  -ER0090=This NodeSetDTM can not do indexing or counting functions!
  -# ER_NODESET_CANNOT_INDEX
  -ER0091=This NodeSet can not do indexing or counting functions!
  -# ER_CANNOT_CALL_SETSHOULDCACHENODE
  -ER0092=Can not call setShouldCacheNodes after nextNode has been called!
  -# ER_ONLY_ALLOWS
  -ER0093={0} only allows {1} arguments
  -# ER_UNKNOWN_STEP
  -ER0094=Programmer's assertion in getNextStepPos: unknown stepType: {0}
  -# ER_EXPECTED_REL_LOC_PATH
  -ER0095=A relative location path was expected following the '/' or '//' token.
  -# ER_EXPECTED_LOC_PATH
  -ER0096=A location path was expected, but the following token was encountered\u003a  {0}
  -# ER_EXPECTED_LOC_STEP
  -ER0097=A location step was expected following the '/' or '//' token.
  -# ER_EXPECTED_NODE_TEST
  -ER0098=A node test that matches either NCName:* or QName was expected.
  -# ER_EXPECTED_STEP_PATTERN
  -ER0099=A step pattern was expected, but '/' was encountered.
  -# ER_EXPECTED_REL_PATH_PATTERN
  -ER0100=A relative path pattern was expected.
  -# ER_ARG_LOCALNAME_INVALID
  -ER0101= Localname in QNAME should be a valid NCName   
  -# ER_ARG_PREFIX_INVALID
  -ER0102=Prefix in QNAME should be a valid NCName 
  -
   
   # WG_LOCALE_NAME_NOT_HANDLED 
   WR0001=locale name in the format-number function not yet handled!
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +117 -0    xml-xalan/java/src/org/apache/xpath/seqctor/Attic/Binding.java
  
  
  
  
  1.1.2.1   +126 -0    xml-xalan/java/src/org/apache/xpath/seqctor/Attic/ExprSequence.java
  
  
  
  
  1.1.2.1   +157 -0    xml-xalan/java/src/org/apache/xpath/seqctor/Attic/ExprSequenceIter.java
  
  
  
  
  1.1.2.1   +167 -0    xml-xalan/java/src/org/apache/xpath/seqctor/Attic/FLWRExpr.java
  
  
  
  
  1.1.2.1   +227 -0    xml-xalan/java/src/org/apache/xpath/seqctor/Attic/FLWRIter.java
  
  
  
  
  1.1.2.1   +32 -0     xml-xalan/java/src/org/apache/xpath/seqctor/Attic/RangeExpr.java
  
  
  
  
  1.1.2.1   +319 -0    xml-xalan/java/src/org/apache/xpath/seqctor/Attic/RangeIter.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +139 -0    xml-xalan/java/src/org/apache/xpath/types/Attic/Atomizer.java
  
  
  
  
  1.1.2.1   +462 -0    xml-xalan/java/src/org/apache/xpath/types/Attic/InstanceofExpr.java
  
  
  
  
  1.1.2.1   +69 -0     xml-xalan/java/src/org/apache/xpath/types/Attic/Promoter.java
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org