sboag       99/12/13 00:13:47

  Modified:    src/org/apache/xalan/xslt FuncFormatNumb.java
  Log:
  Wrap bad argument exception in SAX exception, for better error reporting and 
error catching.
  
  Revision  Changes    Path
  1.5       +30 -22    xml-xalan/src/org/apache/xalan/xslt/FuncFormatNumb.java
  
  Index: FuncFormatNumb.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/FuncFormatNumb.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FuncFormatNumb.java       1999/11/28 10:26:22     1.4
  +++ FuncFormatNumb.java       1999/12/13 08:13:47     1.5
  @@ -94,30 +94,38 @@
       int nArgs = args.size();
       // this third argument is not a locale name. It is the name of a
       // decimal-format declared in the stylesheet!(xsl:decimal-format 
  -    if(nArgs == 3)
  +    try
       {
  -      String formatStr = ((XObject)args.elementAt(2)).str();
  -      //  Document baseDoc = (Node.DOCUMENT_NODE == context.getNodeType()) ? 
  -      //                       (Document)context : 
context.getOwnerDocument();
  -      
  -      //  if(baseDoc instanceof Stylesheet)
  -      //  {    
  -      dfs = ss.getDecimalFormatElem(formatStr);
  -      //}
  -      if (null == dfs)
  -      {      
  -        // Have to figure out a way to do XPath errors from here.
  -        
path.warn(org.apache.xalan.xpath.res.XPATHErrorResources.WARNING0012, 
  -                  new Object[]{formatStr}); //"not found!!!  
  +      if(nArgs == 3)
  +      {
  +        String formatStr = ((XObject)args.elementAt(2)).str();
  +        //  Document baseDoc = (Node.DOCUMENT_NODE == context.getNodeType()) 
? 
  +        //                       (Document)context : 
context.getOwnerDocument();
  +        
  +        //  if(baseDoc instanceof Stylesheet)
  +        //  {          
  +        dfs = ss.getDecimalFormatElem(formatStr);
  +        //}
  +        if (null == dfs)
  +        {    
  +          // Have to figure out a way to do XPath errors from here.
  +          
path.warn(org.apache.xalan.xpath.res.XPATHErrorResources.WARNING0012, 
  +                    new Object[]{formatStr}); //"not found!!!  
  +          formatter = new java.text.DecimalFormat(patternStr);
  +        }    
  +        else   
  +          formatter = new java.text.DecimalFormat(patternStr, dfs);
  +        // path.warn(XPATHErrorResources.WARNING0001); //"locale name in the 
format-number function not yet handled!");
  +      }
  +      else
           formatter = new java.text.DecimalFormat(patternStr);
  -      }      
  -      else     
  -        formatter = new java.text.DecimalFormat(patternStr, dfs);
  -      // path.warn(XPATHErrorResources.WARNING0001); //"locale name in the 
format-number function not yet handled!");
  -    }
  -    else
  -      formatter = new java.text.DecimalFormat(patternStr);
   
  -    return new XString(formatter.format(num));
  +      return new XString(formatter.format(num));
  +    }
  +    catch(IllegalArgumentException iae)
  +    {
  +      // Myriam: you should call the problem listener here...
  +      throw new XSLProcessorException(iae);
  +    }
     }
   }
  
  
  

Reply via email to