zongaro     2002/09/12 09:07:37

  Modified:    java/src/org/apache/xalan/extensions Tag: XSLTC_DTM
                        MethodResolver.java
               java/src/org/apache/xalan/lib Tag: XSLTC_DTM ExsltMath.java
                        ExsltSets.java Extensions.java PipeDocument.java
                        Redirect.java
               java/src/org/apache/xalan/lib/sql Tag: XSLTC_DTM
                        DefaultConnectionPool.java SQLDocument.java
                        XConnection.java
               java/src/org/apache/xalan/processor Tag: XSLTC_DTM
                        XSLProcessorVersion.java
               java/src/org/apache/xalan/res Tag: XSLTC_DTM
                        XSLTInfo.properties
               java/src/org/apache/xalan/templates Tag: XSLTC_DTM
                        Constants.java ElemExtensionCall.java
               java/src/org/apache/xalan/transformer Tag: XSLTC_DTM
                        TransformerIdentityImpl.java
               java/src/org/apache/xalan/xslt Tag: XSLTC_DTM
                        EnvironmentCheck.java
               java/src/org/apache/xalan/xsltc/cmdline Tag: XSLTC_DTM
                        Compile.java Transform.java
               java/src/org/apache/xalan/xsltc/compiler Tag: XSLTC_DTM
                        Constants.java EqualityExpr.java Number.java
                        ParameterRef.java Predicate.java
                        RelationalExpr.java Sort.java SyntaxTreeNode.java
                        Template.java Variable.java VariableRef.java
                        VariableRefBase.java XSLTC.java xpath.cup
               java/src/org/apache/xalan/xsltc/compiler/util Tag: XSLTC_DTM
                        ResultTreeType.java
               java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
                        DOMImpl.java NodeCounter.java SAXImpl.java
               java/src/org/apache/xalan/xsltc/runtime Tag: XSLTC_DTM
                        AbstractTranslet.java BasisLibrary.java
               java/src/org/apache/xalan/xsltc/trax Tag: XSLTC_DTM
                        TrAXFilter.java TransformerHandlerImpl.java
                        TransformerImpl.java
               java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
                        DTMNodeProxy.java
               java/src/org/apache/xpath/axes Tag: XSLTC_DTM
                        SelfIteratorNoPredicate.java
               java/src/org/apache/xpath/functions Tag: XSLTC_DTM
                        FuncExtFunction.java
  Log:
  Brought code back up to date with changes on MAIN branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.27.2.1  +5 -2      
xml-xalan/java/src/org/apache/xalan/extensions/MethodResolver.java
  
  Index: MethodResolver.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/MethodResolver.java,v
  retrieving revision 1.27
  retrieving revision 1.27.2.1
  diff -u -r1.27 -r1.27.2.1
  --- MethodResolver.java       22 Mar 2002 14:50:49 -0000      1.27
  +++ MethodResolver.java       12 Sep 2002 16:07:31 -0000      1.27.2.1
  @@ -845,8 +845,11 @@
               // Xalan ensures that iter() always returns an
               // iterator positioned at the beginning.
               DTMIterator ni = xobj.iter();
  -            int handle = ni.nextNode();           
  -            return ni.getDTM(handle).getNode(handle); // may be null.
  +            int handle = ni.nextNode();
  +            if (handle != DTM.NULL)
  +              return ni.getDTM(handle).getNode(handle); // may be null.
  +            else
  +              return null;
             }
             else if(javaClass == java.lang.String.class)
             {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +227 -74   xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java
  
  Index: ExsltMath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- ExsltMath.java    1 Aug 2002 19:55:30 -0000       1.2.2.1
  +++ ExsltMath.java    12 Sep 2002 16:07:31 -0000      1.2.2.2
  @@ -57,36 +57,13 @@
   package org.apache.xalan.lib;
   
   import org.w3c.dom.Node;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentFragment;
   import org.w3c.dom.NodeList;
  -import org.w3c.dom.Text;
  -import org.w3c.dom.traversal.NodeIterator;
   
   import org.apache.xpath.NodeSet;
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XBoolean;
  -import org.apache.xpath.objects.XNumber;
  -import org.apache.xpath.objects.XRTreeFrag;
  -
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.XPathContext;
   import org.apache.xpath.DOMHelper;
  -import org.apache.xml.dtm.DTMIterator;
  -import org.apache.xml.dtm.ref.DTMNodeIterator;
  -import org.apache.xml.utils.XMLString;
  -
  -import org.xml.sax.SAXNotSupportedException;
  +import org.apache.xml.dtm.ref.DTMNodeProxy;
   
   import java.util.Hashtable;
  -import java.util.StringTokenizer;
  -
  -import org.apache.xalan.extensions.ExpressionContext;
  -import org.apache.xalan.res.XSLMessages;
  -import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.xslt.EnvironmentCheck;
  -
  -import javax.xml.parsers.*;
   
   /**
    * <meta name="usage" content="general"/>
  @@ -104,6 +81,15 @@
    */
   public class ExsltMath
   {
  +  // Constants
  +  private static String PI = 
"3.1415926535897932384626433832795028841971693993751";
  +  private static String E  = 
"2.71828182845904523536028747135266249775724709369996";
  +  private static String SQRRT2 = 
"1.41421356237309504880168872420969807856967187537694";
  +  private static String LN2 = 
"0.69314718055994530941723212145817656807550013436025";
  +  private static String LN10 = "2.302585092994046";
  +  private static String LOG2E = "1.4426950408889633";
  +  private static String SQRT1_2 = "0.7071067811865476";
  +     
     /**
      * The math:max function returns the maximum value of the nodes passed as 
the argument. 
      * The maximum value is defined as follows. The node set passed as an 
argument is sorted 
  @@ -114,32 +100,31 @@
      * If the node set is empty, or if the result of converting the string 
values of any of the 
      * nodes to a number is NaN, then NaN is returned.
      * 
  -   * @param expCon is passed in by the Xalan extension processor
  -   * @param ni The NodeIterator for the node-set to be evaluated.
  +   * @param nl The NodeList for the node-set to be evaluated.
      * 
      * @return String representation of the maximum value found, NaN if any 
node cannot be 
      * converted to a number.
      * 
      * @see <a href="http://www.exslt.org/";>EXSLT</a>
      */
  -  public static String max (ExpressionContext expCon, NodeIterator ni)
  +  public static String max (NodeList nl)
     {
  -    NodeSet ns = new NodeSet(ni);
  -    Node maxNode = null;
  -    double m = Double.MIN_VALUE;
  -    for (int i = 0; i < ns.getLength(); i++)
  -    {
  -      Node n = ns.elementAt(i);
  -      double d = expCon.toNumber(n);
  -      if (Double.isNaN(d))
  -        return "NaN";
  -      else if (d > m)
  -      {
  -        m = d;
  -        maxNode = n;
  -      }
  -    }
  -    return expCon.toString(maxNode);      
  +     Node maxNode = null;
  +     double m = Double.MIN_VALUE;
  +     for (int i = 0; i < nl.getLength(); i++)
  +     {
  +             Node n = nl.item(i);
  +             double d = toNumber(n);
  +             if (Double.isNaN(d))
  +               return "NaN";
  +             else if (d > m)
  +             {
  +                     m = d;
  +                     maxNode = n;
  +             }
  +     }
  +     
  +     return toString(maxNode);       
     }
   
     /**
  @@ -152,23 +137,21 @@
      * If the node set is empty, or if the result of converting the string 
values of any of 
      * the nodes to a number is NaN, then NaN is returned.
      * 
  -   * @param expCon is passed in by the Xalan extension processor
  -   * @param ni The NodeIterator for the node-set to be evaluated.
  +   * @param nl The NodeList for the node-set to be evaluated.
      * 
      * @return String representation of the minimum value found, NaN if any 
node cannot be 
      * converted to a number.
      * 
      * @see <a href="http://www.exslt.org/";>EXSLT</a>
      */
  -  public static String min (ExpressionContext expCon, NodeIterator ni)
  +  public static String min (NodeList nl)
     {
  -    NodeSet ns = new NodeSet(ni);
       Node minNode = null;
       double m = Double.MAX_VALUE;
  -    for (int i = 0; i < ns.getLength(); i++)
  +    for (int i = 0; i < nl.getLength(); i++)
       {
  -      Node n = ns.elementAt(i);
  -      double d = expCon.toNumber(n);
  +      Node n = nl.item(i);
  +      double d = toNumber(n);
         if (Double.isNaN(d))
           return "NaN";
         else if (d < m)
  @@ -177,7 +160,7 @@
           minNode = n;
         }
       }
  -    return expCon.toString(minNode);
  +    return toString(minNode);
     }
     
     /**
  @@ -192,30 +175,26 @@
      * of the nodes in the node set has a non-numeric value, math:highest will 
return an empty 
      * node set. 
      * 
  -   * @param expCon is passed in by the Xalan extension processor
  -   * @param ni The NodeIterator for the node-set to be evaluated.
  +   * @param nl The NodeList for the node-set to be evaluated.
      * 
      * @return node-set with nodes containing the maximum value found, an 
empty node-set
      * if any node cannot be converted to a number.
      */
  -  public static NodeSet highest (ExpressionContext expCon, NodeIterator ni)
  -    throws java.lang.CloneNotSupportedException
  +  public static NodeList highest (NodeList nl)
     {    
  -    NodeSet ns = new NodeSet(ni);
  -    NodeIterator niClone = ns.cloneWithReset();
  -    double high = new Double(max(expCon, niClone)).doubleValue();
  +    double high = new Double(max(nl)).doubleValue();
       NodeSet highNodes = new NodeSet();
       highNodes.setShouldCacheNodes(true);
       
       if (Double.isNaN(high))
         return highNodes;  // empty Nodeset
       
  -     for (int i = 0; i < ns.getLength(); i++)
  +    for (int i = 0; i < nl.getLength(); i++)
       {
  -      Node n = ns.elementAt(i);
  -      double d = expCon.toNumber(n); 
  +      Node n = nl.item(i);
  +      double d = toNumber(n); 
         if (d == high)
  -      highNodes.addElement(n);
  +        highNodes.addElement(n);
       }
       return highNodes;
     }
  @@ -231,19 +210,15 @@
      * NaN. The definition numeric comparisons entails that NaN != NaN. 
Therefore if any of the nodes 
      * in the node set has a non-numeric value, math:lowest will return an 
empty node set.
      * 
  -   * @param expCon is passed in by the Xalan extension processor
  -   * @param ni The NodeIterator for the node-set to be evaluated.
  +   * @param nl The NodeList for the node-set to be evaluated.
      * 
      * @return node-set with nodes containing the minimum value found, an 
empty node-set
      * if any node cannot be converted to a number.
      * 
      */
  -  public static NodeSet lowest (ExpressionContext expCon, NodeIterator ni)
  -    throws java.lang.CloneNotSupportedException
  +  public static NodeList lowest (NodeList nl)
     {
  -    NodeSet ns = new NodeSet(ni);
  -    NodeIterator niClone = ns.cloneWithReset();
  -    double low = new Double(min(expCon, niClone)).doubleValue();
  +    double low = new Double(min(nl)).doubleValue();
   
       NodeSet lowNodes = new NodeSet();
       lowNodes.setShouldCacheNodes(true);
  @@ -251,13 +226,191 @@
       if (Double.isNaN(low))
         return lowNodes;  // empty Nodeset
       
  -     for (int i = 0; i < ns.getLength(); i++)
  +    for (int i = 0; i < nl.getLength(); i++)
       {
  -      Node n = ns.elementAt(i);
  -      double d = expCon.toNumber(n); 
  +      Node n = nl.item(i);
  +      double d = toNumber(n); 
         if (d == low)
  -      lowNodes.addElement(n);
  +        lowNodes.addElement(n);
       }
       return lowNodes;
  -  }  
  +  }
  +  
  +  /**
  +   *  Return the string value of a Node
  +   */
  +  private static String toString(Node n)
  +  {
  +     if (n instanceof DTMNodeProxy)
  +      return ((DTMNodeProxy)n).getStringValue();
  +     else
  +      return n.getNodeValue();
  +  }
  +  
  +  /**
  +   * Convert the string value of a Node to a number
  +   */
  +  private static double toNumber(Node n)
  +  {
  +     double d = 0.0;
  +     String str = toString(n);
  +     try
  +     {
  +       d = Double.parseDouble(str);
  +     }
  +     catch (NumberFormatException e)
  +     {
  +       d= Double.NaN;                
  +     }
  +     return d;
  +  }
  +
  +  /**
  +   * The math:abs function returns the absolute value of a number. 
  +   */
  +   public static double abs(double num)
  +   {
  +     return Math.abs(num);
  +   }
  +
  +  /**
  +   * The math:acos function returns the arccosine value of a number. 
  +   */
  +   public static double acos(double num)
  +   {
  +     return Math.acos(num);
  +   }
  +
  +  /**
  +   * The math:asin function returns the arcsine value of a number. 
  +   */
  +   public static double asin(double num)
  +   {
  +     return Math.asin(num);
  +   }
  +
  +  /**
  +   * The math:atan function returns the arctangent value of a number. 
  +   */
  +   public static double atan(double num)
  +   {
  +     return Math.atan(num);
  +   }
  +  
  +  /**
  +   * The math:atan2 function returns the angle ( in radians ) from the X 
axis to a point (y,x). 
  +   */
  +   public static double atan2(double num1, double num2)
  +   {
  +     return Math.atan2(num1, num2);
  +   }
  +
  +  /**
  +   * The math:cos function returns cosine of the passed argument. 
  +   */
  +   public static double cos(double num)
  +   {
  +     return Math.cos(num);
  +   }
  +
  +  /**
  +   * The math:exp function returns e (the base of natural logarithms) raised 
to a power. 
  +   */
  +   public static double exp(double num)
  +   {
  +     return Math.exp(num);
  +   }
  +
  +  /**
  +   * The math:log function returns the natural logarithm of a number. 
  +   */
  +   public static double log(double num)
  +   {
  +     return Math.log(num);
  +   }
  +
  +  /**
  +   * The math:power function returns the value of a base expression taken to 
a specified power. 
  +   */
  +   public static double power(double num1, double num2)
  +   {
  +     return Math.pow(num1, num2);
  +   }
  +
  +  /**
  +   * The math:random function returns a random number from 0 to 1. 
  +   */
  +   public static double random()
  +   {
  +     return Math.random();
  +   }
  +
  +  /**
  +   * The math:sin function returns the sine of the number. 
  +   */
  +   public static double sin(double num)
  +   {
  +     return Math.sin(num);
  +   }
  +
  +  /**
  +   * The math:sqrt function returns the square root of a number. 
  +   */
  +   public static double sqrt(double num)
  +   {
  +     return Math.sqrt(num);
  +   }
  +
  +  /**
  +   * The math:tan function returns the tangent of the number passed as an 
argument. 
  +   */
  +   public static double tan(double num)
  +   {
  +     return Math.tan(num);
  +   }
  +
  +  /**
  +   * The math:constant function returns the specified constant to a set 
precision. 
  +   * The possible constants are:
  +   *
  +   * PI
  +   * E
  +   * SQRRT2
  +   * LN2
  +   * LN10
  +   * LOG2E
  +   * SQRT1_2 
  +   */
  +   public static double constant(String name, double precision)
  +   {
  +     String value = null;
  +     if (name.equals("PI"))
  +       value = PI;
  +     else if (name.equals("E"))
  +       value = E;
  +     else if (name.equals("SQRRT2"))
  +       value = SQRRT2;
  +     else if (name.equals("LN2"))
  +       value = LN2;
  +     else if (name.equals("LN10"))
  +       value = LN10;
  +     else if (name.equals("LOG2E"))
  +       value = LOG2E;
  +     else if (name.equals("SQRT1_2"))
  +       value = SQRT1_2;
  +     
  +     if (value != null)
  +     {
  +       int bits = new Double(precision).intValue();
  +       
  +       if (bits <= value.length())
  +         value = value.substring(0, bits);
  +         
  +       return new Double(value).doubleValue();
  +     }
  +     else
  +       return Double.NaN;
  +            
  +   }
  +      
   }
  
  
  
  1.2.2.2   +100 -76   xml-xalan/java/src/org/apache/xalan/lib/ExsltSets.java
  
  Index: ExsltSets.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltSets.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- ExsltSets.java    1 Aug 2002 19:55:30 -0000       1.2.2.1
  +++ ExsltSets.java    12 Sep 2002 16:07:31 -0000      1.2.2.2
  @@ -57,34 +57,15 @@
   package org.apache.xalan.lib;
   
   import org.w3c.dom.Node;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.DocumentFragment;
   import org.w3c.dom.NodeList;
  -import org.w3c.dom.Text;
   import org.w3c.dom.traversal.NodeIterator;
   
   import org.apache.xpath.NodeSet;
  -import org.apache.xpath.objects.XObject;
  -import org.apache.xpath.objects.XBoolean;
  -import org.apache.xpath.objects.XNumber;
  -import org.apache.xpath.objects.XRTreeFrag;
  -
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.XPathContext;
   import org.apache.xpath.DOMHelper;
  -import org.apache.xml.dtm.DTMIterator;
  -import org.apache.xml.dtm.ref.DTMNodeIterator;
  -import org.apache.xml.utils.XMLString;
  -
  -import org.xml.sax.SAXNotSupportedException;
  -
  +import org.apache.xml.dtm.ref.DTMNodeProxy;
   import java.util.Hashtable;
  -import java.util.StringTokenizer;
   
   import org.apache.xalan.extensions.ExpressionContext;
  -import org.apache.xalan.res.XSLMessages;
  -import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.xslt.EnvironmentCheck;
   
   import javax.xml.parsers.*;
   
  @@ -109,29 +90,30 @@
      * the first node in the second node set is not contained in the first 
node set, then an empty
      * node set is returned. If the second node set is empty, then the first 
node set is returned.
      * 
  -   * @param ni1 NodeIterator for first node-set.
  -   * @param ni2 NodeIterator for second node-set.
  -   * @return a node-set containing the nodes in ni1 that precede in document 
order the first
  -   * node in ni2; an empty node-set if the first node in ni2 is not in ni1; 
all of ni1 if n12
  +   * @param nl1 NodeList for first node-set.
  +   * @param nl2 NodeList for second node-set.
  +   * @return a NodeList containing the nodes in nl1 that precede in document 
order the first
  +   * node in nl2; an empty node-set if the first node in nl2 is not in nl1; 
all of nl1 if nl2
      * is empty.
      * 
      * @see <a href="http://www.exslt.org/";>EXSLT</a>
      */
  -  public static NodeSet leading (NodeIterator ni1, NodeIterator ni2)
  +  public static NodeList leading (NodeList nl1, NodeList nl2)
     {
  -    NodeSet ns1 = new NodeSet(ni1);
  -    NodeSet ns2 = new NodeSet(ni2);
  +    if (nl2.getLength() == 0)
  +      return nl1;
  +      
  +    NodeSet ns1 = new NodeSet(nl1);
       NodeSet leadNodes = new NodeSet();
  -    if (ns2.getLength() == 0)
  -      return ns1;
  -    Node endNode = ns2.elementAt(0);
  +    Node endNode = nl2.item(0);
       if (!ns1.contains(endNode))
         return leadNodes; // empty NodeSet
  -    for (int i = 0; i < ns1.getLength(); i++)
  +      
  +    for (int i = 0; i < nl1.getLength(); i++)
       {
  -      Node testNode = ns1.elementAt(i);
  +      Node testNode = nl1.item(i);
         if (DOMHelper.isNodeAfter(testNode, endNode) 
  -          && !(DOMHelper.isNodeTheSame(testNode, endNode)))
  +          && !(testNode == endNode || DOMHelper.isNodeTheSame(testNode, 
endNode)))
           leadNodes.addElement(testNode);
       }
       return leadNodes;
  @@ -143,29 +125,30 @@
      * the first node in the second node set is not contained in the first 
node set, then an empty 
      * node set is returned. If the second node set is empty, then the first 
node set is returned. 
      * 
  -   * @param ni1 NodeIterator for first node-set.
  -   * @param ni2 NodeIterator for second node-set.
  -   * @return a node-set containing the nodes in ni1 that follow in document 
order the first
  -   * node in ni2; an empty node-set if the first node in ni2 is not in ni1; 
all of ni1 if ni2
  +   * @param nl1 NodeList for first node-set.
  +   * @param nl2 NodeList for second node-set.
  +   * @return a NodeList containing the nodes in nl1 that follow in document 
order the first
  +   * node in nl2; an empty node-set if the first node in nl2 is not in nl1; 
all of nl1 if nl2
      * is empty.
      * 
      * @see <a href="http://www.exslt.org/";>EXSLT</a>
      */
  -  public static NodeSet trailing (NodeIterator ni1, NodeIterator ni2)
  +  public static NodeList trailing (NodeList nl1, NodeList nl2)
     {
  -    NodeSet ns1 = new NodeSet(ni1);
  -    NodeSet ns2 = new NodeSet(ni2);
  +    if (nl2.getLength() == 0)
  +      return nl1;
  +      
  +    NodeSet ns1 = new NodeSet(nl1);
       NodeSet trailNodes = new NodeSet();
  -    if (ns2.getLength() == 0)
  -      return ns1;
  -    Node startNode = ns2.elementAt(0);
  +    Node startNode = nl2.item(0);
       if (!ns1.contains(startNode))
         return trailNodes; // empty NodeSet
  -    for (int i = 0; i < ns1.getLength(); i++)
  +      
  +    for (int i = 0; i < nl1.getLength(); i++)
       {
  -      Node testNode = ns1.elementAt(i);
  +      Node testNode = nl1.item(i);
         if (DOMHelper.isNodeAfter(startNode, testNode) 
  -          && !(DOMHelper.isNodeTheSame(startNode, testNode)))
  +          && !(startNode == testNode || DOMHelper.isNodeTheSame(startNode, 
testNode)))
           trailNodes.addElement(testNode);          
       }
       return trailNodes;
  @@ -175,19 +158,30 @@
      * The set:intersection function returns a node set comprising the nodes 
that are within 
      * both the node sets passed as arguments to it.
      * 
  -   * @param ni1 NodeIterator for first node-set.
  -   * @param ni2 NodeIterator for second node-set.
  -   * @return a NodeSet containing the nodes in ni1 that are also
  -   * in ni2.
  -   * 
  -   * Note: Already implemented in the xalan namespace.
  +   * @param nl1 NodeList for first node-set.
  +   * @param nl2 NodeList for second node-set.
  +   * @return a NodeList containing the nodes in nl1 that are also
  +   * in nl2.
      * 
      * @see <a href="http://www.exslt.org/";>EXSLT</a>
      */
  -  public static NodeSet intersection(NodeIterator ni1, NodeIterator ni2)
  -          throws javax.xml.transform.TransformerException
  +  public static NodeList intersection(NodeList nl1, NodeList nl2)
     {
  -    return Extensions.intersection(ni1, ni2);
  +    NodeSet ns1 = new NodeSet(nl1);
  +    NodeSet ns2 = new NodeSet(nl2);
  +    NodeSet inter = new NodeSet();
  +
  +    inter.setShouldCacheNodes(true);
  +
  +    for (int i = 0; i < ns1.getLength(); i++)
  +    {
  +      Node n = ns1.elementAt(i);
  +
  +      if (ns2.contains(n))
  +        inter.addElement(n);
  +    }
  +
  +    return inter;
     }
     
     /**
  @@ -195,19 +189,30 @@
      * are in the node set passed as the first argument that are not in the 
node set passed as the 
      * second argument.
      * 
  -   * @param ni1 NodeIterator for first node-set.
  -   * @param ni2 NodeIterator for second node-set.
  -   * @return a NodeSet containing the nodes in ni1 that are not
  -   * in ni2.
  -   * 
  -   * Note: Already implemented in the xalan namespace.
  +   * @param nl1 NodeList for first node-set.
  +   * @param nl2 NodeList for second node-set.
  +   * @return a NodeList containing the nodes in nl1 that are not in nl2.
      * 
      * @see <a href="http://www.exslt.org/";>EXSLT</a>
      */
  -  public static NodeSet difference(NodeIterator ni1, NodeIterator ni2)
  -          throws javax.xml.transform.TransformerException
  +  public static NodeList difference(NodeList nl1, NodeList nl2)
     {
  -    return Extensions.difference(ni1, ni2);
  +    NodeSet ns1 = new NodeSet(nl1);
  +    NodeSet ns2 = new NodeSet(nl2);
  +
  +    NodeSet diff = new NodeSet();
  +
  +    diff.setShouldCacheNodes(true);
  +
  +    for (int i = 0; i < ns1.getLength(); i++)
  +    {
  +      Node n = ns1.elementAt(i);
  +
  +      if (!ns2.contains(n))
  +        diff.addElement(n);
  +    }
  +
  +    return diff;
     }
     
     /**
  @@ -215,20 +220,39 @@
      * as the first argument. Specifically, it selects a node N if there is no 
node in NS that has 
      * the same string value as N, and that precedes N in document order. 
      * 
  -   * @param myContext Passed in by Xalan extension processor.
  -   * @param ni NodeIterator for node-set.
  -   * @return a NodeSet with nodes from ni containing distinct string values.
  -   * In other words, if more than one node in ni contains the same string 
value,
  +   * @param nl NodeList for the node-set.
  +   * @return a NodeList with nodes from nl containing distinct string values.
  +   * In other words, if more than one node in nl contains the same string 
value,
      * only include the first such node found.
      * 
  -   * Note: Already implemented in the xalan namespace.
  -   * 
      * @see <a href="http://www.exslt.org/";>EXSLT</a>
      */
  -  public static NodeSet distinct(ExpressionContext myContext, NodeIterator 
ni)
  -          throws javax.xml.transform.TransformerException
  +  public static NodeList distinct(NodeList nl)
     {
  -    return Extensions.distinct(myContext, ni);
  +    NodeSet dist = new NodeSet();
  +    dist.setShouldCacheNodes(true);
  +
  +    Hashtable stringTable = new Hashtable();
  +    
  +    for (int i = 0; i < nl.getLength(); i++)
  +    {
  +      Node currNode = nl.item(i);
  +      String key = null;
  +      if (currNode instanceof DTMNodeProxy)
  +        key = ((DTMNodeProxy)currNode).getStringValue();
  +      else
  +        key = currNode.getNodeValue();
  +      
  +      if (key == null)
  +        dist.addElement(currNode);
  +      else if (!stringTable.containsKey(key))
  +      {
  +        stringTable.put(key, currNode);
  +        dist.addElement(currNode);           
  +      }
  +    }
  +
  +    return dist;
     }
     
     /**
  @@ -244,11 +268,11 @@
      * 
      * @see <a href="http://www.exslt.org/";>EXSLT</a>
      */
  -  public static boolean hasSameNode(NodeIterator ni1, NodeIterator ni2)
  +  public static boolean hasSameNode(NodeList nl1, NodeList nl2)
     {
       
  -    NodeSet ns1 = new NodeSet(ni1);
  -    NodeSet ns2 = new NodeSet(ni2);
  +    NodeSet ns1 = new NodeSet(nl1);
  +    NodeSet ns2 = new NodeSet(nl2);
   
       for (int i = 0; i < ns1.getLength(); i++)
       {
  
  
  
  1.17.2.3  +55 -151   xml-xalan/java/src/org/apache/xalan/lib/Extensions.java
  
  Index: Extensions.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/Extensions.java,v
  retrieving revision 1.17.2.2
  retrieving revision 1.17.2.3
  diff -u -r1.17.2.2 -r1.17.2.3
  --- Extensions.java   1 Aug 2002 19:55:30 -0000       1.17.2.2
  +++ Extensions.java   12 Sep 2002 16:07:31 -0000      1.17.2.3
  @@ -67,17 +67,9 @@
   import org.apache.xpath.objects.XObject;
   import org.apache.xpath.objects.XBoolean;
   import org.apache.xpath.objects.XNumber;
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.XPathContext;
  -import org.apache.xpath.DOMHelper;
  -import org.apache.xml.dtm.DTMIterator;
  -import org.apache.xml.dtm.ref.DTMNodeIterator;
  -import org.apache.xml.utils.XMLString;
  -
   import org.xml.sax.SAXNotSupportedException;
   
   import java.util.Hashtable;
  -import java.util.StringTokenizer;
   
   import org.apache.xalan.extensions.ExpressionContext;
   import org.apache.xalan.res.XSLMessages;
  @@ -85,7 +77,7 @@
   // Note: we should consider loading EnvironmentCheck at runtime
   //  to simplify inter-package dependencies Sep-01 -sc
   import org.apache.xalan.xslt.EnvironmentCheck;
  -
  +import javax.xml.transform.TransformerException;
   import javax.xml.parsers.*;
   
   /**
  @@ -180,118 +172,64 @@
     /**
      * Returns the intersection of two node-sets.
      * 
  -   * @param ni1 NodeIterator for first node-set
  -   * @param ni2 NodeIterator for second node-set
  -   * @return a NodeSet containing the nodes in ni1 that are also
  -   * in ni2
  +   * @param nl1 NodeList for first node-set
  +   * @param nl2 NodeList for second node-set
  +   * @return a NodeList containing the nodes in nl1 that are also in nl2
      *
  -   * @throws javax.xml.transform.TransformerException
  +   * Note: The usage of this extension function in the xalan namespace 
  +   * is deprecated. Please use the same function in the EXSLT sets extension
  +   * (http://exslt.org/sets).
      */
  -  public static NodeSet intersection(NodeIterator ni1, NodeIterator ni2)
  -          throws javax.xml.transform.TransformerException
  +  public static NodeList intersection(NodeList nl1, NodeList nl2)
     {
  -
  -    NodeSet ns1 = new NodeSet(ni1);
  -    NodeSet ns2 = new NodeSet(ni2);
  -    NodeSet inter = new NodeSet();
  -
  -    inter.setShouldCacheNodes(true);
  -
  -    for (int i = 0; i < ns1.getLength(); i++)
  -    {
  -      Node n = ns1.elementAt(i);
  -
  -      if (ns2.contains(n))
  -        inter.addElement(n);
  -    }
  -
  -    return inter;
  +    return ExsltSets.intersection(nl1, nl2);
     }
   
     /**
      * Returns the difference between two node-sets.
      * 
  -   * @param ni1 NodeIterator for first node-set
  -   * @param ni2 NodeIterator for second node-set
  -   * @return a NodeSet containing the nodes in ni1 that are not
  -   * in ni2
  -   *
  -   * @throws javax.xml.transform.TransformerException
  +   * @param nl1 NodeList for first node-set
  +   * @param nl2 NodeList for second node-set
  +   * @return a NodeList containing the nodes in nl1 that are not in nl2
  +   * 
  +   * Note: The usage of this extension function in the xalan namespace 
  +   * is deprecated. Please use the same function in the EXSLT sets extension
  +   * (http://exslt.org/sets).
      */
  -  public static NodeSet difference(NodeIterator ni1, NodeIterator ni2)
  -          throws javax.xml.transform.TransformerException
  +  public static NodeList difference(NodeList nl1, NodeList nl2)
     {
  -
  -    NodeSet ns1 = new NodeSet(ni1);
  -    NodeSet ns2 = new NodeSet(ni2);
  -
  -    // NodeSet inter= new NodeSet();
  -    NodeSet diff = new NodeSet();
  -
  -    diff.setShouldCacheNodes(true);
  -
  -    for (int i = 0; i < ns1.getLength(); i++)
  -    {
  -      Node n = ns1.elementAt(i);
  -
  -      if (!ns2.contains(n))
  -        diff.addElement(n);
  -    }
  -
  -    return diff;
  +    return ExsltSets.difference(nl1, nl2);
     }
   
     /**
      * Returns node-set containing distinct string values.
  -   * @param ni NodeIterator for node-set
  -   * @return a NodeSet with nodes from ni containing distinct string values.
  -   * In other words, if more than one node in ni contains the same string 
value,
  +   *
  +   * @param nl NodeList for node-set
  +   * @return a NodeList with nodes from nl containing distinct string values.
  +   * In other words, if more than one node in nl contains the same string 
value,
      * only include the first such node found.
      *
  -   * @throws javax.xml.transform.TransformerException
  +   * Note: The usage of this extension function in the xalan namespace 
  +   * is deprecated. Please use the same function in the EXSLT sets extension
  +   * (http://exslt.org/sets).
      */
  -  public static NodeSet distinct(ExpressionContext myContext, NodeIterator 
ni)
  -          throws javax.xml.transform.TransformerException
  +  public static NodeList distinct(NodeList nl)
     {
  -
  -    // Set up our resulting NodeSet and the hashtable we use to keep track 
of duplicate
  -    // strings.
  -
  -    NodeSet dist = new NodeSet();
  -    dist.setShouldCacheNodes(true);
  -
  -    Hashtable stringTable = new Hashtable();
  -
  -    Node currNode = ni.nextNode();
  -
  -    while (currNode != null)
  -    {
  -      String key = myContext.toString(currNode);
  -
  -      if (!stringTable.containsKey(key))
  -      {
  -        stringTable.put(key, currNode);
  -        dist.addElement(currNode);
  -      }
  -      currNode = ni.nextNode();
  -    }
  -
  -    return dist;
  +    return ExsltSets.distinct(nl);
     }
   
     /**
      * Returns true if both node-sets contain the same set of nodes.
  -   * @param n1 NodeIterator for first node-set
      *
  -   * NEEDSDOC @param ni1
  -   * @param ni2 NodeIterator for second node-set
  -   * @return true if ni1 and ni2 contain exactly the same set of nodes.
  +   * @param nl1 NodeList for first node-set
  +   * @param nl2 NodeList for second node-set
  +   * @return true if nl1 and nl2 contain exactly the same set of nodes.
      */
  -  public static boolean hasSameNodes(NodeIterator ni1, NodeIterator ni2)
  +  public static boolean hasSameNodes(NodeList nl1, NodeList nl2)
     {
   
  -    NodeSet ns1 = new NodeSet(ni1);
  -    NodeSet ns2 = new NodeSet(ni2);
  +    NodeSet ns1 = new NodeSet(nl1);
  +    NodeSet ns2 = new NodeSet(nl2);
   
       if (ns1.getLength() != ns2.getLength())
         return false;
  @@ -312,41 +250,22 @@
      * an XPath expression.  Used where the XPath expression is not known until
      * run-time.  The expression is evaluated as if the run-time value of the
      * argument appeared in place of the evaluate function call at compile 
time.
  +   *
      * @param myContext an <code>ExpressionContext</code> passed in by the
      *                  extension mechanism.  This must be an XPathContext.
      * @param xpathExtr The XPath expression to be evaluated.
  -   * NEEDSDOC @param xpathExpr
      * @return the XObject resulting from evaluating the XPath
      *
  -   * @throws Exception
      * @throws SAXNotSupportedException
  +   *
  +   * Note: The usage of this extension function in the xalan namespace 
  +   * is deprecated. Please use the same function in the EXSLT dynamic 
extension
  +   * (http://exslt.org/dynamic).
      */
  -  public static XObject evaluate(
  -          ExpressionContext myContext, String xpathExpr)
  -            throws SAXNotSupportedException, Exception
  +  public static XObject evaluate(ExpressionContext myContext, String 
xpathExpr)
  +         throws SAXNotSupportedException
     {
  -
  -    if (myContext instanceof XPathContext.XPathExpressionContext)
  -    {
  -      try
  -      {
  -        XPathContext xctxt =
  -                    ((XPathContext.XPathExpressionContext) 
myContext).getXPathContext();
  -        XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(),
  -                                       xctxt.getNamespaceContext(),
  -                                       XPath.SELECT);
  -
  -        return dynamicXPath.execute(xctxt, myContext.getContextNode(),
  -                                    xctxt.getNamespaceContext());
  -      }
  -      catch (Exception e)
  -      {
  -        throw e;
  -      }
  -    }
  -    else
  -      throw new 
SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED,
 new Object[]{myContext })); //"Invalid context passed to evaluate "
  -                                         //+ myContext);
  +    return ExsltDynamic.evaluate(myContext, xpathExpr);
     }
   
     /**
  @@ -355,41 +274,22 @@
      * Tokens are determined by a call to <code>StringTokenizer</code>.
      * If the first argument is an empty string or contains only delimiters, 
the result
      * will be an empty NodeSet.
  +   *
      * Contributed to XalanJ1 by <a href="mailto:[EMAIL PROTECTED]">Benoit 
Cerrina</a>.
  +   * 
      * @param myContext an <code>ExpressionContext</code> passed in by the
      *                  extension mechanism.  This must be an XPathContext.
      * @param toTokenize The string to be split into text tokens.
      * @param delims The delimiters to use.
      * @return a NodeSet as described above.
      *
  +   * Note: The usage of this extension function in the xalan namespace 
  +   * is deprecated. Please use the same function in the EXSLT strings 
extension
  +   * (http://exslt.org/strings).
      */
  -  public static NodeSet tokenize(ExpressionContext myContext,
  -                                 String toTokenize, String delims)
  +  public static NodeList tokenize(String toTokenize, String delims)
     {
  -
  -    Document lDoc;
  -
  -    // Document lDoc = myContext.getContextNode().getOwnerDocument();
  -    try
  -    {
  -      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  -      DocumentBuilder db = dbf.newDocumentBuilder();
  -      lDoc = db.newDocument();
  -    }
  -    catch(ParserConfigurationException pce)
  -    {
  -      throw new org.apache.xml.utils.WrappedRuntimeException(pce);
  -    }
  -
  -    StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
  -    NodeSet resultSet = new NodeSet();
  -
  -    while (lTokenizer.hasMoreTokens())
  -    {
  -      resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
  -    }
  -
  -    return resultSet;
  +    return ExsltStrings.tokenize(toTokenize, delims);
     }
   
     /**
  @@ -399,17 +299,21 @@
      * Tokens are determined by a call to <code>StringTokenizer</code>.
      * If the first argument is an empty string or contains only delimiters, 
the result
      * will be an empty NodeSet.
  +   *
      * Contributed to XalanJ1 by <a href="mailto:[EMAIL PROTECTED]">Benoit 
Cerrina</a>.
  +   * 
      * @param myContext an <code>ExpressionContext</code> passed in by the
      *                  extension mechanism.  This must be an XPathContext.
      * @param toTokenize The string to be split into text tokens.
      * @return a NodeSet as described above.
      *
  +   * Note: The usage of this extension function in the xalan namespace 
  +   * is deprecated. Please use the same function in the EXSLT strings 
extension
  +   * (http://exslt.org/strings).
      */
  -  public static NodeSet tokenize(ExpressionContext myContext,
  -                                 String toTokenize)
  +  public static NodeList tokenize(String toTokenize)
     {
  -    return tokenize(myContext, toTokenize, " \t\n\r");
  +    return tokenize(toTokenize, " \t\n\r");
     }
   
     /**
  
  
  
  1.1.10.1  +8 -2      xml-xalan/java/src/org/apache/xalan/lib/PipeDocument.java
  
  Index: PipeDocument.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/PipeDocument.java,v
  retrieving revision 1.1
  retrieving revision 1.1.10.1
  diff -u -r1.1 -r1.1.10.1
  --- PipeDocument.java 3 Aug 2001 19:12:52 -0000       1.1
  +++ PipeDocument.java 12 Sep 2002 16:07:31 -0000      1.1.10.1
  @@ -112,9 +112,15 @@
   import java.util.Properties;
   
   /**
  - * Sets stylesheet params and pipes an XML document through a series of 1 or 
more stylesheets.
  + * PipeDocument is a Xalan extension element to set stylesheet params and 
pipes an XML 
  + * document through a series of 1 or more stylesheets.
    * PipeDocument is invoked from a stylesheet as the [EMAIL PROTECTED] 
#pipeDocument pipeDocument extension element}.
    * 
  + * It is accessed by specifying a namespace URI as follows:
  + * <pre>
  + *    xmlns:pipe="http://xml.apache.org/xalan/PipeDocument";
  + * </pre>
  + *
    * @author Donald Leslie
    */
   public class PipeDocument
  @@ -130,7 +136,7 @@
    * Syntax:
    * &lt;xsl:stylesheet version="1.0"
    *                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  - *                xmlns:pipe="xalan://PipeDocument"
  + *                xmlns:pipe="http://xml.apache.org/xalan/PipeDocument";
    *                extension-element-prefixes="pipe"&gt;
    * ...
    * &lt;pipe:pipeDocument   source="source.xml" target="target.xml"&gt;
  
  
  
  1.16.10.1 +5 -5      xml-xalan/java/src/org/apache/xalan/lib/Redirect.java
  
  Index: Redirect.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/Redirect.java,v
  retrieving revision 1.16
  retrieving revision 1.16.10.1
  diff -u -r1.16 -r1.16.10.1
  --- Redirect.java     29 Nov 2001 19:26:11 -0000      1.16
  +++ Redirect.java     12 Sep 2002 16:07:31 -0000      1.16.10.1
  @@ -81,9 +81,10 @@
    * Implements three extension elements to allow an XSLT transformation to
    * redirect its output to multiple output files.
    *
  - * <p>You must declare the Xalan namespace 
(xmlns:lxslt="http://xml.apache.org/xslt";),
  - * a namespace for the extension prefix (such as 
xmlns:redirect="org.apache.xalan.lib.Redirect"),
  - * and declare the extension namespace as an extension 
(extension-element-prefixes="redirect").
  + * It is accessed by specifying a namespace URI as follows:
  + * <pre>
  + *    xmlns:redirect="http://xml.apache.org/xalan/redirect";
  + * </pre>
    *
    * <p>You can either just use redirect:write, in which case the file will be
    * opened and immediately closed after the write, or you can bracket the
  @@ -116,8 +117,7 @@
    * <PRE>
    * &lt;?xml version="1.0"?>
    * &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0";
  - *                 xmlns:lxslt="http://xml.apache.org/xslt";
  - *                 xmlns:redirect="org.apache.xalan.lib.Redirect"
  + *                 xmlns:redirect="http://xml.apache.org/xalan/redirect";
    *                 extension-element-prefixes="redirect">
    *
    *   &lt;xsl:template match="/">
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.9.10.2  +18 -1     
xml-xalan/java/src/org/apache/xalan/lib/sql/DefaultConnectionPool.java
  
  Index: DefaultConnectionPool.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/DefaultConnectionPool.java,v
  retrieving revision 1.9.10.1
  retrieving revision 1.9.10.2
  diff -u -r1.9.10.1 -r1.9.10.2
  --- DefaultConnectionPool.java        29 Jul 2002 00:01:17 -0000      1.9.10.1
  +++ DefaultConnectionPool.java        12 Sep 2002 16:07:32 -0000      1.9.10.2
  @@ -59,6 +59,7 @@
   import java.sql.Connection;
   import java.sql.DatabaseMetaData;
   import java.sql.DriverManager;
  +import java.sql.Driver;
   import java.sql.SQLException;
   import java.util.Enumeration;
   import java.util.Properties;
  @@ -74,6 +75,11 @@
   public class DefaultConnectionPool implements ConnectionPool
   {
     /**
  +   * A placeholder thast will keep the driver loaded
  +   * between calls.
  +   */
  +  private Object m_Driver = null;
  +  /**
      */
     private static final boolean DEBUG = false;
   
  @@ -470,12 +476,23 @@
   
        try
        {
  -       Class.forName( m_driver );
  +// We need to implement the context classloader
  +//       Class.forName( m_driver );
  +        Class cls = 
Thread.currentThread().getContextClassLoader().loadClass(m_driver);
  +        // We have also had problems with drivers unloading
  +        // load an instance that will get freed with the class.
  +        m_Driver = cls.newInstance();
  +
  +
        }
        catch(ClassNotFoundException e)
        {
          throw new 
IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_DRIVER_NAME,
 null));
          // "Invalid Driver Name Specified!");
  +     }
  +     catch(Exception e)
  +     {
  +       throw new 
IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_DRIVER_NAME,
 null));
        }
   
        // IF we are not active, don't actuall build a pool yet
  
  
  
  1.19.10.1 +2 -2      
xml-xalan/java/src/org/apache/xalan/lib/sql/SQLDocument.java
  
  Index: SQLDocument.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/SQLDocument.java,v
  retrieving revision 1.19
  retrieving revision 1.19.10.1
  diff -u -r1.19 -r1.19.10.1
  --- SQLDocument.java  17 Jan 2002 19:29:38 -0000      1.19
  +++ SQLDocument.java  12 Sep 2002 16:07:32 -0000      1.19.10.1
  @@ -678,9 +678,9 @@
           // In Streaming mode, the current ROW will always point back
           // to itself until all the data was read. Once the Query is
           // empty then point the next row to DTM.NULL so that the stream
  -        // ends.
  +        // ends. Only do this if we have statted the loop to begin with.
   
  -        if (m_StreamingMode)
  +        if (m_StreamingMode && (m_LastRowIdx != DTM.NULL))
           {
             // We are at the end, so let's untie the mark
             m_nextsib.setElementAt(DTM.NULL, m_LastRowIdx);
  
  
  
  1.23.10.1 +8 -1      
xml-xalan/java/src/org/apache/xalan/lib/sql/XConnection.java
  
  Index: XConnection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/XConnection.java,v
  retrieving revision 1.23
  retrieving revision 1.23.10.1
  diff -u -r1.23 -r1.23.10.1
  --- XConnection.java  17 Jan 2002 19:12:43 -0000      1.23
  +++ XConnection.java  12 Sep 2002 16:07:32 -0000      1.23.10.1
  @@ -90,7 +90,14 @@
   
   /**
    * An XSLT extension that allows a stylesheet to
  - * access JDBC data. From the stylesheet perspective,
  + * access JDBC data. 
  + *
  + * It is accessed by specifying a namespace URI as follows:
  + * <pre>
  + *    xmlns:sql="http://xml.apache.org/xalan/sql";
  + * </pre>
  + *
  + * From the stylesheet perspective,
    * XConnection provides 3 extension functions: new(),
    * query(), and close().
    * Use new() to call one of XConnection constructors, which
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.38.2.1  +2 -2      
xml-xalan/java/src/org/apache/xalan/processor/XSLProcessorVersion.java
  
  Index: XSLProcessorVersion.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/XSLProcessorVersion.java,v
  retrieving revision 1.38
  retrieving revision 1.38.2.1
  diff -u -r1.38 -r1.38.2.1
  --- XSLProcessorVersion.java  24 Mar 2002 14:57:10 -0000      1.38
  +++ XSLProcessorVersion.java  12 Sep 2002 16:07:32 -0000      1.38.2.1
  @@ -118,7 +118,7 @@
      *          When missing, it designates the final and complete
      *          development drop for a release.
      */
  -  public static int MAINTENANCE = 1;
  +  public static int MAINTENANCE = 0;
   
     /**
      * Development Drop Number.
  @@ -137,7 +137,7 @@
      *          well as defect fixes. 'D' drops may not be as stable as
      *          the final releases.
      */
  -  public static int DEVELOPMENT = 1;
  +  public static int DEVELOPMENT = 0;
     
     /**
      * Version String like <CODE>"<B>Xalan</B> <B>Language</B> 
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.29.4.2  +1 -1      
xml-xalan/java/src/org/apache/xalan/res/XSLTInfo.properties
  
  Index: XSLTInfo.properties
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/res/XSLTInfo.properties,v
  retrieving revision 1.29.4.1
  retrieving revision 1.29.4.2
  diff -u -r1.29.4.1 -r1.29.4.2
  --- XSLTInfo.properties       29 Jul 2002 00:01:18 -0000      1.29.4.1
  +++ XSLTInfo.properties       12 Sep 2002 16:07:32 -0000      1.29.4.2
  @@ -2,7 +2,7 @@
   #  XSLT Resource File
   #
   
  -version=2.4.D1
  +version=2.4.0
   vendor=Apache Software Foundation
   vendor-url=http://xml.apache.org/xalan-j
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.12.16.2 +11 -3     
xml-xalan/java/src/org/apache/xalan/templates/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/Constants.java,v
  retrieving revision 1.12.16.1
  retrieving revision 1.12.16.2
  diff -u -r1.12.16.1 -r1.12.16.2
  --- Constants.java    29 Jul 2002 00:01:19 -0000      1.12.16.1
  +++ Constants.java    12 Sep 2002 16:07:32 -0000      1.12.16.2
  @@ -113,9 +113,15 @@
      * Xalan extension namespaces.
      */
     public static final String 
  -    S_EXTENSIONS_JAVA_URL = "http://xml.apache.org/xslt/java";,
  +    // The old namespace for Java extension
  +    S_EXTENSIONS_OLD_JAVA_URL = "http://xml.apache.org/xslt/java";,
  +    // The new namespace for Java extension
  +    S_EXTENSIONS_JAVA_URL = "http://xml.apache.org/xalan/java";,
       S_EXTENSIONS_LOTUSXSL_JAVA_URL = "http://xsl.lotus.com/java";,
  -    S_EXTENSIONS_XALANLIB_URL = "http://xml.apache.org/xalan";;   
  +    S_EXTENSIONS_XALANLIB_URL = "http://xml.apache.org/xalan";,
  +    S_EXTENSIONS_REDIRECT_URL = "http://xml.apache.org/xalan/redirect";,
  +    S_EXTENSIONS_PIPE_URL = "http://xml.apache.org/xalan/PipeDocument";,
  +    S_EXTENSIONS_SQL_URL = "http://xml.apache.org/xalan/sql";;
     
     /**
      * EXSLT extension namespaces.
  @@ -125,7 +131,9 @@
       S_EXSLT_MATH_URL = "http://exslt.org/math";,
       S_EXSLT_SETS_URL = "http://exslt.org/sets";,
       S_EXSLT_DATETIME_URL = "http://exslt.org/dates-and-times";,
  -    S_EXSLT_FUNCTIONS_URL = "http://exslt.org/functions";;
  +    S_EXSLT_FUNCTIONS_URL = "http://exslt.org/functions";,
  +    S_EXSLT_DYNAMIC_URL = "http://exslt.org/dynamic";,
  +    S_EXSLT_STRINGS_URL = "http://exslt.org/strings";;
       
       
     /**
  
  
  
  1.27.2.2  +1 -1      
xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionCall.java
  
  Index: ElemExtensionCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemExtensionCall.java,v
  retrieving revision 1.27.2.1
  retrieving revision 1.27.2.2
  diff -u -r1.27.2.1 -r1.27.2.2
  --- ElemExtensionCall.java    29 Jul 2002 00:01:19 -0000      1.27.2.1
  +++ ElemExtensionCall.java    12 Sep 2002 16:07:32 -0000      1.27.2.2
  @@ -189,7 +189,7 @@
         }
       }
   
  -    return decl;
  +    return null;
     }
     
     /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.18.10.1 +4 -1      
xml-xalan/java/src/org/apache/xalan/transformer/TransformerIdentityImpl.java
  
  Index: TransformerIdentityImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerIdentityImpl.java,v
  retrieving revision 1.18
  retrieving revision 1.18.10.1
  diff -u -r1.18 -r1.18.10.1
  --- TransformerIdentityImpl.java      9 Aug 2001 18:32:55 -0000       1.18
  +++ TransformerIdentityImpl.java      12 Sep 2002 16:07:32 -0000      
1.18.10.1
  @@ -744,7 +744,10 @@
     public void setErrorListener(ErrorListener listener)
             throws IllegalArgumentException
     {
  -    m_errorListener = listener;
  +      if (listener == null)
  +        throw new 
IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_NULL_ERROR_HANDLER,
 null));
  +      else
  +        m_errorListener = listener;
     }
   
     /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.6.2  +15 -7     
xml-xalan/java/src/org/apache/xalan/xslt/EnvironmentCheck.java
  
  Index: EnvironmentCheck.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/EnvironmentCheck.java,v
  retrieving revision 1.10.6.1
  retrieving revision 1.10.6.2
  diff -u -r1.10.6.1 -r1.10.6.2
  --- EnvironmentCheck.java     29 Jul 2002 00:01:21 -0000      1.10.6.1
  +++ EnvironmentCheck.java     12 Sep 2002 16:07:33 -0000      1.10.6.2
  @@ -1265,6 +1265,10 @@
       jarVersions.put(new Long(923866), "xalan.jar from xalan-j_2_2_0");
       jarVersions.put(new Long(905872), "xalan.jar from xalan-j_2_3_D1");
       jarVersions.put(new Long(906122), "xalan.jar from xalan-j_2_3_0");
  +    jarVersions.put(new Long(906248), "xalan.jar from xalan-j_2_3_1");
  +    jarVersions.put(new Long(997276), "xalan.jar from xalan-j_2_4_0");
  +
  +
       // Impossible to get exact number, so don't use this: 
jarVersions.put(new Long(), "xalan.jar from xalan-j_2_4_D1");
   
       jarVersions.put(new Long(857171), "xalan.jar from lotusxsl-j_1_0_1");
  @@ -1274,11 +1278,14 @@
       jarVersions.put(new Long(596540), "xsltc.jar from xalan-j_2_2_0");
       jarVersions.put(new Long(590247), "xsltc.jar from xalan-j_2_3_D1");
       jarVersions.put(new Long(589914), "xsltc.jar from xalan-j_2_3_0");
  -    jarVersions.put(new Long(1306667), "xsltc.jar from xalan-j_2_4_D1");
  +    jarVersions.put(new Long(589915), "xsltc.jar from xalan-j_2_3_1");
  +    jarVersions.put(new Long(1328227), "xsltc.jar from xalan-j_2_4_0");
       jarVersions.put(new Long(1268634), "xsltc.jar-bundled from 
xalan-j_2_3_0");
   
       jarVersions.put(new Long(100196), "xml-apis.jar from xalan-j_2_2_0 or 
xalan-j_2_3_D1");
  -    jarVersions.put(new Long(108484), "xml-apis.jar from 
xalan-j_2_3_0,2_4_D1 from xml-commons-1.0.b2");
  +    jarVersions.put(new Long(108484), "xml-apis.jar from xalan-j_2_3_0, or 
xalan-j_2_3_1 from xml-commons-1.0.b2");
  +    jarVersions.put(new Long(109049), "xml-apis.jar from xalan-j_2_4_0 from 
xml-commons RIVERCOURT1 branch");
  +    
   
       // If the below were more common I would update it to report 
       //  errors better; but this is so old hardly anyone has it
  @@ -1301,14 +1308,15 @@
       jarVersions.put(new Long(1803877), "xerces.jar from XML4J-3_2_1");
       jarVersions.put(new Long(1812019), "xerces.jar from xalan-j_2_2_0");
       jarVersions.put(new Long(1720292), "xercesImpl.jar from xalan-j_2_3_D1");
  -    jarVersions.put(new Long(1730053), "xercesImpl.jar from xalan-j_2_3_0 
from xerces-2_0_0");
  -    jarVersions.put(new Long(1728861), "xercesImpl.jar from xalan-j_2_4_D1 
from xerces-2_0_1");
  +    jarVersions.put(new Long(1730053), "xercesImpl.jar from xalan-j_2_3_0 or 
xalan-j_2_3_1 from xerces-2_0_0");
  +    jarVersions.put(new Long(972027), "xercesImpl.jar from xalan-j_2_4_0 
from xerces-2_1");
   
       jarVersions.put(new Long(37485), "xalanj1compat.jar from xalan-j_2_0_0");
       jarVersions.put(new Long(38100), "xalanj1compat.jar from xalan-j_2_0_1");
   
       jarVersions.put(new Long(18779), "xalanservlet.jar from xalan-j_2_0_0");
       jarVersions.put(new Long(21453), "xalanservlet.jar from xalan-j_2_0_1");
  +    jarVersions.put(new Long(24826), "xalanservlet.jar from xalan-j_2_3_1 or 
xalan-j_2_4_0");
   
       // For those who've downloaded JAXP from sun
       jarVersions.put(new Long(5618), "jaxp.jar from jaxp1.0.1");
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.8.10.2  +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Compile.java
  
  Index: Compile.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Compile.java,v
  retrieving revision 1.8.10.1
  retrieving revision 1.8.10.2
  diff -u -r1.8.10.1 -r1.8.10.2
  --- Compile.java      29 Jul 2002 00:01:21 -0000      1.8.10.1
  +++ Compile.java      12 Sep 2002 16:07:33 -0000      1.8.10.2
  @@ -82,7 +82,7 @@
   
       // Versioning numbers  for the compiler -v option output
       private static int VERSION_MAJOR = 1;
  -    private static int VERSION_MINOR = 1;
  +    private static int VERSION_MINOR = 2;
       private static int VERSION_DELTA = 0;
    
   
  
  
  
  1.15.10.4 +32 -5     
xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Transform.java
  
  Index: Transform.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/Transform.java,v
  retrieving revision 1.15.10.3
  retrieving revision 1.15.10.4
  diff -u -r1.15.10.3 -r1.15.10.4
  --- Transform.java    24 Aug 2002 11:33:16 -0000      1.15.10.3
  +++ Transform.java    12 Sep 2002 16:07:33 -0000      1.15.10.4
  @@ -120,7 +120,10 @@
        _uri = uri;
        _debug = debug;
        _iterations = iterations;
  -    }
  +  }
  +  
  +   public String getFileName(){return _fileName;}
  +   public String getClassName(){return _className;}
   
       public void setParameters(Vector params) {
        _params = params;
  @@ -209,8 +212,13 @@
                mm = System.currentTimeMillis() - mm;
   
                System.err.println("\n<!--");
  -             System.err.println("  transform  = " + (mm / _iterations) + " 
ms");
  -             System.err.println("  throughput = " + (1000.0 / (mm / 
_iterations)) + " tps");
  +             System.err.println("  transform  = "
  +                                   + (((double) mm) / ((double) _iterations))
  +                                   + " ms");
  +             System.err.println("  throughput = "
  +                                   + (1000.0 / (((double) mm)
  +                                                 / ((double) _iterations)))
  +                                   + " tps");
                System.err.println("-->");
            }
        }
  @@ -288,7 +296,9 @@
                boolean uri = false, debug = false;
                boolean isJarFileSpecified = false;
                String  jarFile = null;
  -
  +             boolean doDiag = false;
  +             long start=0;
  +             long stop=0;
                // Parse options starting with '-'
                for (i = 0; i < args.length && args[i].charAt(0) == '-'; i++) {
                    if (args[i].equals("-u")) {
  @@ -315,6 +325,9 @@
                            // ignore
                        }
                    }
  +                 else if ("-DIAG".equalsIgnoreCase(args[i])){
  +                     doDiag = true;
  +                 }
                    else {
                        printUsage();
                    }
  @@ -344,7 +357,21 @@
   
                if (i == args.length) {
                    handler.setParameters(params);
  +                 if (doDiag) {
  +                     start = System.currentTimeMillis();
  +                 }
                    handler.doTransform();
  +                 if (doDiag) {
  +                     stop = System.currentTimeMillis();
  +                     long millisecondsDuration = stop - start;
  +                     String msg = "--------- Transform of "
  +                                   + handler.getFileName() + " via "
  +                                   + handler.getClassName() + " took "
  +                                   + millisecondsDuration + " ms"; 
  +                     java.io.PrintWriter diagnosticsWriter =
  +                                              new PrintWriter(System.err, 
true);
  +                     diagnosticsWriter.println(msg);
  +                 }
                    if (_allowExit) System.exit(0);
                }
            } else {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.19.2.4  +3 -17     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
  retrieving revision 1.19.2.3
  retrieving revision 1.19.2.4
  diff -u -r1.19.2.3 -r1.19.2.4
  --- Constants.java    24 Aug 2002 11:33:23 -0000      1.19.2.3
  +++ Constants.java    12 Sep 2002 16:07:33 -0000      1.19.2.4
  @@ -322,6 +322,8 @@
        = "iterator";
       public static final String DOCUMENT_PNAME     
        = "document";
  +    public static final String TRANSLET_PNAME     
  +     = "translet";
   
       public static final String GET_NODE_NAME      
        = "getNodeNameX";
  @@ -456,22 +458,6 @@
        = "(" + STRING_SIG + ")" + OBJECT_SIG;
       public static final String ADD_PARAMETER_SIG
        = "(" + STRING_SIG + OBJECT_SIG + "Z)" + OBJECT_SIG;
  -    public static final String PUSH_VAR_FRAME
  -     = "pushVarFrame";
  -    public static final String PUSH_VAR_FRAME_SIG
  -     = "(I)V";
  -    public static final String POP_VAR_FRAME
  -     = "popVarFrame";
  -    public static final String POP_VAR_FRAME_SIG
  -     = "()V";
  -    public static final String ADD_VARIABLE
  -     = "addVariable";
  -    public static final String ADD_VARIABLE_SIG
  -     = "(I" + OBJECT_SIG + ")V";
  -    public static final String GET_VARIABLE
  -     = "getVariable";
  -    public static final String GET_VARIABLE_SIG
  -     = "(I)" + OBJECT_SIG;
   
       public static final String STRIP_SPACE
        = "stripSpace";
  
  
  
  1.8.6.2   +1 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/EqualityExpr.java
  
  Index: EqualityExpr.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/EqualityExpr.java,v
  retrieving revision 1.8.6.1
  retrieving revision 1.8.6.2
  diff -u -r1.8.6.1 -r1.8.6.2
  --- EqualityExpr.java 29 Jul 2002 00:01:22 -0000      1.8.6.1
  +++ EqualityExpr.java 12 Sep 2002 16:07:33 -0000      1.8.6.2
  @@ -360,7 +360,6 @@
   
        // Call the appropriate compare() from the BasisLibrary
        il.append(new PUSH(cpg, _op));
  -     il.append(methodGen.loadContextNode());
        il.append(methodGen.loadDOM());
   
        final int compare = cpg.addMethodref(BASIS_LIBRARY_CLASS,
  @@ -369,7 +368,6 @@
                                             + tleft.toSignature() 
                                             + tright.toSignature()
                                             + "I"
  -                                          + NODE_SIG
                                             + DOM_INTF_SIG
                                             + ")Z");
        il.append(new INVOKESTATIC(compare));
  
  
  
  1.8.6.2   +104 -33   
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Number.java
  
  Index: Number.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Number.java,v
  retrieving revision 1.8.6.1
  retrieving revision 1.8.6.2
  diff -u -r1.8.6.1 -r1.8.6.2
  --- Number.java       29 Jul 2002 00:01:22 -0000      1.8.6.1
  +++ Number.java       12 Sep 2002 16:07:33 -0000      1.8.6.2
  @@ -63,6 +63,8 @@
   
   package org.apache.xalan.xsltc.compiler;
   
  +import java.util.ArrayList;
  +
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.ReferenceType;
   import org.apache.bcel.classfile.JavaClass;
  @@ -71,11 +73,23 @@
   
   import org.apache.xalan.xsltc.compiler.util.*;
   
  -final class Number extends Instruction {
  +final class Number extends Instruction implements Closure {
       private static final int LEVEL_SINGLE   = 0;
       private static final int LEVEL_MULTIPLE = 1;
       private static final int LEVEL_ANY      = 2;
   
  +    static final private String[] ClassNames = { 
  +     "org.apache.xalan.xsltc.dom.SingleNodeCounter",   // LEVEL_SINGLE
  +     "org.apache.xalan.xsltc.dom.MultipleNodeCounter", // LEVEL_MULTIPLE
  +     "org.apache.xalan.xsltc.dom.AnyNodeCounter"       // LEVEL_ANY
  +    };
  +
  +    static final private String[] FieldNames = { 
  +     "___single_node_counter",                  // LEVEL_SINGLE
  +     "___multiple_node_counter",                // LEVEL_MULTIPLE
  +     "___any_node_counter"                      // LEVEL_ANY
  +    };
  +
       private Pattern _from = null;
       private Pattern _count = null;
       private Expression _value = null;
  @@ -89,19 +103,51 @@
       private int _level = LEVEL_SINGLE;
       private boolean _formatNeeded = false;
   
  -    static final private String[] ClassNames = { 
  -     "org.apache.xalan.xsltc.dom.SingleNodeCounter",   // LEVEL_SINGLE
  -     "org.apache.xalan.xsltc.dom.MultipleNodeCounter", // LEVEL_MULTIPLE
  -     "org.apache.xalan.xsltc.dom.AnyNodeCounter"       // LEVEL_ANY
  -    };
  +    private String _className = null;
  +    private ArrayList _closureVars = null;
   
  -    static final private String[] FieldNames = { 
  -     "___single_node_counter",                  // LEVEL_SINGLE
  -     "___multiple_node_counter",                // LEVEL_MULTIPLE
  -     "___any_node_counter"                      // LEVEL_ANY
  -    };
  +     // -- Begin Closure interface --------------------
  +
  +    /**
  +     * Returns true if this closure is compiled in an inner class (i.e.
  +     * if this is a real closure).
  +     */
  +    public boolean inInnerClass() {
  +     return (_className != null);
  +    }
   
  -    public void parseContents(Parser parser) {
  +    /**
  +     * Returns a reference to its parent closure or null if outermost.
  +     */
  +    public Closure getParentClosure() {
  +     return null;
  +    }
  +
  +    /**
  +     * Returns the name of the auxiliary class or null if this predicate 
  +     * is compiled inside the Translet.
  +     */
  +    public String getInnerClassName() {
  +     return _className;
  +    }
  +
  +    /**
  +     * Add new variable to the closure.
  +     */
  +    public void addVariable(VariableRefBase variableRef) {
  +     if (_closureVars == null) {
  +         _closureVars = new ArrayList();
  +     }
  +
  +     // Only one reference per variable
  +     if (!_closureVars.contains(variableRef)) {
  +         _closureVars.add(variableRef);
  +     }
  +    }
  +
  +    // -- End Closure interface ----------------------
  +
  +   public void parseContents(Parser parser) {
        final int count = _attributes.getLength();
   
        for (int i = 0; i < count; i++) {
  @@ -253,12 +299,11 @@
       }
   
       /**
  -     * Compiles a constructor for the class <tt>className</tt> that
  +     * Compiles a constructor for the class <tt>_className</tt> that
        * inherits from {Any,Single,Multiple}NodeCounter. This constructor
        * simply calls the same constructor in the super class.
        */
  -    private void compileConstructor(ClassGenerator classGen,
  -                                    String className) {
  +    private void compileConstructor(ClassGenerator classGen) {
        MethodGenerator cons;
        final InstructionList il = new InstructionList();
        final ConstantPoolGen cpg = classGen.getConstantPool();
  @@ -275,7 +320,7 @@
                                       "translet",
                                       "iterator"
                                   },
  -                                "<init>", className, il, cpg);
  +                                "<init>", _className, il, cpg);
   
        il.append(ALOAD_0);     // this
        il.append(ALOAD_1);     // translet
  @@ -303,13 +348,11 @@
        */
       private void compileLocals(NodeCounterGenerator nodeCounterGen,
                               MatchGenerator matchGen,
  -                            InstructionList il) {
  -
  -     ConstantPoolGen cpg = nodeCounterGen.getConstantPool();
  -     final String className = matchGen.getClassName();
  -
  -     LocalVariableGen local;
  +                            InstructionList il) 
  +    {
        int field;
  +     LocalVariableGen local;
  +     ConstantPoolGen cpg = nodeCounterGen.getConstantPool();
   
        // Get NodeCounter._iterator and store locally
        local = matchGen.addLocalVariable("iterator", 
  @@ -338,7 +381,7 @@
        local = matchGen.addLocalVariable("document", 
                                          Util.getJCRefType(DOM_INTF_SIG),
                                          null, null);
  -     field = cpg.addFieldref(className, "_document", DOM_INTF_SIG);
  +     field = cpg.addFieldref(_className, "_document", DOM_INTF_SIG);
        il.append(ALOAD_0); // 'this' pointer on stack
        il.append(new GETFIELD(field));
        // Make sure we have the correct DOM type on the stack!!!
  @@ -347,16 +390,16 @@
       }
   
       private void compilePatterns(ClassGenerator classGen,
  -                              MethodGenerator methodGen) {
  -     //!!!  local variables?
  +                              MethodGenerator methodGen) 
  +    {
        int current;
        int field;
        LocalVariableGen local;
        MatchGenerator matchGen;
        NodeCounterGenerator nodeCounterGen;
   
  -     final String className = getXSLTC().getHelperClassName();
  -     nodeCounterGen = new NodeCounterGenerator(className,
  +     _className = getXSLTC().getHelperClassName();
  +     nodeCounterGen = new NodeCounterGenerator(_className,
                                                  ClassNames[_level],
                                                  toString(), 
                                                  ACC_PUBLIC | ACC_SUPER,
  @@ -365,8 +408,22 @@
        InstructionList il = null;
        ConstantPoolGen cpg = nodeCounterGen.getConstantPool();
   
  +     // Add a new instance variable for each var in closure
  +     final int closureLen = (_closureVars == null) ? 0 : 
  +         _closureVars.size();
  +
  +     for (int i = 0; i < closureLen; i++) {
  +         VariableBase var = 
  +             ((VariableRefBase) _closureVars.get(i)).getVariable();
  +
  +         nodeCounterGen.addField(new Field(ACC_PUBLIC, 
  +                                     cpg.addUtf8(var.getVariable()),
  +                                     
cpg.addUtf8(var.getType().toSignature()),
  +                                     null, cpg.getConstantPool()));
  +     }
  +
        // Add a single constructor to the class
  -     compileConstructor(nodeCounterGen, className);
  +     compileConstructor(nodeCounterGen);
   
        /*
         * Compile method matchesFrom()
  @@ -382,7 +439,7 @@
                                   new String[] {
                                       "node",
                                   },
  -                                "matchesFrom", className, il, cpg);
  +                                "matchesFrom", _className, il, cpg);
   
            compileLocals(nodeCounterGen,matchGen,il);
   
  @@ -412,7 +469,7 @@
                                          new String[] {
                                              "node",
                                          },
  -                                       "matchesCount", className, il, cpg);
  +                                       "matchesCount", _className, il, cpg);
   
            compileLocals(nodeCounterGen,matchGen,il);
            
  @@ -436,17 +493,31 @@
        cpg = classGen.getConstantPool();
        il = methodGen.getInstructionList();
   
  -     final int index = cpg.addMethodref(className, "<init>", 
  +     final int index = cpg.addMethodref(_className, "<init>", 
                                           "(" + TRANSLET_INTF_SIG
                                           + DOM_INTF_SIG 
                                           + NODE_ITERATOR_SIG
                                           + ")V");
  -     il.append(new NEW(cpg.addClass(className)));
  +     il.append(new NEW(cpg.addClass(_className)));
        il.append(DUP);
        il.append(classGen.loadTranslet());
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadIterator());
        il.append(new INVOKESPECIAL(index));
  +
  +     // Initialize closure variables
  +     for (int i = 0; i < closureLen; i++) {
  +         final VariableRefBase varRef = (VariableRefBase) 
_closureVars.get(i);
  +         final VariableBase var = varRef.getVariable();
  +         final Type varType = var.getType();
  +
  +         // Store variable in new closure
  +         il.append(DUP);
  +         il.append(var.loadInstruction());
  +         il.append(new PUTFIELD(
  +                 cpg.addFieldref(_className, var.getVariable(), 
  +                     varType.toSignature())));
  +     }
       }
   
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
  
  
  
  1.10.6.2  +24 -17    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParameterRef.java
  
  Index: ParameterRef.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParameterRef.java,v
  retrieving revision 1.10.6.1
  retrieving revision 1.10.6.2
  diff -u -r1.10.6.1 -r1.10.6.2
  --- ParameterRef.java 13 Aug 2002 21:21:13 -0000      1.10.6.1
  +++ ParameterRef.java 12 Sep 2002 16:07:33 -0000      1.10.6.2
  @@ -79,21 +79,31 @@
        return "parameter-ref("+_variable.getName()+'/'+_variable.getType()+')';
       }
   
  -    public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
  +   public void translate(ClassGenerator classGen, MethodGenerator methodGen) 
{
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
        final String name = _variable.getVariable();
  +     final String signature = _type.toSignature();
   
        if (_variable.isLocal()) {
            if (classGen.isExternal()) {
  -             il.append(classGen.loadTranslet());
  -             il.append(new PUSH(cpg, name));
  -             final int index = cpg.addMethodref(TRANSLET_CLASS, 
  -                                                GET_PARAMETER,
  -                                                GET_PARAMETER_SIG);
  -             il.append(new INVOKEVIRTUAL(index));
  -             _type.translateUnBox(classGen, methodGen);
  +             Closure variableClosure = _closure;
  +             while (variableClosure != null) {
  +                 if (variableClosure.inInnerClass()) break;
  +                 variableClosure = variableClosure.getParentClosure();
  +             }
  +         
  +             if (variableClosure != null) {
  +                 il.append(ALOAD_0);
  +                 il.append(new GETFIELD(
  +                     cpg.addFieldref(variableClosure.getInnerClassName(), 
  +                         name, signature)));
  +             }
  +             else {
  +                 il.append(_variable.loadInstruction());
  +                 _variable.removeReference(this);
  +             }
            }
            else {
                il.append(_variable.loadInstruction());
  @@ -101,10 +111,8 @@
            }
        }
        else {
  -         final String signature = _type.toSignature();
            final String className = classGen.getClassName();
            il.append(classGen.loadTranslet());
  -         // If inside a predicate we must cast this ref down
            if (classGen.isExternal()) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
  @@ -113,12 +121,11 @@
   
        if (_variable.getType() instanceof NodeSetType) {
            // The method cloneIterator() also does resetting
  -            final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
  -                                                       "cloneIterator",
  -                                                       "()" +
  -                                                        NODE_ITERATOR_SIG);
  -            il.append(new INVOKEINTERFACE(clone, 1));
  +         final int clone = cpg.addInterfaceMethodref(NODE_ITERATOR,
  +                                                    "cloneIterator",
  +                                                    "()" + 
  +                                                     NODE_ITERATOR_SIG);
  +         il.append(new INVOKEINTERFACE(clone, 1));
        }
  -
       }
   }
  
  
  
  1.22.6.2  +120 -13   
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java
  
  Index: Predicate.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java,v
  retrieving revision 1.22.6.1
  retrieving revision 1.22.6.2
  diff -u -r1.22.6.1 -r1.22.6.2
  --- Predicate.java    29 Jul 2002 00:01:22 -0000      1.22.6.1
  +++ Predicate.java    12 Sep 2002 16:07:33 -0000      1.22.6.2
  @@ -65,22 +65,27 @@
   package org.apache.xalan.xsltc.compiler;
   
   import java.util.Vector;
  +import java.util.ArrayList;
   
   import org.apache.bcel.classfile.JavaClass;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.ReferenceType;
   import org.apache.bcel.generic.*;
   import org.apache.xalan.xsltc.compiler.util.*;
  +import org.apache.bcel.classfile.Field;
   
  -final class Predicate extends Expression {
  +final class Predicate extends Expression implements Closure {
   
       private Expression _exp = null; // Expression to be compiled inside pred.
  -    private String  _className;     // Name of filter to generate
       private boolean _nthPositionFilter = false;
       private boolean _nthDescendant = false;
       private boolean _canOptimize = true;
       private int     _ptype = -1;
   
  +    private String _className = null;
  +    private ArrayList _closureVars = null;
  +    private Closure _parentClosure = null;
  +
       public Predicate(Expression exp) {
        (_exp = exp).setParent(this);
       }
  @@ -102,10 +107,66 @@
        _canOptimize = false;
       }
   
  -    protected final boolean isClosureBoundary() {
  -     return true;
  +    // -- Begin Closure interface --------------------
  +
  +    /**
  +     * Returns true if this closure is compiled in an inner class (i.e.
  +     * if this is a real closure).
  +     */
  +    public boolean inInnerClass() {
  +     return (_className != null);
  +    }
  +
  +    /**
  +     * Returns a reference to its parent closure or null if outermost.
  +     */
  +    public Closure getParentClosure() {
  +     if (_parentClosure == null) {
  +         SyntaxTreeNode node = getParent();
  +         do {
  +             if (node instanceof Closure) {
  +                 _parentClosure = (Closure) node;
  +                 break;
  +             }
  +             if (node instanceof TopLevelElement) {
  +                 break;      // way up in the tree
  +             }
  +             node = node.getParent();
  +         } while (node != null);
  +     }
  +     return _parentClosure;
       }
  -    
  +
  +    /**
  +     * Returns the name of the auxiliary class or null if this predicate 
  +     * is compiled inside the Translet.
  +     */
  +    public String getInnerClassName() {
  +     return _className;
  +    }
  +
  +    /**
  +     * Add new variable to the closure.
  +     */
  +    public void addVariable(VariableRefBase variableRef) {
  +     if (_closureVars == null) {
  +         _closureVars = new ArrayList();
  +     }
  +
  +     // Only one reference per variable
  +     if (!_closureVars.contains(variableRef)) {
  +         _closureVars.add(variableRef);
  +
  +         // Add variable to parent closure as well
  +         Closure parentClosure = getParentClosure();
  +         if (parentClosure != null) {
  +             parentClosure.addVariable(variableRef);
  +         }
  +     }
  +    }
  +
  +    // -- End Closure interface ----------------------
  +
       public int getPosType() {
        if (_ptype == -1) {
            SyntaxTreeNode parent = getParent();
  @@ -273,9 +334,20 @@
                                        },
                                        classGen.getStylesheet());      
   
  -     final InstructionList il = new InstructionList();
        final ConstantPoolGen cpg = filterGen.getConstantPool();
  +     final int length = (_closureVars == null) ? 0 : _closureVars.size();
   
  +     // Add a new instance variable for each var in closure
  +     for (int i = 0; i < length; i++) {
  +         VariableBase var = ((VariableRefBase) 
_closureVars.get(i)).getVariable();
  +
  +         filterGen.addField(new Field(ACC_PUBLIC, 
  +                                     cpg.addUtf8(var.getVariable()),
  +                                     
cpg.addUtf8(var.getType().toSignature()),
  +                                     null, cpg.getConstantPool()));
  +     }
  +
  +     final InstructionList il = new InstructionList();
        testGen = new TestGenerator(ACC_PUBLIC | ACC_FINAL,
                                    org.apache.bcel.generic.Type.BOOLEAN, 
                                    new org.apache.bcel.generic.Type[] {
  @@ -339,10 +411,7 @@
        */
       public boolean isNodeValueTest() {
        if (!_canOptimize) return false;
  -     if ((getStep() != null) && (getCompareValue() != null))
  -         return true;
  -     else
  -         return false;
  +     return (getStep() != null && getCompareValue() != null);
       }
   
       private Expression _value = null;
  @@ -439,15 +508,53 @@
        * filter object and a reference to the predicate's closure.
        */
       public void translateFilter(ClassGenerator classGen,
  -                             MethodGenerator methodGen) {
  -
  +                             MethodGenerator methodGen) 
  +    {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  +     // Compile auxiliary class for filter
        compileFilter(classGen, methodGen);
  +     
  +     // Create new instance of filter
        il.append(new NEW(cpg.addClass(_className)));
        il.append(DUP);
        il.append(new INVOKESPECIAL(cpg.addMethodref(_className,
                                                     "<init>", "()V")));
  +
  +     // Initialize closure variables
  +     final int length = (_closureVars == null) ? 0 : _closureVars.size();
  +
  +     for (int i = 0; i < length; i++) {
  +         VariableRefBase varRef = (VariableRefBase) _closureVars.get(i);
  +         VariableBase var = varRef.getVariable();
  +         Type varType = var.getType();
  +
  +         il.append(DUP);
  +
  +         // Find nearest closure implemented as an inner class
  +         Closure variableClosure = _parentClosure;
  +         while (variableClosure != null) {
  +             if (variableClosure.inInnerClass()) break;
  +             variableClosure = variableClosure.getParentClosure();
  +         }
  +
  +         // Use getfield if in an inner class
  +         if (variableClosure != null) {
  +             il.append(ALOAD_0);
  +             il.append(new GETFIELD(
  +                 cpg.addFieldref(variableClosure.getInnerClassName(), 
  +                     var.getVariable(), varType.toSignature())));
  +         }
  +         else {
  +             // Use a load of instruction if in translet class
  +             il.append(var.loadInstruction());
  +         }
  +
  +         // Store variable in new closure
  +         il.append(new PUTFIELD(
  +                 cpg.addFieldref(_className, var.getVariable(), 
  +                     varType.toSignature())));
  +     }
       }
   }
  
  
  
  1.12.6.2  +1 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java
  
  Index: RelationalExpr.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java,v
  retrieving revision 1.12.6.1
  retrieving revision 1.12.6.2
  diff -u -r1.12.6.1 -r1.12.6.2
  --- RelationalExpr.java       24 Aug 2002 12:39:05 -0000      1.12.6.1
  +++ RelationalExpr.java       12 Sep 2002 16:07:33 -0000      1.12.6.2
  @@ -225,7 +225,6 @@
            _right.startResetIterator(classGen, methodGen);
   
            il.append(new PUSH(cpg, _op));
  -         il.append(methodGen.loadContextNode());
            il.append(methodGen.loadDOM());
   
            int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "compare",
  @@ -233,7 +232,6 @@
                                         + _left.getType().toSignature() 
                                         + _right.getType().toSignature()
                                         + "I"
  -                                      + NODE_SIG
                                         + DOM_INTF_SIG
                                         + ")Z");
            il.append(new INVOKESTATIC(index));
  
  
  
  1.14.6.2  +276 -30   
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java
  
  Index: Sort.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java,v
  retrieving revision 1.14.6.1
  retrieving revision 1.14.6.2
  diff -u -r1.14.6.1 -r1.14.6.2
  --- Sort.java 29 Jul 2002 00:01:22 -0000      1.14.6.1
  +++ Sort.java 12 Sep 2002 16:07:33 -0000      1.14.6.2
  @@ -65,6 +65,7 @@
   package org.apache.xalan.xsltc.compiler;
   
   import java.util.Vector;
  +import java.util.ArrayList;
   import java.util.StringTokenizer;
   import java.util.NoSuchElementException;
   import java.text.Collator;
  @@ -82,7 +83,7 @@
   import org.apache.xalan.xsltc.compiler.util.*;
   
   
  -final class Sort extends Instruction {
  +final class Sort extends Instruction implements Closure {
   
       private Expression     _select;
       private AttributeValue _order;
  @@ -93,6 +94,56 @@
       public  String         _lang;
       public  String         _country;
   
  +    private String _className = null;
  +    private ArrayList _closureVars = null;
  +    private boolean _needsSortRecordFactory = false;
  +
  +    // -- Begin Closure interface --------------------
  +
  +    /**
  +     * Returns true if this closure is compiled in an inner class (i.e.
  +     * if this is a real closure).
  +     */
  +    public boolean inInnerClass() {
  +     return (_className != null);
  +    }
  +
  +    /**
  +     * Returns a reference to its parent closure or null if outermost.
  +     */
  +    public Closure getParentClosure() {
  +     return null;
  +    }
  +
  +    /**
  +     * Returns the name of the auxiliary class or null if this predicate 
  +     * is compiled inside the Translet.
  +     */
  +    public String getInnerClassName() {
  +     return _className;
  +    }
  +
  +    /**
  +     * Add new variable to the closure.
  +     */
  +    public void addVariable(VariableRefBase variableRef) {
  +     if (_closureVars == null) {
  +         _closureVars = new ArrayList();
  +     }
  +
  +     // Only one reference per variable
  +     if (!_closureVars.contains(variableRef)) {
  +         _closureVars.add(variableRef);
  +         _needsSortRecordFactory = true;
  +     }
  +    }
  +
  +    // -- End Closure interface ----------------------
  +
  +    private void setInnerClassName(String className) {
  +     _className = className;
  +    }
  +
       /**
        * Parse the attributes of the xsl:sort element
        */
  @@ -202,9 +253,10 @@
        * and a node sort record producing objects as its parameters.
        */
       public static void translateSortIterator(ClassGenerator classGen,
  -                                          MethodGenerator methodGen,
  -                                          Expression nodeSet,
  -                                          Vector sortObjects) {
  +                                   MethodGenerator methodGen,
  +                                   Expression nodeSet,
  +                                   Vector sortObjects) 
  +    {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  @@ -244,36 +296,38 @@
        * will produce NodeSortRecord objects of a specific type.
        */
       public static void compileSortRecordFactory(Vector sortObjects,
  -                                             ClassGenerator classGen,
  -                                             MethodGenerator methodGen) {
  +     ClassGenerator classGen, MethodGenerator methodGen) 
  +    {
  +     String sortRecordClass = 
  +         compileSortRecord(sortObjects, classGen, methodGen);
  +
  +     boolean needsSortRecordFactory = false;
  +     final int nsorts = sortObjects.size();
  +     for (int i = 0; i < nsorts; i++) {
  +         final Sort sort = (Sort) sortObjects.elementAt(i);
  +         needsSortRecordFactory |= sort._needsSortRecordFactory;
  +     }
  +
  +     String sortRecordFactoryClass = NODE_SORT_FACTORY;
  +     if (needsSortRecordFactory) {
  +         sortRecordFactoryClass = 
  +             compileSortRecordFactory(sortObjects, classGen, methodGen, 
  +                 sortRecordClass);
  +     }
  +
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
        
  -     // NodeSortRecordFactory.NodeSortRecordFactory(dom,class,levels,trlet);
  -     final String initParams =
  -         "("+DOM_INTF_SIG+STRING_SIG+TRANSLET_INTF_SIG+
  -         "["+STRING_SIG+"["+STRING_SIG+")V";
  -     final int init = cpg.addMethodref(NODE_SORT_FACTORY,
  -                                       "<init>", initParams);
  -
  -     // Compile the object that will encapsulate each sort object (node).
  -     // NodeSortRecordFactory needs the name of the new class.
  -     String className = compileSortRecord(sortObjects, classGen, methodGen);
  -
  -     // The constructor for the NodeSortRecord generating class takes no
  -     // parameters so we must to pass initialization params to other methods
  -     il.append(new NEW(cpg.addClass(NODE_SORT_FACTORY)));
  +     il.append(new NEW(cpg.addClass(sortRecordFactoryClass)));
        il.append(DUP);
        il.append(methodGen.loadDOM());
  -     il.append(new PUSH(cpg, className));
  +     il.append(new PUSH(cpg, sortRecordClass));
        il.append(classGen.loadTranslet());
   
  -     // Compile code that initializes the static _compareType array
  -     final int levels = sortObjects.size();
        // Compile code that initializes the static _sortOrder
  -     il.append(new PUSH(cpg, levels));
  +     il.append(new PUSH(cpg, nsorts));
        il.append(new ANEWARRAY(cpg.addClass(STRING)));
  -     for (int level = 0; level < levels; level++) {
  +     for (int level = 0; level < nsorts; level++) {
            final Sort sort = (Sort)sortObjects.elementAt(level);
            il.append(DUP);
            il.append(new PUSH(cpg, level));
  @@ -281,9 +335,9 @@
            il.append(AASTORE);
        }
   
  -     il.append(new PUSH(cpg,levels));
  +     il.append(new PUSH(cpg, nsorts));
        il.append(new ANEWARRAY(cpg.addClass(STRING)));
  -     for (int level = 0; level < levels; level++) {
  +     for (int level = 0; level < nsorts; level++) {
            final Sort sort = (Sort)sortObjects.elementAt(level);
            il.append(DUP);
            il.append(new PUSH(cpg, level));
  @@ -291,7 +345,172 @@
            il.append(AASTORE);
        }
   
  -     il.append(new INVOKESPECIAL(init));
  +     il.append(new INVOKESPECIAL(
  +         cpg.addMethodref(sortRecordFactoryClass, "<init>", 
  +             "(" + DOM_INTF_SIG 
  +                 + STRING_SIG
  +                 + TRANSLET_INTF_SIG
  +                 + "[" + STRING_SIG
  +                 + "[" + STRING_SIG + ")V")));
  +
  +     // Initialize closure variables in sortRecordFactory
  +     final ArrayList dups = new ArrayList();
  +
  +     for (int j = 0; j < nsorts; j++) {
  +         final Sort sort = (Sort) sortObjects.get(j);
  +         final int length = (sort._closureVars == null) ? 0 : 
  +             sort._closureVars.size();
  +
  +         for (int i = 0; i < length; i++) {
  +             VariableRefBase varRef = (VariableRefBase) 
sort._closureVars.get(i);
  +
  +             // Discard duplicate variable references
  +             if (dups.contains(varRef)) continue;
  +
  +             final VariableBase var = varRef.getVariable();
  +
  +             // Store variable in new closure
  +             il.append(DUP);
  +             il.append(var.loadInstruction());
  +             il.append(new PUTFIELD(
  +                     cpg.addFieldref(sortRecordFactoryClass, 
var.getVariable(), 
  +                         var.getType().toSignature())));
  +             dups.add(varRef);
  +         }
  +     }
  +    }
  +
  +    public static String compileSortRecordFactory(Vector sortObjects,
  +     ClassGenerator classGen, MethodGenerator methodGen, 
  +     String sortRecordClass)
  +    {
  +     final XSLTC  xsltc = ((Sort)sortObjects.firstElement()).getXSLTC();
  +     final String className = xsltc.getHelperClassName();
  +
  +     final NodeSortRecordFactGenerator sortRecordFactory =
  +         new NodeSortRecordFactGenerator(className,
  +                                     NODE_SORT_FACTORY,
  +                                     className + ".java",
  +                                     ACC_PUBLIC | ACC_SUPER | ACC_FINAL,
  +                                     new String[] {},
  +                                     classGen.getStylesheet());
  +
  +     ConstantPoolGen cpg = sortRecordFactory.getConstantPool();
  +
  +     // Add a new instance variable for each var in closure
  +     final int nsorts = sortObjects.size();
  +     final ArrayList dups = new ArrayList();
  +
  +     for (int j = 0; j < nsorts; j++) {
  +         final Sort sort = (Sort) sortObjects.get(j);
  +         final int length = (sort._closureVars == null) ? 0 : 
  +             sort._closureVars.size();
  +
  +         for (int i = 0; i < length; i++) {
  +             final VariableRef varRef = (VariableRef) 
sort._closureVars.get(i);
  +
  +             // Discard duplicate variable references
  +             if (dups.contains(varRef)) continue;
  +
  +             final VariableBase var = varRef.getVariable();
  +             sortRecordFactory.addField(new Field(ACC_PUBLIC, 
  +                                        cpg.addUtf8(var.getVariable()),
  +                                        
cpg.addUtf8(var.getType().toSignature()),
  +                                        null, cpg.getConstantPool()));
  +             dups.add(varRef);
  +         }
  +     }
  +
  +     // Define a constructor for this class
  +     final org.apache.bcel.generic.Type[] argTypes = 
  +         new org.apache.bcel.generic.Type[5];
  +     argTypes[0] = Util.getJCRefType(DOM_INTF_SIG);
  +     argTypes[1] = Util.getJCRefType(STRING_SIG);
  +     argTypes[2] = Util.getJCRefType(TRANSLET_INTF_SIG);
  +     argTypes[3] = Util.getJCRefType("[" + STRING_SIG);
  +     argTypes[4] = Util.getJCRefType("[" + STRING_SIG);
  +
  +     final String[] argNames = new String[5];
  +     argNames[0] = DOCUMENT_PNAME;
  +     argNames[1] = "className";
  +     argNames[2] = TRANSLET_PNAME;
  +     argNames[3] = "order";
  +     argNames[4] = "type";
  +
  +     InstructionList il = new InstructionList();
  +     final MethodGenerator constructor =
  +         new MethodGenerator(ACC_PUBLIC,
  +                             org.apache.bcel.generic.Type.VOID, 
  +                             argTypes, argNames, "<init>", 
  +                             className, il, cpg);
  +
  +     // Push all parameters onto the stack and called super.<init>()
  +     il.append(ALOAD_0);
  +     il.append(ALOAD_1);
  +     il.append(ALOAD_2);
  +     il.append(new ALOAD(3));
  +     il.append(new ALOAD(4));
  +     il.append(new ALOAD(5));
  +     il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_FACTORY,
  +         "<init>", 
  +         "(" + DOM_INTF_SIG 
  +             + STRING_SIG 
  +             + TRANSLET_INTF_SIG 
  +             + "[" + STRING_SIG
  +             + "[" + STRING_SIG + ")V")));
  +     il.append(RETURN);
  +
  +     // Override the definition of makeNodeSortRecord()
  +     il = new InstructionList(); 
  +     final MethodGenerator makeNodeSortRecord =
  +         new MethodGenerator(ACC_PUBLIC,
  +             Util.getJCRefType(NODE_SORT_RECORD_SIG), 
  +             new org.apache.bcel.generic.Type[] { 
  +                 org.apache.bcel.generic.Type.INT,
  +                 org.apache.bcel.generic.Type.INT },
  +             new String[] { "node", "last" }, "makeNodeSortRecord",
  +             className, il, cpg);
  +
  +     il.append(ALOAD_0);
  +     il.append(ILOAD_1);
  +     il.append(ILOAD_2);
  +     il.append(new INVOKESPECIAL(cpg.addMethodref(NODE_SORT_FACTORY,
  +         "makeNodeSortRecord", "(II)" + NODE_SORT_RECORD_SIG)));
  +     il.append(DUP);
  +     il.append(new CHECKCAST(cpg.addClass(sortRecordClass)));
  +
  +     // Initialize closure in record class
  +     final int ndups = dups.size();
  +     for (int i = 0; i < ndups; i++) {
  +         final VariableRef varRef = (VariableRef) dups.get(i);
  +         final VariableBase var = varRef.getVariable();
  +         final Type varType = var.getType();
  +         
  +         il.append(DUP);
  +
  +         // Get field from factory class
  +         il.append(ALOAD_0);
  +         il.append(new GETFIELD(
  +             cpg.addFieldref(className,
  +                 var.getVariable(), varType.toSignature())));
  +
  +         // Put field in record class
  +         il.append(new PUTFIELD(
  +             cpg.addFieldref(sortRecordClass,
  +                 var.getVariable(), varType.toSignature())));
  +     }
  +     il.append(POP);
  +     il.append(ARETURN);
  +
  +     constructor.setMaxLocals();
  +     constructor.setMaxStack();
  +     sortRecordFactory.addMethod(constructor.getMethod());
  +     makeNodeSortRecord.setMaxLocals();
  +     makeNodeSortRecord.setMaxStack();
  +     sortRecordFactory.addMethod(makeNodeSortRecord.getMethod());
  +     xsltc.dumpClass(sortRecordFactory.getJavaClass());
  +
  +     return className;
       }
   
       /**
  @@ -313,7 +532,34 @@
                                        classGen.getStylesheet());
        
        final ConstantPoolGen cpg = sortRecord.getConstantPool();       
  -     
  +
  +     // Add a new instance variable for each var in closure
  +     final int nsorts = sortObjects.size();
  +     final ArrayList dups = new ArrayList();
  +
  +     for (int j = 0; j < nsorts; j++) {
  +         final Sort sort = (Sort) sortObjects.get(j);
  +
  +         // Set the name of the inner class in this sort object
  +         sort.setInnerClassName(className);  
  +
  +         final int length = (sort._closureVars == null) ? 0 : 
  +             sort._closureVars.size();
  +         for (int i = 0; i < length; i++) {
  +             final VariableRef varRef = (VariableRef) 
sort._closureVars.get(i);
  +
  +             // Discard duplicate variable references
  +             if (dups.contains(varRef)) continue;
  +
  +             final VariableBase var = varRef.getVariable();
  +             sortRecord.addField(new Field(ACC_PUBLIC, 
  +                                 cpg.addUtf8(var.getVariable()),
  +                                 cpg.addUtf8(var.getType().toSignature()),
  +                                 null, cpg.getConstantPool()));
  +             dups.add(varRef);
  +         }
  +     }
  +
        Method clinit = compileClassInit(sortObjects, sortRecord,
                                         cpg, className);
        Method extract = compileExtract(sortObjects, sortRecord,
  
  
  
  1.19.2.3  +2 -18     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
  
  Index: SyntaxTreeNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java,v
  retrieving revision 1.19.2.2
  retrieving revision 1.19.2.3
  diff -u -r1.19.2.2 -r1.19.2.3
  --- SyntaxTreeNode.java       29 Jul 2002 00:01:23 -0000      1.19.2.2
  +++ SyntaxTreeNode.java       12 Sep 2002 16:07:33 -0000      1.19.2.3
  @@ -406,23 +406,7 @@
        * @return Symbol table.
        */
       protected final SymbolTable getSymbolTable() {
  -     if (_parser != null)
  -         return _parser.getSymbolTable();
  -     else
  -         return null;
  -    }
  -
  -    /**
  -     * Local variables that are accessible from a given syntax tree node will
  -     * be put on the JVM's stack. A closure is a record that contains a 
pointer
  -     * to a node's outer variable frame (not only global variables, but also
  -     * variables in parent nodes). This method returns true if this node's 
code
  -     * is implemented by code outside of ApplyTemplates (the only such case 
is
  -     * the Predicates class). This methid is only called by the VariableRef).
  -     * @return 'true' if node's code is implemented outside of ApplyTemplates
  -     */
  -    protected boolean isClosureBoundary() {
  -     return false;
  +     return (_parser == null) ? null : _parser.getSymbolTable();
       }
   
       /**
  
  
  
  1.16.6.2  +1 -47     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java
  
  Index: Template.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java,v
  retrieving revision 1.16.6.1
  retrieving revision 1.16.6.2
  diff -u -r1.16.6.1 -r1.16.6.2
  --- Template.java     29 Jul 2002 00:01:23 -0000      1.16.6.1
  +++ Template.java     12 Sep 2002 16:07:33 -0000      1.16.6.2
  @@ -85,14 +85,6 @@
       private int     _position; // Position within stylesheet (prio. 
resolution)
       private boolean _disabled = false;
       private boolean _compiled = false;//make sure it is compiled only once
  -
  -    /**
  -     * Set to <tt>true</tt> by the XPath parser if this template
  -     * needs to create a variable frame. Variable frames are needed
  -     * when certain parts of a template are compiled in external
  -     * classes (e.g., predicates, xsl:number, xsl:sort).
  -     */
  -    private boolean _hasVariableFrame;
       private boolean _hasParams = false;
       private boolean _simplified = false;
   
  @@ -165,29 +157,6 @@
            return 0;
       }
   
  -    private Hashtable _variables;
  -    private int _nextIndex;
  -
  -    public int allocateIndex(QName varName) {
  -     if (_variables == null) { // first time
  -         _hasVariableFrame = true;
  -         (_variables = new Hashtable()).put(varName, new Integer(0));
  -         _nextIndex = 1;
  -         return 0;
  -     }
  -     else {
  -         Integer index = (Integer)_variables.get(varName);
  -         if (index == null) {
  -             _variables.put(varName, index = new Integer(_nextIndex++));
  -         }
  -         return index.intValue();
  -     }
  -    }
  -
  -    private final int localVariablesCount() {
  -     return _variables == null ? 0 : _variables.size();
  -    }
  -    
       public void display(int indent) {
        Util.println('\n');
        indent(indent);
  @@ -354,24 +323,9 @@
        if (_compiled) return;
        _compiled = true; 
        
  -     if (_hasVariableFrame) {
  -         il.append(classGen.loadTranslet());
  -         il.append(new PUSH(cpg, localVariablesCount()));
  -         il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
  -                                                      PUSH_VAR_FRAME,
  -                                                      PUSH_VAR_FRAME_SIG)));
  -     }
  -     
        final InstructionHandle start = il.getEnd();
        translateContents(classGen, methodGen);
        final InstructionHandle end = il.getEnd();
        il.setPositions(true);
  -     
  -     if (_hasVariableFrame) {
  -         il.append(classGen.loadTranslet());
  -         il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS, 
  -                                                      POP_VAR_FRAME,
  -                                                      POP_VAR_FRAME_SIG)));
  -     }
       }
   }
  
  
  
  1.22.6.1  +3 -45     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java
  
  Index: Variable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java,v
  retrieving revision 1.22
  retrieving revision 1.22.6.1
  diff -u -r1.22 -r1.22.6.1
  --- Variable.java     1 Feb 2002 20:07:09 -0000       1.22
  +++ Variable.java     12 Sep 2002 16:07:33 -0000      1.22.6.1
  @@ -77,37 +77,14 @@
   
   final class Variable extends VariableBase {
   
  -    // Index of this variable in the variable stack relative to base ptr
  -    private int _stackIndex = -1;
  -
  -    private boolean _escapes; // 'true' if the variable's value can change
  -
  -    /**
  -     * This method returns 'true' if the variable value can change over time,
  -     * such as with varibles inside a for-each loop.
  -     */
  -    public void setEscapes() {
  -     _escapes = true;
  -     if (_stackIndex == -1) { // unassigned
  -         Template template = getTemplate();
  -         if (template != null) {
  -             _stackIndex = template.allocateIndex(_name);
  -         }
  -     }
  -    }
  -
  -    /**
  -     *
  -     */
  -    public int getStackIndex() {
  -     return _stackIndex;
  +    public int getIndex() {
  +     return (_local != null) ? _local.getIndex() : -1;
       }
   
       /**
        * Parse the contents of the variable
        */
       public void parseContents(Parser parser) {
  -
        // Parse 'name' and 'select' attributes plus parameter contents
        super.parseContents(parser);
   
  @@ -210,20 +187,9 @@
        _ignore = true;
   
        if (isLocal()) {
  -         // Push args to call addVariable()
  -         if (_escapes) {
  -             il.append(classGen.loadTranslet());
  -             il.append(new PUSH(cpg, _stackIndex));
  -         }
  -
            // Compile variable value computation
            translateValue(classGen, methodGen);
   
  -         // Dup value only when needed
  -         if (_escapes) {
  -             il.append(_type.DUP());
  -         }
  -
            // Add a new local variable and store value
            if (_refs.isEmpty()) { // Remove it if nobody uses the value
                il.append(_type.POP());
  @@ -232,14 +198,6 @@
            else {                 // Store in local var slot if referenced
                if (_local == null) mapRegister(methodGen);
                il.append(_type.STORE(_local.getIndex()));
  -         }
  -
  -         // Store boxed value into the template's variable stack
  -         if (_escapes) {
  -             _type.translateBox(classGen, methodGen);
  -             il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
  -                                                          ADD_VARIABLE,
  -                                                          
ADD_VARIABLE_SIG)));
            }
        }
        else {
  
  
  
  1.11.6.2  +19 -36    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRef.java
  
  Index: VariableRef.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRef.java,v
  retrieving revision 1.11.6.1
  retrieving revision 1.11.6.2
  diff -u -r1.11.6.1 -r1.11.6.2
  --- VariableRef.java  13 Aug 2002 21:21:13 -0000      1.11.6.1
  +++ VariableRef.java  12 Sep 2002 16:07:33 -0000      1.11.6.2
  @@ -71,33 +71,10 @@
   
   final class VariableRef extends VariableRefBase {
   
  -    private boolean _escaped;
  -     
       public VariableRef(Variable variable) {
        super(variable);
       }
   
  -    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  -     if ( (_variable.isLocal()) && (_escaped = isEscaped()) )
  -         ((Variable)_variable).setEscapes();
  -     return super.typeCheck(stable);
  -    }
  -
  -    private boolean isEscaped() {
  -     final SyntaxTreeNode limit = _variable.getParent();
  -     SyntaxTreeNode parent = getParent();
  -     do {
  -         if (parent.isClosureBoundary()) {
  -             return true;
  -         }
  -         else {
  -             parent = parent.getParent();
  -         }
  -     }
  -     while (parent != limit);
  -     return limit.isClosureBoundary();
  -    }
  -
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
  @@ -106,17 +83,26 @@
        if (_type.implementedAsMethod()) return;
   
        final String name = _variable.getVariable();
  +     final String signature = _type.toSignature();
   
        if (_variable.isLocal()) {
  -         if (classGen.isExternal() || _escaped) {
  -             il.append(classGen.loadTranslet());
  -             final int sindex = ((Variable)_variable).getStackIndex();
  -             il.append(new PUSH(cpg, sindex));
  -             final int getVar = cpg.addMethodref(TRANSLET_CLASS, 
  -                                                 GET_VARIABLE,
  -                                                 GET_VARIABLE_SIG);
  -             il.append(new INVOKEVIRTUAL(getVar));
  -             _type.translateUnBox(classGen, methodGen);
  +         if (classGen.isExternal()) {
  +             Closure variableClosure = _closure;
  +             while (variableClosure != null) {
  +                 if (variableClosure.inInnerClass()) break;
  +                 variableClosure = variableClosure.getParentClosure();
  +             }
  +         
  +             if (variableClosure != null) {
  +                 il.append(ALOAD_0);
  +                 il.append(new GETFIELD(
  +                     cpg.addFieldref(variableClosure.getInnerClassName(), 
  +                         name, signature)));
  +             }
  +             else {
  +                 il.append(_variable.loadInstruction());
  +                 _variable.removeReference(this);
  +             }
            }
            else {
                il.append(_variable.loadInstruction());
  @@ -124,10 +110,8 @@
            }
        }
        else {
  -         final String signature = _type.toSignature();
            final String className = classGen.getClassName();
            il.append(classGen.loadTranslet());
  -         // If inside a predicate we must cast this ref down
            if (classGen.isExternal()) {
                il.append(new CHECKCAST(cpg.addClass(className)));
            }
  @@ -142,6 +126,5 @@
                                                        NODE_ITERATOR_SIG);
            il.append(new INVOKEINTERFACE(clone, 1));
        }
  -
       }
   }
  
  
  
  1.8.6.1   +50 -14    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRefBase.java
  
  Index: VariableRefBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRefBase.java,v
  retrieving revision 1.8
  retrieving revision 1.8.6.1
  diff -u -r1.8 -r1.8.6.1
  --- VariableRefBase.java      1 Feb 2002 20:07:09 -0000       1.8
  +++ VariableRefBase.java      12 Sep 2002 16:07:33 -0000      1.8.6.1
  @@ -57,6 +57,7 @@
    * <http://www.apache.org/>.
    *
    * @author Morten Jorgensen
  + * @author Santiago Pericas-Geertsen
    *
    */
   
  @@ -68,16 +69,17 @@
   
   class VariableRefBase extends Expression {
   
  -    protected final VariableBase _variable; // Reference to the associated 
var.
  +    /**
  +     * A reference to the associated variable.
  +     */
  +    protected final VariableBase _variable; 
   
       /**
  -     * Created a new variable or parameter reference. Note that this base-
  -     * class is not here mostly because variable and parameter references 
share
  -     * a lot of functionality. The base class is needed more for having a
  -     * single class to run 'if (instanceof)' on in the compiler code. The 
same
  -     * holds for the variable base class.
  -     * @param variable The referenced variable
  +     * A reference to the enclosing expression/instruction for which a
  +     * closure is needed (Predicate, Number or Sort).
        */
  +    protected Closure _closure = null;
  +
       public VariableRefBase(VariableBase variable) {
        _variable = variable;
        variable.addReference(this);
  @@ -89,23 +91,34 @@
   
       /**
        * Returns a reference to the associated variable
  -     * @return The referenced variable
        */
       public VariableBase getVariable() {
  -     return(_variable);
  +     return _variable;
       }
   
       /**
        * Returns a reference to any parent variable
  -     * @return Parent variable (or null if none)
        */
       public VariableBase findParentVariable() {
        SyntaxTreeNode node = this;
  -     while ((node != null) && (!(node instanceof VariableBase)))
  +     while (node != null && !(node instanceof VariableBase)) {
            node = node.getParent();
  -     return (VariableBase)node;
  +     }
  +     return (VariableBase) node;
       }
   
  +    /**
  +     * Two variable references are deemed equal if they refer to the 
  +     * same variable.
  +     */
  +    public boolean equals(Object obj) {
  +     try {
  +         return (_variable == ((VariableRefBase) obj)._variable);
  +     } 
  +     catch (ClassCastException e) {
  +         return false;
  +     }
  +    }
   
       /**
        * Returns a string representation of this variable reference on the
  @@ -116,7 +129,30 @@
        return "variable-ref("+_variable.getName()+'/'+_variable.getType()+')';
       }
   
  -    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  +    public Type typeCheck(SymbolTable stable) 
  +     throws TypeCheckError 
  +    {
  +     // Returned cached type if available
  +     if (_type != null) return _type;
  +
  +     // Find nearest closure to add a variable reference
  +     if (_variable.isLocal()) {
  +         SyntaxTreeNode node = getParent();
  +         do {
  +             if (node instanceof Closure) {
  +                 _closure = (Closure) node;
  +                 break;
  +             }
  +             if (node instanceof TopLevelElement) {
  +                 break;      // way up in the tree
  +             }
  +             node = node.getParent();
  +         } while (node != null);
  +
  +         if (_closure != null) {
  +             _closure.addVariable(this);
  +         }
  +     }
   
        // Insert a dependency link from one variable to another
        VariableBase parent = findParentVariable();
  
  
  
  1.35.6.3  +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
  
  Index: XSLTC.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
  retrieving revision 1.35.6.2
  retrieving revision 1.35.6.3
  diff -u -r1.35.6.2 -r1.35.6.3
  --- XSLTC.java        29 Jul 2002 00:01:23 -0000      1.35.6.2
  +++ XSLTC.java        12 Sep 2002 16:07:33 -0000      1.35.6.3
  @@ -729,7 +729,7 @@
        // create the manifest
        final Manifest manifest = new Manifest();
        final java.util.jar.Attributes atrs = manifest.getMainAttributes();
  -     atrs.put(java.util.jar.Attributes.Name.MANIFEST_VERSION,"1.1");
  +     atrs.put(java.util.jar.Attributes.Name.MANIFEST_VERSION,"1.2");
   
        final Map map = manifest.getEntries();
        // create manifest
  
  
  
  1.33.10.2 +21 -43    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup
  
  Index: xpath.cup
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup,v
  retrieving revision 1.33.10.1
  retrieving revision 1.33.10.2
  diff -u -r1.33.10.1 -r1.33.10.2
  --- xpath.cup 29 Jul 2002 00:01:23 -0000      1.33.10.1
  +++ xpath.cup 12 Sep 2002 16:07:33 -0000      1.33.10.2
  @@ -116,10 +116,6 @@
           return _lineNumber;
       }
   
  -    public QName getQName(String name) {
  -          return _parser.getQName(name);
  -    }    
  -
       public QName getQNameIgnoreDefaultNs(String name) {
             return _parser.getQNameIgnoreDefaultNs(name);
       }    
  @@ -133,14 +129,10 @@
       }
   
       public int findNodeType(int axis, Object test) {
  -
        if (test == null) {  // *
  -            if (axis == Axis.ATTRIBUTE)
  -                return NodeTest.ATTRIBUTE;
  -            else if (axis == Axis.NAMESPACE)
  -                return -1;
  -            else
  -                return NodeTest.ELEMENT;
  +         return (axis == Axis.ATTRIBUTE) ? 
  +             NodeTest.ATTRIBUTE :
  +             (axis == Axis.NAMESPACE) ? -1 : NodeTest.ELEMENT;
           }
           else if (test instanceof Integer) {
               return ((Integer)test).intValue();
  @@ -149,30 +141,24 @@
            QName name = (QName)test;
   
            if (axis == Axis.NAMESPACE) {
  -                if (name.toString().equals("*"))
  -                    return -1;
  -                else
  -                    return _xsltc.registerNamespace(name);
  +             return (name.toString().equals("*")) ? -1
  +                 : _xsltc.registerNamespace(name);
               }
   
  -            if (name.getPrefix() == null || name.getNamespace() == null) {
  -                final String local = name.getLocalPart();
  -             if (local.equals("*")) {
  -                    if (axis == Axis.ATTRIBUTE)
  -                        return(NodeTest.ATTRIBUTE);
  -                    else
  -                        return(NodeTest.ELEMENT);
  -                }
  -                else if (local.equals("@*"))
  -                    return(NodeTest.ATTRIBUTE);
  -                name = new QName(null,null,local);
  -            }
  -            if (axis == Axis.ATTRIBUTE) {
  -                return _xsltc.registerAttribute(name);
  -            }
  -            else {
  -             return _xsltc.registerElement(name);
  -            }
  +         if (name.getNamespace() == null) {
  +             final String local = name.getLocalPart();
  +
  +             if (local.equals("*")) {
  +                 return (axis == Axis.ATTRIBUTE) ? NodeTest.ATTRIBUTE
  +                     : NodeTest.ELEMENT;
  +             }
  +             else if (local.equals("@*")) {
  +                 return NodeTest.ATTRIBUTE;
  +             }
  +         }
  +
  +         return (axis == Axis.ATTRIBUTE) ? _xsltc.registerAttribute(name)
  +             : _xsltc.registerElement(name); 
           }
       }
   
  @@ -942,19 +928,11 @@
   
   FunctionName ::= QName:fname
           {: 
  -         final String prefix = fname.getPrefix();
  -         if (prefix == null || prefix.equals(Constants.EMPTYSTRING)) {
  -             fname = parser.getQNameIgnoreDefaultNs(fname.getLocalPart());
  -         }
            RESULT = fname; 
        :};
   
   VariableName ::= QName:vname
           {: 
  -         final String prefix = vname.getPrefix();
  -         if (prefix == null || prefix.equals(Constants.EMPTYSTRING)) {
  -             vname = parser.getQNameIgnoreDefaultNs(vname.getLocalPart());
  -         }
            RESULT = vname; 
        :};
   
  @@ -994,7 +972,7 @@
                {: RESULT = qn; :};
   
   QName ::= QNAME:qname
  -        {: RESULT = parser.getQName(qname); :}
  +        {: RESULT = parser.getQNameIgnoreDefaultNs(qname); :}
   
        | DIV
           {: RESULT = parser.getQNameIgnoreDefaultNs("div"); :}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.6.3  +1 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java
  
  Index: ResultTreeType.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java,v
  retrieving revision 1.10.6.2
  retrieving revision 1.10.6.3
  diff -u -r1.10.6.2 -r1.10.6.3
  --- ResultTreeType.java       1 Aug 2002 19:55:31 -0000       1.10.6.2
  +++ ResultTreeType.java       12 Sep 2002 16:07:34 -0000      1.10.6.3
  @@ -446,7 +446,6 @@
            il.append(NOP);
        }
        else {
  -System.out.println("ResultTreeType.translateTo()");
            ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
                                        toString(), className);
            classGen.getParser().reportError(Constants.FATAL, err);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.68.2.5  +24 -19    
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.68.2.4
  retrieving revision 1.68.2.5
  diff -u -r1.68.2.4 -r1.68.2.5
  --- DOMImpl.java      24 Aug 2002 11:33:31 -0000      1.68.2.4
  +++ DOMImpl.java      12 Sep 2002 16:07:35 -0000      1.68.2.5
  @@ -2346,7 +2346,6 @@
            _currentOffset += length;
   
            _disableEscaping = !_escaping;      
  -
        }
   
   
  @@ -2362,13 +2361,11 @@
            _currentAttributeNode = 1;
            _type2[0] = DTM.NAMESPACE_NODE;
   
  -         startPrefixMapping(EMPTYSTRING, EMPTYSTRING);
  -
  +         definePrefixAndUri(EMPTYSTRING, EMPTYSTRING);
            startPrefixMapping(XML_PREFIX, 
"http://www.w3.org/XML/1998/namespace";);
            _lengthOrAttr[DTMDefaultBase.ROOTNODE] = _nextNamespace;
            _parent2[_nextNamespace] = DTMDefaultBase.ROOTNODE;
            _nextNamespace = DTM.NULL;
  -
        }
   
        /**
  @@ -2438,9 +2435,9 @@
         */
           public void startElement(String uri, String localName,
                                 String qname, Attributes attributes)
  -         throws SAXException {
  -
  -            makeTextNode(false);
  +         throws SAXException 
  +     {
  +         makeTextNode(false);
   
               // Get node index and setup parent/child references
               final int node = nextNode();
  @@ -2553,8 +2550,25 @@
         * SAX2: Begin the scope of a prefix-URI Namespace mapping.
         */
        public void startPrefixMapping(String prefix, String uri) 
  -         throws SAXException {
  +         throws SAXException 
  +     {
  +         final Stack stack = definePrefixAndUri(prefix, uri);
   
  +         makeTextNode(false);
  +         int attr = makeNamespaceNode(prefix, uri);
  +         if (_nextNamespace == DTM.NULL) {
  +             _nextNamespace = attr;
  +         }
  +         else {
  +             _nextSibling2[attr-1] = attr;
  +         }
  +         _nextSibling2[attr] = DTM.NULL;
  +         _prefix2[attr] = ((Integer) stack.elementAt(0)).shortValue();
  +     }
  +
  +     private Stack definePrefixAndUri(String prefix, String uri) 
  +         throws SAXException 
  +     {
               // Get the stack associated with this namespace prefix
               Stack stack = (Stack)_nsPrefixes.get(prefix);
               if (stack == null) {
  @@ -2573,16 +2587,7 @@
               }
               stack.push(uri);
   
  -            if (!prefix.equals(EMPTYSTRING) || !uri.equals(EMPTYSTRING)) {
  -                makeTextNode(false);
  -                int attr = makeNamespaceNode(prefix, uri);
  -                if (_nextNamespace == DTM.NULL)
  -                    _nextNamespace = attr;
  -                else
  -                    _nextSibling2[attr-1] = attr;
  -                _nextSibling2[attr] = DTM.NULL;
  -             _prefix2[attr] = ((Integer) stack.elementAt(0)).shortValue();
  -         }
  +            return stack;
           }
   
           /**
  
  
  
  1.6.10.2  +14 -6     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeCounter.java
  
  Index: NodeCounter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeCounter.java,v
  retrieving revision 1.6.10.1
  retrieving revision 1.6.10.2
  diff -u -r1.6.10.1 -r1.6.10.2
  --- NodeCounter.java  17 Apr 2002 18:13:44 -0000      1.6.10.1
  +++ NodeCounter.java  12 Sep 2002 16:07:35 -0000      1.6.10.2
  @@ -292,8 +292,8 @@
        * lang="en".
        */
       private void formatValue(int value, String format, StringBuffer buffer) {
  -
           char c = format.charAt(0);
  +
           if (Character.isDigit(c)) {
               char zero = (char)(c - Character.getNumericValue(c));
   
  @@ -329,10 +329,18 @@
               buffer.append(romanValue(value).toUpperCase());
           } 
        else {
  -            int min = (int) c;
  -            int max = (int) c;
  -            while (Character.isLetterOrDigit((char) (max+1))) {
  -             max++;
  +         int min = (int) c;
  +         int max = (int) c;
  +
  +         // Special case for Greek alphabet 
  +         if (c >= 0x3b1 && c <= 0x3c9) {
  +             max = 0x3c9;    // omega
  +         }
  +         else {
  +             // General case: search for end of group
  +             while (Character.isLetterOrDigit((char) (max + 1))) {
  +                 max++;
  +             }
            }
               buffer.append(alphaValue(value, min, max));
           }
  
  
  
  1.1.2.6   +49 -98    
xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
  
  Index: SAXImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- SAXImpl.java      24 Aug 2002 11:33:38 -0000      1.1.2.5
  +++ SAXImpl.java      12 Sep 2002 16:07:35 -0000      1.1.2.6
  @@ -2348,7 +2348,7 @@
            _currentAttributeNode = 1;
            _type2[0] = DTM.NAMESPACE_NODE;
   
  -         startPrefixMapping(EMPTYSTRING, EMPTYSTRING);
  +         definePrefixAndUri(EMPTYSTRING, EMPTYSTRING);
            startPrefixMapping(XML_PREFIX, 
"http://www.w3.org/XML/1998/namespace";);
   //       _lengthOrAttr[DTMDefaultBase.ROOTNODE] = _nextNamespace;
   //       _parent2[_nextNamespace] = DTMDefaultBase.ROOTNODE;
  @@ -2464,16 +2464,13 @@
         */
        public void endElement(String namespaceURI, String localName,
                               String qname) throws SAXException
  -  {
  -
  -        SAXImpl.this.endElement(namespaceURI, localName, qname);
  +        {
  +            SAXImpl.this.endElement(namespaceURI, localName, qname);
            makeTextNode(false);
   
            // Revert to strip/preserve-space setting from before this element
  -       // use m_parent??
  +            // use m_parent??
            xmlSpaceRevert(_parentStack[_sp]);
  -         //_previousSiblingStack[_sp--] = 0;
  -       // SAXImpl.this.endElement(namespaceURI, localName, qname);
        }
   
        /**
  @@ -2481,17 +2478,10 @@
         */
        public void processingInstruction(String target, String data)
            throws SAXException
  -  {
  -        SAXImpl.this.processingInstruction(target, data);
  +        {
  +            SAXImpl.this.processingInstruction(target, data);
            final int node = makeTextNode(false);
   
  -         //final int node = nextNode();
  -         //_type[node] =
  -       //_types.put(new Integer(getExpandedTypeID(node)), new 
Integer(DTM.PROCESSING_INSTRUCTION_NODE));
  -         //linkChildren(node);
  -         //characters(target);
  -         //characters(" ");
  -         //characters(data);
            storeTextRef(node);
        }
   
  @@ -2499,25 +2489,20 @@
         * SAX2: Receive notification of ignorable whitespace in element
         * content. Similar to characters(char[], int, int).
         */
  -     public void ignorableWhitespace(char[] ch, int start, int length) 
throws SAXException
  -  {
  -        SAXImpl.this.ignorableWhitespace(ch, start, length);
  -  /*  if (_currentOffset + length > _text.length)
  -    {
  -      resizeTextArray(_text.length * 2);
  -    }
  -    System.arraycopy(ch, start, _text, _currentOffset, length);
  -  */_currentOffset += length;
  -    makeTextNode(true);
  -  }
  +     public void ignorableWhitespace(char[] ch, int start, int length)
  +            throws SAXException
  +        {
  +            SAXImpl.this.ignorableWhitespace(ch, start, length);
  +            makeTextNode(true);
  +        }
   
        /**
         * SAX2: Receive an object for locating the origin of SAX document
         * events.
         */
        public void setDocumentLocator(Locator locator)
  -  {
  -        SAXImpl.this.setDocumentLocator(locator);
  +        {
  +            SAXImpl.this.setDocumentLocator(locator);
            // Not handled
        }
   
  @@ -2525,7 +2510,7 @@
         * SAX2: Receive notification of a skipped entity.
         */
        public void skippedEntity(String name)
  -  {
  +        {
            // Not handled
        }
   
  @@ -2534,69 +2519,42 @@
         */
        public void startPrefixMapping(String prefix, String uri)
            throws SAXException
  -  {
  -     if (!prefix.equals(EMPTYSTRING) && !uri.equals(EMPTYSTRING))
  -     SAXImpl.this.startPrefixMapping(prefix, uri);
  -    // Get the stack associated with this namespace prefix
  -   /* Stack stack = (Stack)_nsPrefixes.get(prefix);
  -    if (stack == null)
  -    {
  -      stack = new Stack();
  -      stack.push(new Integer(_prefixCount++));
  -      _nsPrefixes.put(prefix, stack);
  -    }*/
  -
  -    // Check if the URI already exists before pushing on stack
  -        Integer eType = new Integer(getIdForNamespace(uri));
  -                             //getExpandedTypeID(null, prefix, 
DTM.NAMESPACE_NODE));
  -    Integer idx;
  -    if ((idx = (Integer)_nsIndex.get(eType)) == null)
  -    {
  -      _nsIndex.put(eType, idx = new Integer(_uriCount++));
  -    }
  -    //stack.push(uri);
  +        {
  +            SAXImpl.this.startPrefixMapping(prefix, uri);
  +            definePrefixAndUri(prefix, uri);
   
  -    if (!prefix.equals(EMPTYSTRING) || !uri.equals(EMPTYSTRING)) {
  -      makeTextNode(false);
  -      int attr = makeNamespaceNode(prefix, uri);
  -      //if (_nextNamespace == DTM.NULL)
  -      //  _nextNamespace = attr;
  -      //else
  -      //  _nextSibling2[attr-1] = attr;
  -     // _nextSibling2[attr] = DTM.NULL;
  -     // _prefix2[attr] = idx.shortValue();
  -    }
  -  }
  +            makeTextNode(false);
  +            int attr = makeNamespaceNode(prefix, uri);
  +        }
   
  -  /**
  -   * SAX2: End the scope of a prefix-URI Namespace mapping.
  -   */
  -  public void endPrefixMapping(String prefix) throws SAXException
  -  {
  -      SAXImpl.this.endPrefixMapping(prefix);
  -    // Get the stack associated with this namespace prefix
  -   // final Stack stack = (Stack)_nsPrefixes.get(prefix);
  -   // if ((stack != null) && (!stack.empty())) stack.pop();
  -  }
  +     private void definePrefixAndUri(String prefix, String uri) 
  +         throws SAXException 
  +     {
  +            // Check if the URI already exists before pushing on stack
  +            Integer eType = new Integer(getIdForNamespace(uri));
  +            if ((Integer)_nsIndex.get(eType) == null) {
  +                _nsIndex.put(eType, new Integer(_uriCount++));
  +            }
  +     }
  + 
  +        /**
  +         * SAX2: End the scope of a prefix-URI Namespace mapping.
  +         */
  +        public void endPrefixMapping(String prefix) throws SAXException
  +        {
  +            SAXImpl.this.endPrefixMapping(prefix);
  +        }
   
        /**
         * SAX2: Report an XML comment anywhere in the document.
         */
  -     public void comment(char[] ch, int start, int length) throws 
SAXException
  -  {
  -        //SAXImpl.this.comment(ch, start, length);
  -    makeTextNode(false);
  -    SAXImpl.this.comment(ch, start, length);
  - /*   if (_currentOffset + length > _text.length)
  -    {
  -      resizeTextArray(_text.length * 2);
  -    }
  -    System.arraycopy(ch, start, _text, _currentOffset, length);
  -*/  _currentOffset += length;
  -    final int node = makeTextNode(false);
  -    //_type[node] =
  -     //_types.put(new Integer(getExpandedTypeID(node)), new 
Integer(DTM.COMMENT_NODE));
  -  }
  +     public void comment(char[] ch, int start, int length)
  +            throws SAXException
  +        {
  +            makeTextNode(false);
  +            SAXImpl.this.comment(ch, start, length);
  +            final int node = makeTextNode(false);
  +        }
   
        /**
         * SAX2: Ignored events
  @@ -2656,18 +2614,11 @@
         * method takes a string as its only parameter. The effect is the same.
         */
        private void characters(final String string)
  -  {
  -    final int length = string.length();
  - /*   if (_currentOffset + length > _text.length) {
  -             // GTM: resizeTextArray(_text.length * 2);
  -             // bug fix 6189, contributed by Mirko Seifert
  -             resizeTextArray(
  -                 Math.max(_text.length * 2, _currentOffset + length));
  -         }
  -         string.getChars(0, length, _text, _currentOffset);
  -*/   _currentOffset += length;
  +        {
  +            final int length = string.length();
  +            _currentOffset += length;
       
  -  }
  +        }
   
        private void resizeArrays(final int newSize, int length)
     {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.33.2.4  +2 -51     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.33.2.3
  retrieving revision 1.33.2.4
  diff -u -r1.33.2.3 -r1.33.2.4
  --- AbstractTranslet.java     24 Aug 2002 11:33:16 -0000      1.33.2.3
  +++ AbstractTranslet.java     12 Sep 2002 16:07:35 -0000      1.33.2.4
  @@ -117,9 +117,6 @@
       public void printInternalState() {
        System.out.println("-------------------------------------");
        System.out.println("AbstractTranslet this = " + this);
  -     System.out.println("vbase = " + vbase);
  -     System.out.println("vframe = " + vframe);
  -     System.out.println("varsStack.size() = " + varsStack.size());
        System.out.println("pbase = " + pbase);
        System.out.println("vframe = " + pframe);
        System.out.println("paramsStack.size() = " + paramsStack.size());
  @@ -145,14 +142,9 @@
       }
   
       /************************************************************************
  -     * Variable and parameter handling
  +     * Parameter handling
        
************************************************************************/
   
  -    // Variable's stack: <tt>vbase</tt> and <tt>vframe</tt> are used 
  -    // to denote the current variable frame.
  -    protected int vbase = 0, vframe = 0;
  -    protected ArrayList varsStack = new ArrayList();
  -
       // Parameter's stack: <tt>pbase</tt> and <tt>pframe</tt> are used 
       // to denote the current parameter frame.
       protected int pbase = 0, pframe = 0;
  @@ -236,47 +228,6 @@
            if (param._name.equals(name)) return param._value;
        }
        return null;
  -    }
  -
  -    /**
  -     * Push a new variable frame.
  -     */
  -    public final void pushVarFrame(int frameSize) {
  -     varsStack.add(vframe, new Integer(vbase));
  -     vbase = ++vframe;
  -     vframe += frameSize;
  -
  -     // Clear stack frame
  -     for (int i = vbase; i <= vframe + 1; i++) {
  -         varsStack.add(i, null);
  -     }
  -    }
  -
  -    /**
  -     * Pop the topmost variable frame.
  -     */
  -    public final void popVarFrame() {
  -     if (vbase > 0) {
  -         final int oldvbase = ((Integer)varsStack.get(--vbase)).intValue();
  -         for (int i = vbase; i < vframe; i++) {
  -             varsStack.set(i, null);         // for the GC
  -         }
  -         vframe = vbase; vbase = oldvbase;
  -     }
  -    }
  -
  -    /**
  -     * Get the value of a variable given its index.
  -     */
  -    public final Object getVariable(int vindex) {
  -     return varsStack.get(vbase + vindex);
  -    }
  -     
  -    /**
  -     * Set the value of a variable in the current frame.
  -     */
  -    public final void addVariable(int vindex, Object value) {
  -     varsStack.set(vbase + vindex, value);
       }
   
       /************************************************************************
  
  
  
  1.35.2.5  +14 -48    
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
  
  Index: BasisLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
  retrieving revision 1.35.2.4
  retrieving revision 1.35.2.5
  diff -u -r1.35.2.4 -r1.35.2.5
  --- BasisLibrary.java 24 Aug 2002 12:39:06 -0000      1.35.2.4
  +++ BasisLibrary.java 12 Sep 2002 16:07:35 -0000      1.35.2.5
  @@ -523,7 +523,7 @@
        * Utility function: node-set/node-set compare. 
        */
       public static boolean compare(DTMAxisIterator left, DTMAxisIterator 
right,
  -                               int op, int node, DOM dom) {
  +                               int op, DOM dom) {
        int lnode;
        left.reset();
        
  @@ -541,24 +541,8 @@
        return false;
       }
   
  -    /**
  -     * Utility function: node/node-set compare.
  -     */
  -    public static boolean compare(int node, DTMAxisIterator nodeSet,
  -                               int op, DOM dom) {
  -     final String lvalue = dom.getNodeValue(node);
  -     int rnode;
  -     //nodeSet.reset();
  -     while ((rnode = nodeSet.next()) != DTMAxisIterator.END) {
  -         if (compareStrings(lvalue, dom.getNodeValue(rnode), op, dom)) {
  -             return true;
  -         }
  -     } 
  -     return false;
  -    }
  -
       public static boolean compare(int node, DTMAxisIterator iterator,
  -                               int op, int dummy, DOM dom) {
  +                               int op, DOM dom) {
        //iterator.reset();
   
        int rnode;
  @@ -566,41 +550,33 @@
   
        switch(op) {
        case EQ:
  -         /* TODO:
  -          * This needs figuring out: What sort of comparison is done here?
  -          * Are we comparing exact node id's, node types, or node values?
  -          * Values is the obvious for attributes, but what about elements?
  -          */
            value = dom.getNodeValue(node);
  -         while ((rnode = iterator.next()) != DTMAxisIterator.END)
  +         while ((rnode = iterator.next()) != DTMAxisIterator.END) {
                if (value.equals(dom.getNodeValue(rnode))) return true;
  -         // if (rnode == node) return true; It just ain't that easy!!!
  +         }
            break;
        case NE:
            value = dom.getNodeValue(node);
  -         while ((rnode = iterator.next()) != DTMAxisIterator.END)
  +         while ((rnode = iterator.next()) != DTMAxisIterator.END) {
                if (!value.equals(dom.getNodeValue(rnode))) return true;
  -         // if (rnode != node) return true;
  +         }
            break;
        case LT:
            // Assume we're comparing document order here
  -         while ((rnode = iterator.next()) != DTMAxisIterator.END)
  +         while ((rnode = iterator.next()) != DTMAxisIterator.END) {
                if (rnode > node) return true;
  +         }
            break;
        case GT:
            // Assume we're comparing document order here
  -         while ((rnode = iterator.next()) != DTMAxisIterator.END)
  +         while ((rnode = iterator.next()) != DTMAxisIterator.END) {
                if (rnode < node) return true;
  +         }
            break;
        } 
        return(false);
       }
   
  -    public static boolean compare(DTMAxisIterator left, final double rnumber,
  -                               final int op, final int node, DOM dom) {
  -     return(compare(left,rnumber,op,dom));
  -    }
  -
       /**
        * Utility function: node-set/number compare.
        */
  @@ -674,19 +650,10 @@
        return false;
       }
   
  -    public static boolean compare(DTMAxisIterator left, final String rstring,
  -                               int op, int node, DOM dom) {
  -     
  -     if (compareStrings(dom.getNodeValue(node), rstring, op, dom)) {
  -         return true;
  -     }
  -     else {
  -         return false;
  -     }
  -    }
   
       public static boolean compare(Object left, Object right,
  -                               int op, int node, DOM dom) { 
  +                               int op, DOM dom) 
  +    { 
        boolean result = false;
        boolean hasSimpleArgs = hasSimpleType(left) && hasSimpleType(right);
   
  @@ -784,10 +751,9 @@
            DTMAxisIterator iter = ((DTMAxisIterator)left).reset();
   
            if (right instanceof DTMAxisIterator) {
  -             result = compare(iter, (DTMAxisIterator)right, op, node, dom);
  +             result = compare(iter, (NodeIterator)right, op, dom);
            }
            else if (right instanceof String) {
  -             //result = compare(iter, (String)right, op, node, dom);
                result = compare(iter, (String)right, op, dom);
            }   
            else if (right instanceof Number) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.10.1  +81 -3     
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TrAXFilter.java
  
  Index: TrAXFilter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TrAXFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.1.10.1
  diff -u -r1.1 -r1.1.10.1
  --- TrAXFilter.java   26 Jun 2001 17:19:58 -0000      1.1
  +++ TrAXFilter.java   12 Sep 2002 16:07:36 -0000      1.1.10.1
  @@ -56,6 +56,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  + * @author Santiago Pericas-Geertsen
    * @author G. Todd Miller 
    *
    */
  @@ -64,18 +65,95 @@
   package org.apache.xalan.xsltc.trax;
   
   import org.xml.sax.XMLFilter;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.XMLReader;
  +import org.xml.sax.InputSource;
   import org.xml.sax.helpers.XMLFilterImpl;
  +import org.xml.sax.helpers.XMLReaderFactory;
  +import org.xml.sax.ContentHandler;
   import javax.xml.transform.Templates;
   import javax.xml.transform.TransformerConfigurationException;
  -
  +import javax.xml.transform.ErrorListener;
  +import javax.xml.transform.Transformer;
  +import javax.xml.transform.sax.TransformerHandler;
  +import javax.xml.transform.sax.SAXResult;
  +import javax.xml.parsers.SAXParserFactory;
  +import javax.xml.parsers.SAXParser;
  +import javax.xml.parsers.ParserConfigurationException;
  +import javax.xml.parsers.FactoryConfigurationError;
  +import java.io.IOException;
   
   /**
    * skeleton extension of XMLFilterImpl for now.  
    */
   public class TrAXFilter extends XMLFilterImpl {
  +    private Templates              _templates;
  +    private TransformerHandlerImpl _transformer;
  +
       public TrAXFilter(Templates templates)  throws 
        TransformerConfigurationException
       {
  -     /* nothing yet */ 
  +     _templates = templates;
  +        _transformer = new TransformerHandlerImpl( 
  +             (TransformerImpl) templates.newTransformer());
       }
  +
  +    private void createParent() throws SAXException {
  +     XMLReader parent = null;
  +        try {
  +            SAXParserFactory pfactory = SAXParserFactory.newInstance();
  +            pfactory.setNamespaceAware(true);
  +            SAXParser saxparser = pfactory.newSAXParser();
  +            parent = saxparser.getXMLReader();
  +        }
  +        catch (ParserConfigurationException e) {
  +            throw new SAXException(e);
  +        }
  +        catch (FactoryConfigurationError e) {
  +            throw new SAXException(e.toString());
  +        }
  +
  +        if (parent == null) {
  +            parent = XMLReaderFactory.createXMLReader();
  +        }
  +
  +        // make this XMLReader the parent of this filter
  +        setParent(parent);
  +    }
  +
  +    public void parse (InputSource input) throws SAXException, IOException
  +    {
  +     if (getParent() == null) {
  +             try {
  +                 createParent();
  +             }
  +                catch (SAXException  e) {
  +                    throw new SAXException(e.toString());
  +                }
  +     }
  +
  +     // call parse on the parent     
  +     getParent().parse(input);
  +    }
  +
  +    public void parse (String systemId) throws SAXException, IOException 
  +    {
  +        parse(new InputSource(systemId));
  +    }
  +
  +    public void setContentHandler (ContentHandler handler) 
  +    {
  +     _transformer.setResult(new SAXResult(handler));
  +     if (getParent() == null) {
  +                try {
  +                    createParent();
  +                }
  +                catch (SAXException  e) {
  +                   return; 
  +                }
  +     }
  +     getParent().setContentHandler(_transformer);
  +    }
  +
  +    public void setErrorListener (ErrorListener handler) { }
   }
  
  
  
  1.6.10.6  +24 -12    
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerHandlerImpl.java
  
  Index: TransformerHandlerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerHandlerImpl.java,v
  retrieving revision 1.6.10.5
  retrieving revision 1.6.10.6
  diff -u -r1.6.10.5 -r1.6.10.6
  --- TransformerHandlerImpl.java       24 Aug 2002 11:33:16 -0000      1.6.10.5
  +++ TransformerHandlerImpl.java       12 Sep 2002 16:07:36 -0000      1.6.10.6
  @@ -109,7 +109,7 @@
       /**
        * Cosntructor - pass in reference to a TransformerImpl object
        */
  -    protected TransformerHandlerImpl(TransformerImpl transformer) {
  +    public TransformerHandlerImpl(TransformerImpl transformer) {
        // Save the reference to the transformer
        _transformer = transformer;
   
  @@ -171,10 +171,9 @@
                    _transformer.getOutputHandler(result);
                _transformer.transferOutputProperties(outputHandler);
   
  -             _handler = new SAX2TO(outputHandler);
  -             _lexHandler = (LexicalHandler) _handler;
  -             _dtdHandler = (DTDHandler) _handler;
  -             _declHandler = (DeclHandler) _handler;
  +                SAX2TO saxToOutputHandler = new SAX2TO(outputHandler);
  +             _handler = saxToOutputHandler;
  +             _lexHandler = saxToOutputHandler;
            }
            catch (TransformerException e) {
                _result = null;
  @@ -419,7 +418,10 @@
       public void unparsedEntityDecl(String name, String publicId, 
        String systemId, String notationName) throws SAXException 
       {
  -     _dtdHandler.unparsedEntityDecl(name, publicId, systemId, notationName);
  +        if (_dtdHandler != null) {
  +         _dtdHandler.unparsedEntityDecl(name, publicId, systemId,
  +                                           notationName);
  +        }
       }
   
       /**
  @@ -428,7 +430,9 @@
       public void notationDecl(String name, String publicId, String systemId) 
        throws SAXException
       {
  -     _dtdHandler.notationDecl(name, publicId, systemId);
  +        if (_dtdHandler != null) {
  +         _dtdHandler.notationDecl(name, publicId, systemId);
  +        }
       }
   
       /**
  @@ -437,7 +441,9 @@
       public void attributeDecl(String eName, String aName, String type, 
        String valueDefault, String value) throws SAXException 
       {
  -     _declHandler.attributeDecl(eName, aName, type, valueDefault, value);
  +        if (_declHandler != null) {
  +         _declHandler.attributeDecl(eName, aName, type, valueDefault, value);
  +        }
       }
   
       /**
  @@ -446,7 +452,9 @@
       public void elementDecl(String name, String model) 
        throws SAXException
       {
  -     _declHandler.elementDecl(name, model);
  +        if (_declHandler != null) {
  +         _declHandler.elementDecl(name, model);
  +        }
       }
   
       /**
  @@ -455,7 +463,9 @@
       public void externalEntityDecl(String name, String publicId, String 
systemId) 
        throws SAXException
       {
  -     _declHandler.externalEntityDecl(name, publicId, systemId);
  +        if (_declHandler != null) {
  +         _declHandler.externalEntityDecl(name, publicId, systemId);
  +        }
       }
   
       /**
  @@ -464,6 +474,8 @@
       public void internalEntityDecl(String name, String value) 
        throws SAXException
       {
  -     _declHandler.internalEntityDecl(name, value);
  +        if (_declHandler != null) {
  +         _declHandler.internalEntityDecl(name, value);
  +        }
       }
   }
  
  
  
  1.37.2.5  +32 -7     
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
  retrieving revision 1.37.2.4
  retrieving revision 1.37.2.5
  diff -u -r1.37.2.4 -r1.37.2.5
  --- TransformerImpl.java      24 Aug 2002 11:33:16 -0000      1.37.2.4
  +++ TransformerImpl.java      12 Sep 2002 16:07:36 -0000      1.37.2.5
  @@ -180,6 +180,13 @@
        */
       private boolean _isIdentity = false;
   
  +    /**
  +     * A hashtable to store parameters for the identity transform. These
  +     * are not needed during the transformation, but we must keep track of 
  +     * them to be fully complaint with the JAXP API.
  +     */
  +    private Hashtable _parameters = null;
  +
       protected TransformerImpl(Properties outputProperties, int indentNumber, 
        TransformerFactoryImpl tfactory) 
       {
  @@ -685,7 +692,7 @@
        *
        * @return Properties in effect for this Transformer
        */
  -    public Properties getOutputProperties() {
  +    public Properties getOutputProperties() { 
        return (Properties) _properties.clone();
       }
   
  @@ -717,7 +724,7 @@
        * @param properties The properties to use for the Transformer
        * @throws IllegalArgumentException Never, errors are ignored
        */
  -    public void setOutputProperties(Properties properties)
  +    public void setOutputProperties(Properties properties) 
        throws IllegalArgumentException 
       {
        if (properties != null) {
  @@ -885,7 +892,7 @@
   
        // Call setDoctype() if needed
        if (doctypePublic != null || doctypeSystem != null) {
  -         handler.setDoctype(doctypePublic, doctypeSystem);
  +         handler.setDoctype(doctypeSystem, doctypePublic);
        }
       }
   
  @@ -966,7 +973,15 @@
        * @param value The value to assign to the parameter
        */
       public void setParameter(String name, Object value) { 
  -     _translet.addParameter(name, value, false);
  +     if (_isIdentity) {
  +         if (_parameters == null) {
  +             _parameters = new Hashtable();
  +         }
  +         _parameters.put(name, value);
  +     }
  +     else {
  +         _translet.addParameter(name, value, false);
  +     }
       }
   
       /**
  @@ -975,7 +990,12 @@
        * parameter stack.
        */
       public void clearParameters() {  
  -     _translet.clearParameters();
  +     if (_isIdentity && _parameters != null) {
  +         _parameters.clear();
  +     }
  +     else {
  +         _translet.clearParameters();
  +     }
       }
   
       /**
  @@ -987,7 +1007,12 @@
        * @return An object that contains the value assigned to the parameter
        */
       public final Object getParameter(String name) {
  -     return(_translet.getParameter(name));
  +     if (_isIdentity) {
  +         return (_parameters != null) ? _parameters.get(name) : null;
  +     }
  +     else {
  +         return _translet.getParameter(name);
  +     }
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.13.8.2  +10 -0     
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeProxy.java
  
  Index: DTMNodeProxy.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMNodeProxy.java,v
  retrieving revision 1.13.8.1
  retrieving revision 1.13.8.2
  diff -u -r1.13.8.1 -r1.13.8.2
  --- DTMNodeProxy.java 17 Apr 2002 18:13:48 -0000      1.13.8.1
  +++ DTMNodeProxy.java 12 Sep 2002 16:07:36 -0000      1.13.8.2
  @@ -304,6 +304,16 @@
     {
       return dtm.getNodeValue(node);
     }
  +  
  +  /**
  +   * @return The string value of the node
  +   * 
  +   * @throws DOMException
  +   */
  +  public final String getStringValue() throws DOMException
  +  {
  +     return dtm.getStringValue(node).toString();
  +  }
   
     /**
      *
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.1   +3 -0      
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.2.1
  diff -u -r1.6 -r1.6.2.1
  --- SelfIteratorNoPredicate.java      22 Mar 2002 01:04:43 -0000      1.6
  +++ SelfIteratorNoPredicate.java      12 Sep 2002 16:07:36 -0000      1.6.2.1
  @@ -63,6 +63,9 @@
      */
     public int nextNode()
     {
  +    if (m_foundLast)
  +      return DTM.NULL;
  +      
       int next;
       DTM dtm = m_cdtm;
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.2  +69 -0     
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.14.2.1
  retrieving revision 1.14.2.2
  diff -u -r1.14.2.1 -r1.14.2.2
  --- FuncExtFunction.java      29 Jul 2002 00:01:33 -0000      1.14.2.1
  +++ FuncExtFunction.java      12 Sep 2002 16:07:36 -0000      1.14.2.2
  @@ -59,7 +59,10 @@
   import java.util.Vector;
   
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.XPathContext;
  +import org.apache.xpath.XPathVisitor;
   import org.apache.xpath.ExtensionsProvider;
   import org.apache.xpath.objects.*;
   import org.apache.xalan.transformer.TransformerImpl;
  @@ -233,6 +236,72 @@
      * @throws WrongNumberArgsException
      */
     public void checkNumberArgs(int argNum) throws WrongNumberArgsException{}
  +
  +
  +  class ArgExtOwner implements ExpressionOwner
  +  {
  +  
  +    Expression m_exp;
  +     
  +     ArgExtOwner(Expression exp)
  +     {
  +             m_exp = exp;
  +     }
  +     
  +    /**
  +     * @see ExpressionOwner#getExpression()
  +     */
  +    public Expression getExpression()
  +    {
  +      return m_exp;
  +    }
  +
  +
  +    /**
  +     * @see ExpressionOwner#setExpression(Expression)
  +     */
  +    public void setExpression(Expression exp)
  +    {
  +     exp.exprSetParent(FuncExtFunction.this);
  +     m_exp = exp;
  +    }
  +  }
  +  
  +  
  +  /**
  +   * Call the visitors for the function arguments.
  +   */
  +  public void callArgVisitors(XPathVisitor visitor)
  +  {
  +      for (int i = 0; i < m_argVec.size(); i++)
  +      {
  +         Expression exp = (Expression)m_argVec.get(i);
  +         exp.callVisitors(new ArgExtOwner(exp), visitor);
  +      }
  +    
  +  }
  +
  +  /**
  +   * Set the parent node.
  +   * For an extension function, we also need to set the parent
  +   * node for all argument expressions.
  +   * 
  +   * @param n The parent node
  +   */
  +  public void exprSetParent(ExpressionNode n) 
  +  {
  +     
  +    super.exprSetParent(n);
  +      
  +    int nArgs = m_argVec.size();
  +
  +    for (int i = 0; i < nArgs; i++)
  +    {
  +      Expression arg = (Expression) m_argVec.elementAt(i);
  +
  +      arg.exprSetParent(n);
  +    }                
  +  }
   
     /**
      * Constructs and throws a WrongNumberArgException with the appropriate
  
  
  

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

Reply via email to