mkwan       2002/12/12 08:15:17

  Modified:    java/src/org/apache/xalan/lib Tag: xslt20 ExsltCommon.java
                        ExsltDatetime.java ExsltMath.java ExsltSets.java
                        Extensions.java PipeDocument.java Redirect.java
               java/src/org/apache/xalan/lib/sql Tag: xslt20
                        DefaultConnectionPool.java SQLDocument.java
                        XConnection.java
  Added:       java/src/org/apache/xalan/lib Tag: xslt20 ExsltBase.java
                        ExsltDynamic.java ExsltStrings.java
  Log:
  Propagate the extension work to xslt20.
  
  This commit synchronizes all the files under org/apache/xalan/lib with
  files in the main branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.1.2.1 +2 -29     
xml-xalan/java/src/org/apache/xalan/lib/ExsltCommon.java
  
  Index: ExsltCommon.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltCommon.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.1.2.1
  diff -u -r1.4.2.1 -r1.4.2.1.2.1
  --- ExsltCommon.java  14 Aug 2002 19:21:25 -0000      1.4.2.1
  +++ ExsltCommon.java  12 Dec 2002 16:15:15 -0000      1.4.2.1.2.1
  @@ -56,44 +56,17 @@
    */
   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.xml.dtm.DTMIterator;
  -import org.apache.xml.dtm.DTM;
   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.xpath.NodeSet;
   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"/>
    * This class contains EXSLT common extension functions.
    * It is accessed by specifying a namespace URI as follows:
    * <pre>
  - *    xmlns:exslt="http://exslt.org/xalan/common";
  + *    xmlns:exslt="http://exslt.org/common";
    * </pre>
    * 
    * The documentation for each function has been copied from the relevant
  
  
  
  1.2.2.1.2.1 +16 -25    
xml-xalan/java/src/org/apache/xalan/lib/ExsltDatetime.java
  
  Index: ExsltDatetime.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltDatetime.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.1.2.1
  diff -u -r1.2.2.1 -r1.2.2.1.2.1
  --- ExsltDatetime.java        14 Aug 2002 19:21:25 -0000      1.2.2.1
  +++ ExsltDatetime.java        12 Dec 2002 16:15:15 -0000      1.2.2.1.2.1
  @@ -74,7 +74,7 @@
    * This class contains EXSLT dates and times extension functions.
    * It is accessed by specifying a namespace URI as follows:
    * <pre>
  - *    xmlns:math="http://exslt.org/dates-and-times";
  + *    xmlns:datetime="http://exslt.org/dates-and-times";
    * </pre>
    * 
    * The documentation for each function has been copied from the relevant
  @@ -90,9 +90,9 @@
       static final String d = "yyyy-MM-dd";
       static final String gym = "yyyy-MM";
       static final String gy = "yyyy";
  -    static final String gmd = "MM-dd";
  -    static final String gm = "MM";
  -    static final String gd = "dd";
  +    static final String gmd = "--MM-dd";
  +    static final String gm = "--MM--";
  +    static final String gd = "---dd";
       static final String t = "HH:mm:ss";
   
       /**
  @@ -306,7 +306,9 @@
        * The permitted formats are as follows: 
        *    xs:dateTime (CCYY-MM-DDThh:mm:ss) 
        *    xs:date (CCYY-MM-DD) 
  -     *    xs:gYearMonth (CCYY-MM) 
  +     *    xs:gYearMonth (CCYY-MM)
  +     *    xs:gMonth (--MM--) 
  +     *    xs:gMonthDay (--MM-DD)
        * If the date/time string is not in one of these formats, then NaN is 
returned. 
        */
       public static XDouble monthInYear(String datetimeIn)
  @@ -317,7 +319,7 @@
         if (datetime == null)
           return new XDouble(Double.NaN);      
         
  -      String[] formats = {dt, d, gym};
  +      String[] formats = {dt, d, gym, gm, gmd};
         return new XDouble(getNumber(datetime, formats, Calendar.MONTH));
       }
       
  @@ -525,7 +527,7 @@
         if (datetime == null) 
           return new XDouble(Double.NaN);            
         
  -      String[] formats = {d, t};
  +      String[] formats = {dt, t};
         return new XDouble(getNumber(datetime, formats, Calendar.HOUR_OF_DAY));
       }
       
  @@ -821,7 +823,7 @@
         String leader = "";
         String datetime = in;
         String zone = "";
  -      if (in.charAt(0)=='-')
  +      if (in.charAt(0)=='-' && !in.startsWith("--"))
         {
           leader = "-"; //  '+' is implicit , not allowed
           datetime = in.substring(1);
  @@ -847,13 +849,11 @@
       private static int getZoneStart (String datetime)
       {
         if (datetime.indexOf("Z") == datetime.length()-1)
  -        return datetime.indexOf("Z");
  -      else if (
  -               (datetime.lastIndexOf("-") == datetime.length()-6 &&
  -                datetime.charAt(datetime.length()-3) == ':')               
  -                || 
  -                (datetime.indexOf("+") == datetime.length() -6)
  -              )
  +        return datetime.length()-1;
  +      else if (datetime.length() >=6 
  +                     && datetime.charAt(datetime.length()-3) == ':'
  +                     && (datetime.charAt(datetime.length()-6) == '+' 
  +                         || datetime.charAt(datetime.length()-6) == '-'))    
                    
         {
           try
           {
  @@ -874,9 +874,7 @@
       
       /**
        * Attempt to parse an input string with the allowed formats, returning
  -     * null if none of the formats work. Input formats are passed in longest 
to shortest,
  -     * so if any parse operation fails with a parse error in the string, can
  -     * immediately return null.
  +     * null if none of the formats work.
        */
       private static Date testFormats (String in, String[] formats)
         throws ParseException
  @@ -891,8 +889,6 @@
           }
           catch (ParseException pe)
           {
  -          if (pe.getErrorOffset() < in.length())
  -            return null;
           }
         }
         return null;
  @@ -935,11 +931,6 @@
           }
           catch (ParseException pe)
           {
  -          // If ParseException occurred during input string, input is 
invalid.
  -          // If the ParseException occurred at the end of the input string,
  -          // another format may work.
  -          if (pe.getErrorOffset() < in.length())
  -            return "";
           }
         }
         return "";
  
  
  
  1.3.2.1.2.1 +256 -94   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.3.2.1
  retrieving revision 1.3.2.1.2.1
  diff -u -r1.3.2.1 -r1.3.2.1.2.1
  --- ExsltMath.java    14 Aug 2002 19:21:25 -0000      1.3.2.1
  +++ ExsltMath.java    12 Dec 2002 16:15:16 -0000      1.3.2.1.2.1
  @@ -57,35 +57,8 @@
   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.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;
  -import org.apache.xalan.res.XSLTErrorResources;
  -import org.apache.xalan.xslt.EnvironmentCheck;
  -
  -import javax.xml.parsers.*;
   
   /**
    * <meta name="usage" content="general"/>
  @@ -101,44 +74,50 @@
    * @see <a href="http://www.exslt.org/";>EXSLT</a>
   
    */
  -public class ExsltMath
  +public class ExsltMath extends ExsltBase
   {
  +  // 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 
      * in descending order as it would be by xsl:sort with a data type of 
number. The maximum 
      * is the result of converting the string value of the first node in this 
sorted list to 
      * a number using the number function. 
  -   * 
  +   * <p>
      * 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.
  +   * @return 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 double max (NodeList nl)
     {
  -    NodeSet ns = new NodeSet(ni);
  -    Node maxNode = null;
  -    double m = Double.MIN_VALUE;
  -    for (int i = 0; i < ns.getLength(); i++)
  +    if (nl == null || nl.getLength() == 0)
  +      return Double.NaN;
  +      
  +    double m = - Double.MAX_VALUE;
  +    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";
  +        return Double.NaN;
         else if (d > m)
  -      {
           m = d;
  -        maxNode = n;
  -      }
       }
  -    return expCon.toString(maxNode);      
  +     
  +    return m;        
     }
   
     /**
  @@ -147,36 +126,33 @@
      * in ascending order as it would be by xsl:sort with a data type of 
number. The minimum 
      * is the result of converting the string value of the first node in this 
sorted list to 
      * a number using the number function. 
  -   * 
  +   * <p>
      * 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.
  +   * @return 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 double min (NodeList nl)
     {
  -    NodeSet ns = new NodeSet(ni);
  -    Node minNode = null;
  +    if (nl == null || nl.getLength() == 0)
  +      return Double.NaN;
  +
       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";
  +        return Double.NaN;
         else if (d < m)
  -      {
           m = d;
  -        minNode = n;
  -      }
       }
  -    return expCon.toString(minNode);
  +    
  +    return m;
     }
     
     /**
  @@ -185,36 +161,33 @@
      * calculated by math:max. A node has this maximum value if the result of 
converting its 
      * string value to a number as if by the number function is equal to the 
maximum value, 
      * where the equality comparison is defined as a numerical comparison 
using the = operator.
  -   * 
  +   * <p>
      * If any of the nodes in the node set has a non-numeric value, the 
math:max function will 
      * return 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: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 minimum value found, an 
empty node-set
  +   * @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
  -  {    
  -    NodeSet ns = new NodeSet(ni);
  -    NodeIterator niClone = ns.cloneWithReset();
  -    double high = new Double(max(expCon, niClone)).doubleValue();
  +  public static NodeList highest (NodeList nl)
  +  {        
  +    double maxValue = max(nl);
  +
       NodeSet highNodes = new NodeSet();
  -    highNodes.setShouldCache(true);
  +    highNodes.setShouldCache(true);    
       
  -    if (Double.isNaN(high))
  +    if (Double.isNaN(maxValue))
         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); 
  -      if (d == high)
  -      highNodes.addElement(n);
  +      Node n = nl.item(i);
  +      double d = toNumber(n); 
  +      if (d == maxValue)
  +        highNodes.addElement(n);
       }
       return highNodes;
     }
  @@ -225,38 +198,227 @@
      * by math:min. A node has this minimum value if the result of converting 
its string value to 
      * a number as if by the number function is equal to the minimum value, 
where the equality 
      * comparison is defined as a numerical comparison using the = operator.
  -   * 
  +   * <p>
      * If any of the nodes in the node set has a non-numeric value, the 
math:min function will return 
      * 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 maximum value found, an 
empty node-set
  +   * @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 minValue = min(nl);
   
       NodeSet lowNodes = new NodeSet();
       lowNodes.setShouldCache(true);
       
  -    if (Double.isNaN(low))
  +    if (Double.isNaN(minValue))
         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); 
  -      if (d == low)
  -      lowNodes.addElement(n);
  +      Node n = nl.item(i);
  +      double d = toNumber(n); 
  +      if (d == minValue)
  +        lowNodes.addElement(n);
       }
       return lowNodes;
  -  }  
  +  }
  +  
  +  /**
  +   * The math:abs function returns the absolute value of a number.
  +   *
  +   * @param num A number
  +   * @return The absolute value of the number
  +   */
  +   public static double abs(double num)
  +   {
  +     return Math.abs(num);
  +   }
  +
  +  /**
  +   * The math:acos function returns the arccosine value of a number.
  +   *
  +   * @param num A number
  +   * @return The arccosine value of the number
  +   */
  +   public static double acos(double num)
  +   {
  +     return Math.acos(num);
  +   }
  +
  +  /**
  +   * The math:asin function returns the arcsine value of a number. 
  +   *
  +   * @param num A number
  +   * @return The arcsine value of the number
  +   */
  +   public static double asin(double num)
  +   {
  +     return Math.asin(num);
  +   }
  +
  +  /**
  +   * The math:atan function returns the arctangent value of a number. 
  +   *
  +   * @param num A number
  +   * @return The arctangent value of the 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). 
  +   *
  +   * @param num1 The X axis value
  +   * @param num2 The Y axis value
  +   * @return 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. 
  +   *
  +   * @param num A number
  +   * @return The cosine value of the number
  +   */
  +   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. 
  +   *
  +   * @param num A number
  +   * @return The value of e raised to the given power
  +   */
  +   public static double exp(double num)
  +   {
  +     return Math.exp(num);
  +   }
  +
  +  /**
  +   * The math:log function returns the natural logarithm of a number. 
  +   *
  +   * @param num A number
  +   * @return The natural logarithm of the 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. 
  +   *
  +   * @param num1 The base
  +   * @param num2 The power
  +   * @return The value of the base expression taken to the 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. 
  +   *
  +   * @return A random double from 0 to 1
  +   */
  +   public static double random()
  +   {
  +     return Math.random();
  +   }
  +
  +  /**
  +   * The math:sin function returns the sine of the number. 
  +   *
  +   * @param num A number
  +   * @return The sine value of the number
  +   */
  +   public static double sin(double num)
  +   {
  +     return Math.sin(num);
  +   }
  +
  +  /**
  +   * The math:sqrt function returns the square root of a number. 
  +   *
  +   * @param num A number
  +   * @return The square root of the 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. 
  +   *
  +   * @param num A number
  +   * @return The tangent value of the number
  +   */
  +   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:
  +   * <pre>
  +   *  PI
  +   *  E
  +   *  SQRRT2
  +   *  LN2
  +   *  LN10
  +   *  LOG2E
  +   *  SQRT1_2
  +   * </pre>
  +   * @param name The name of the constant
  +   * @param precision The precision
  +   * @return The value of the specified constant to the given precision
  +   */
  +   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.3.2.1.2.1 +97 -83    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.3.2.1
  retrieving revision 1.3.2.1.2.1
  diff -u -r1.3.2.1 -r1.3.2.1.2.1
  --- ExsltSets.java    14 Aug 2002 19:21:25 -0000      1.3.2.1
  +++ ExsltSets.java    12 Dec 2002 16:15:16 -0000      1.3.2.1.2.1
  @@ -57,35 +57,10 @@
   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 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.*;
   
   /**
  @@ -93,7 +68,7 @@
    * This class contains EXSLT set extension functions.
    * It is accessed by specifying a namespace URI as follows:
    * <pre>
  - *    xmlns:set="http://exslt.org/xalan/sets";
  + *    xmlns:set="http://exslt.org/sets";
    * </pre>
    * 
    * The documentation for each function has been copied from the relevant
  @@ -101,7 +76,7 @@
    * 
    * @see <a href="http://www.exslt.org/";>EXSLT</a>
    */
  -public class ExsltSets
  +public class ExsltSets extends ExsltBase
   {   
     /**
      * The set:leading function returns the nodes in the node set passed as 
the first argument that
  @@ -109,29 +84,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)))
  +          && !DOMHelper.isNodeTheSame(testNode, endNode))
           leadNodes.addElement(testNode);
       }
       return leadNodes;
  @@ -143,29 +119,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 noe 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)))
  +          && !DOMHelper.isNodeTheSame(startNode, testNode))
           trailNodes.addElement(testNode);          
       }
       return trailNodes;
  @@ -175,19 +152,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.setShouldCache(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 +183,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.setShouldCache(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 +214,35 @@
      * 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.setShouldCache(true);
  +
  +    Hashtable stringTable = new Hashtable();
  +    
  +    for (int i = 0; i < nl.getLength(); i++)
  +    {
  +      Node currNode = nl.item(i);
  +      String key = toString(currNode);
  +      
  +      if (key == null)
  +        dist.addElement(currNode);
  +      else if (!stringTable.containsKey(key))
  +      {
  +        stringTable.put(key, currNode);
  +        dist.addElement(currNode);           
  +      }
  +    }
  +
  +    return dist;
     }
     
     /**
  @@ -244,11 +258,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.19.2.1.2.1 +64 -133   
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.19.2.1
  retrieving revision 1.19.2.1.2.1
  diff -u -r1.19.2.1 -r1.19.2.1.2.1
  --- Extensions.java   14 Aug 2002 19:21:25 -0000      1.19.2.1
  +++ Extensions.java   12 Dec 2002 16:15:16 -0000      1.19.2.1.2.1
  @@ -67,11 +67,6 @@
   import org.apache.xpath.objects.XObject;
   import org.apache.xpath.objects.XBoolean;
   import org.apache.xpath.objects.XDouble;
  -import org.apache.xpath.XPath;
  -import org.apache.xpath.XPathContext;
  -import org.apache.xml.dtm.DTMIterator;
  -import org.apache.xml.dtm.ref.DTMNodeIterator;
  -import org.apache.xml.utils.XMLString;
   
   import org.xml.sax.SAXNotSupportedException;
   
  @@ -98,6 +93,10 @@
   public class Extensions
   {
   
  +  // Reuse the Document object to reduce memory usage.
  +  private static Document m_doc = null;
  +  private static Extensions m_instance = new Extensions();
  +  
     /**
      * Constructor Extensions
      *
  @@ -179,118 +178,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.setShouldCache(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
  +   * @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
      *
  -   * @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 difference(NodeIterator ni1, NodeIterator ni2)
  -          throws javax.xml.transform.TransformerException
  -  {
  -
  -    NodeSet ns1 = new NodeSet(ni1);
  -    NodeSet ns2 = new NodeSet(ni2);
  -
  -    // NodeSet inter= new NodeSet();
  -    NodeSet diff = new NodeSet();
  -
  -    diff.setShouldCache(true);
  -
  -    for (int i = 0; i < ns1.getLength(); i++)
  +  public static NodeList difference(NodeList nl1, NodeList nl2)
       {
  -      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
  -  {
  -
  -    // Set up our resulting NodeSet and the hashtable we use to keep track 
of duplicate
  -    // strings.
  -
  -    NodeSet dist = new NodeSet();
  -    dist.setShouldCache(true);
  -
  -    Hashtable stringTable = new Hashtable();
  -
  -    Node currNode = ni.nextNode();
  -
  -    while (currNode != null)
  -    {
  -      String key = myContext.toString(currNode);
  -
  -      if (!stringTable.containsKey(key))
  +  public static NodeList distinct(NodeList nl)
         {
  -        stringTable.put(key, currNode);
  -        dist.addElement(currNode);
  -      }
  -      currNode = ni.nextNode();
  -    }
  -
  -    return dist;
  +    return ExsltSets.distinct(nl);
     }
   
     /**
  -   * Returns true of both node-sets contain the same set of nodes.
  -   * @param n1 NodeIterator for first node-set
  +   * Returns true if both node-sets contain the same set of nodes.
      *
  -   * 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;
  @@ -311,41 +256,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, null, 1.0);
  -
  -        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);
     }
   
     /**
  @@ -354,26 +280,28 @@
      * 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.
  -   *
      */
  -  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();
  +      // Lock the instance to ensure thread safety
  +      if (m_doc == null)
  +      {
  +        synchronized (m_instance)
  +        {
  +          if (m_doc == null)
  +            m_doc = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  +        }
  +      }
       }
       catch(ParserConfigurationException pce)
       {
  @@ -383,9 +311,12 @@
       StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
       NodeSet resultSet = new NodeSet();
   
  +    synchronized (m_doc)
  +    {
       while (lTokenizer.hasMoreTokens())
       {
  -      resultSet.addNode(lDoc.createTextNode(lTokenizer.nextToken()));
  +        resultSet.addNode(m_doc.createTextNode(lTokenizer.nextToken()));
  +      }
       }
   
       return resultSet;
  @@ -398,17 +329,17 @@
      * 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.
  -   *
      */
  -  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.14.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.14.1
  diff -u -r1.1 -r1.1.14.1
  --- PipeDocument.java 3 Aug 2001 19:12:52 -0000       1.1
  +++ PipeDocument.java 12 Dec 2002 16:15:16 -0000      1.1.14.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.12.1.2.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.12.1
  retrieving revision 1.16.12.1.2.1
  diff -u -r1.16.12.1 -r1.16.12.1.2.1
  --- Redirect.java     14 Aug 2002 19:21:25 -0000      1.16.12.1
  +++ Redirect.java     12 Dec 2002 16:15:16 -0000      1.16.12.1.2.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.2.4.1   +0 -0      xml-xalan/java/src/org/apache/xalan/lib/ExsltBase.java
  
  Index: ExsltBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltBase.java,v
  retrieving revision 1.2
  retrieving revision 1.2.4.1
  diff -u -r1.2 -r1.2.4.1
  
  
  
  1.7.2.1   +8 -8      xml-xalan/java/src/org/apache/xalan/lib/ExsltDynamic.java
  
  Index: ExsltDynamic.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltDynamic.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- ExsltDynamic.java 5 Nov 2002 18:18:51 -0000       1.7
  +++ ExsltDynamic.java 12 Dec 2002 16:15:16 -0000      1.7.2.1
  @@ -156,7 +156,7 @@
         {
           XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                          xctxt.getNamespaceContext(),
  -                                       XPath.SELECT);
  +                                       XPath.SELECT, null, 1.0);
           result = dynamicXPath.execute(xctxt, contextNode, 
xctxt.getNamespaceContext()).num();
         }
         catch (TransformerException e)
  @@ -237,7 +237,7 @@
         {
           XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                          xctxt.getNamespaceContext(),
  -                                       XPath.SELECT);
  +                                       XPath.SELECT, null, 1.0);
           result = dynamicXPath.execute(xctxt, contextNode, 
xctxt.getNamespaceContext()).num();
         }
         catch (TransformerException e)
  @@ -317,7 +317,7 @@
         {
           XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                          xctxt.getNamespaceContext(),
  -                                       XPath.SELECT);
  +                                       XPath.SELECT, null, 1.0);
           result = dynamicXPath.execute(xctxt, contextNode, 
xctxt.getNamespaceContext()).num();
         }
         catch (TransformerException e)
  @@ -411,7 +411,7 @@
       xctxt.pushContextNodeList(contextNodes);
       
       NodeSet resultSet = new NodeSet();
  -    resultSet.setShouldCacheNodes(true);
  +    resultSet.setShouldCache(true);
       
       for (int i = 0; i < nl.getLength(); i++)
       {
  @@ -423,7 +423,7 @@
         {
           XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                          xctxt.getNamespaceContext(),
  -                                       XPath.SELECT);
  +                                       XPath.SELECT, null, 1.0);
           object = dynamicXPath.execute(xctxt, contextNode, 
xctxt.getNamespaceContext());
           
           if (object instanceof XNodeSet)
  @@ -503,7 +503,7 @@
           xctxt = ((XPathContext.XPathExpressionContext) 
myContext).getXPathContext();
           XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(),
                                          xctxt.getNamespaceContext(),
  -                                       XPath.SELECT);
  +                                       XPath.SELECT, null, 1.0);
   
           return dynamicXPath.execute(xctxt, myContext.getContextNode(),
                                       xctxt.getNamespaceContext());
  @@ -573,7 +573,7 @@
         return new NodeSet();
             
       NodeSet closureSet = new NodeSet();
  -    closureSet.setShouldCacheNodes(true);
  +    closureSet.setShouldCache(true);
           
       NodeList iterationList = nl;
       do
  @@ -594,7 +594,7 @@
           {
             XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                            xctxt.getNamespaceContext(),
  -                                         XPath.SELECT);
  +                                         XPath.SELECT, null, 1.0);
             object = dynamicXPath.execute(xctxt, contextNode, 
xctxt.getNamespaceContext());
             
             if (object instanceof XNodeSet)
  
  
  
  1.9.2.1   +1 -1      xml-xalan/java/src/org/apache/xalan/lib/ExsltStrings.java
  
  Index: ExsltStrings.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltStrings.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- ExsltStrings.java 25 Nov 2002 17:30:30 -0000      1.9
  +++ ExsltStrings.java 12 Dec 2002 16:15:16 -0000      1.9.2.1
  @@ -248,7 +248,7 @@
       }
       
       NodeSet resultSet = new NodeSet();
  -    resultSet.setShouldCacheNodes(true);
  +    resultSet.setShouldCache(true);
       
       boolean done = false;
       int fromIndex = 0;
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.4.1  +31 -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.10
  retrieving revision 1.10.4.1
  diff -u -r1.10 -r1.10.4.1
  --- DefaultConnectionPool.java        7 Jun 2002 17:13:54 -0000       1.10
  +++ DefaultConnectionPool.java        12 Dec 2002 16:15:16 -0000      1.10.4.1
  @@ -63,6 +63,7 @@
   import java.util.Enumeration;
   import java.util.Properties;
   import java.util.Vector;
  +import java.lang.reflect.Method;
   
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xalan.res.XSLTErrorResources;
  @@ -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,36 @@
   
        try
        {
  -       Class.forName( m_driver );
  +        // We need to implement the context classloader
  +        Class cls = null;
  +        try 
  +        {
  +          Method m = Thread.class.getMethod("getContextClassLoader", null);
  +          ClassLoader classLoader = (ClassLoader) 
m.invoke(Thread.currentThread(), null);
  +          cls = classLoader.loadClass(m_driver);
  +        } 
  +        catch (Exception e) 
  +        {
  +          cls = Class.forName(m_driver);  
  +        }
  +        
  +        if (cls == null)
  +          cls = Class.forName(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.14.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.14.1
  diff -u -r1.19 -r1.19.14.1
  --- SQLDocument.java  17 Jan 2002 19:29:38 -0000      1.19
  +++ SQLDocument.java  12 Dec 2002 16:15:16 -0000      1.19.14.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.12.1.2.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.12.1
  retrieving revision 1.23.12.1.2.1
  diff -u -r1.23.12.1 -r1.23.12.1.2.1
  --- XConnection.java  14 Aug 2002 19:21:26 -0000      1.23.12.1
  +++ XConnection.java  12 Dec 2002 16:15:16 -0000      1.23.12.1.2.1
  @@ -83,7 +83,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
  
  
  

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

Reply via email to