mmidy       00/02/29 07:32:20

  Modified:    src/org/apache/xalan/xpath FuncCount.java
               src/org/apache/xalan/xpath/res XPATHErrorResources.java
  Log:
  fix exception if count function  is called without argument
  
  Revision  Changes    Path
  1.4       +4 -1      xml-xalan/src/org/apache/xalan/xpath/FuncCount.java
  
  Index: FuncCount.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/FuncCount.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FuncCount.java    1999/11/28 10:26:14     1.3
  +++ FuncCount.java    2000/02/29 15:32:19     1.4
  @@ -57,6 +57,7 @@
   package org.apache.xalan.xpath; 
   
   import org.w3c.dom.*;
  +import org.apache.xalan.xpath.res.XPATHErrorResources;
   import java.util.Vector;
   
   /**
  @@ -75,7 +76,9 @@
      */
     public XObject execute(XPath path, XPathSupport execContext, Node context, 
int opPos, Vector args) 
       throws org.xml.sax.SAXException
  -  {    
  +  {
  +    if (!(args.size() > 0))
  +      path.error(XPATHErrorResources.ER_COUNT_TAKES_1_ARG);
       NodeList nl = ((XObject)args.elementAt(0)).nodeset();
       return new XNumber((null != nl) ? (double)nl.getLength() : 0.0);
     }
  
  
  
  1.12      +6 -1      
xml-xalan/src/org/apache/xalan/xpath/res/XPATHErrorResources.java
  
  Index: XPATHErrorResources.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/res/XPATHErrorResources.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XPATHErrorResources.java  2000/02/23 20:07:14     1.11
  +++ XPATHErrorResources.java  2000/02/29 15:32:20     1.12
  @@ -19,7 +19,7 @@
   public static final String ERROR_SUFFIX = "ER";  
   public static final String WARNING_SUFFIX = "WR";
   
  -public static final int MAX_CODE = 45;                // this is needed to 
keep track of the number of messages          
  +public static final int MAX_CODE = 46;                // this is needed to 
keep track of the number of messages          
   public static final int MAX_WARNING = 10;             // this is needed to 
keep track of the number of warnings
   public static final int MAX_OTHERS = 20;
   public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING +1;
  @@ -283,6 +283,11 @@
   public static final int ER_KEY_HAS_TOO_MANY_ARGS  = 45;
   static {contents[ER_KEY_HAS_TOO_MANY_ARGS ][1] 
             = "key() has an incorrect number of arguments.";
  +}
  +
  +public static final int ER_COUNT_TAKES_1_ARG  = 46;
  +static {contents[ER_COUNT_TAKES_1_ARG ][1] 
  +          = "The count function should take one argument!";
   }
   
   
  
  
  

Reply via email to