zongaro     2002/09/27 11:59:34

  Modified:    java/src/org/apache/xalan/xsltc/trax
                        TransformerFactoryImpl.java TransformerImpl.java
               java/src/org/apache/xalan/xsltc/compiler/util ErrorMsg.java
                        TypeCheckError.java
               java/src/org/apache/xalan/xsltc/dom DOMImpl.java
                        DTDMonitor.java DocumentCache.java
               java/src/org/apache/xalan/xsltc/runtime BasisLibrary.java
               java/src/org/apache/xalan/xsltc/cmdline/getopt GetOpt.java
               java/src/org/apache/xalan/xsltc/compiler Include.java
                        TransletOutput.java
  Log:
  Committing changes from Gordon Chiu ([EMAIL PROTECTED]), with some tweaks from
  me, to move some hard-coded XSLTC messages into the compiler and run-time
  ErrorMessages classes, as appropriate.
  
  Revision  Changes    Path
  1.49      +23 -11    
xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java
  
  Index: TransformerFactoryImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerFactoryImpl.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- TransformerFactoryImpl.java       25 Sep 2002 20:45:54 -0000      1.48
  +++ TransformerFactoryImpl.java       27 Sep 2002 18:59:33 -0000      1.49
  @@ -651,10 +651,14 @@
       public void error(TransformerException e)
        throws TransformerException 
       {
  -     System.err.println("ERROR: "+e.getMessageAndLocation());
        Throwable wrapped = e.getException();
  -     if (wrapped != null) {
  -         System.err.println("     : "+wrapped.getMessage());
  +        if (wrapped != null) {
  +            System.err.println(new ErrorMsg(ErrorMsg.ERROR_PLUS_WRAPPED_MSG,
  +                                            e.getMessageAndLocation(),
  +                                            wrapped.getMessage()));
  +        } else {
  +            System.err.println(new ErrorMsg(ErrorMsg.ERROR_MSG,
  +                                            e.getMessageAndLocation()));
        }
        throw e;        
       }
  @@ -675,11 +679,15 @@
       public void fatalError(TransformerException e)
        throws TransformerException 
       {
  -     System.err.println("FATAL: "+e.getMessageAndLocation());
        Throwable wrapped = e.getException();
  -     if (wrapped != null) {
  -         System.err.println("     : "+wrapped.getMessage());
  -     }
  +        if (wrapped != null) {
  +            System.err.println(new 
ErrorMsg(ErrorMsg.FATAL_ERR_PLUS_WRAPPED_MSG,
  +                                            e.getMessageAndLocation(),
  +                                            wrapped.getMessage()));
  +        } else {
  +            System.err.println(new ErrorMsg(ErrorMsg.FATAL_ERR_MSG,
  +                                            e.getMessageAndLocation()));
  +        }
        throw e;
       }
   
  @@ -699,11 +707,15 @@
       public void warning(TransformerException e)
        throws TransformerException 
       {
  -     System.err.println("WARNING: "+e.getMessageAndLocation());
        Throwable wrapped = e.getException();
        if (wrapped != null) {
  -         System.err.println("       : "+wrapped.getMessage());
  -     }
  +            System.err.println(new 
ErrorMsg(ErrorMsg.WARNING_PLUS_WRAPPED_MSG,
  +                                            e.getMessageAndLocation(),
  +                                            wrapped.getMessage()));
  +     } else {
  +            System.err.println(new ErrorMsg(ErrorMsg.WARNING_MSG,
  +                                            e.getMessageAndLocation()));
  +        }
       }
   
       /**
  
  
  
  1.58      +30 -14    
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.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- TransformerImpl.java      28 Aug 2002 20:23:22 -0000      1.57
  +++ TransformerImpl.java      27 Sep 2002 18:59:33 -0000      1.58
  @@ -1118,8 +1118,16 @@
       public void error(TransformerException e)
        throws TransformerException 
       {
  -     System.err.println("ERROR: " + e.getMessageAndLocation());
  -     throw(e);       
  +        Throwable wrapped = e.getException();
  +        if (wrapped != null) {
  +            System.err.println(new ErrorMsg(ErrorMsg.ERROR_PLUS_WRAPPED_MSG,
  +                                            e.getMessageAndLocation(),
  +                                            wrapped.getMessage()));
  +        } else {
  +            System.err.println(new ErrorMsg(ErrorMsg.ERROR_MSG,
  +                                            e.getMessageAndLocation()));
  +        }
  +        throw e;
       }
   
       /**
  @@ -1138,12 +1146,16 @@
       public void fatalError(TransformerException e)
        throws TransformerException 
       {
  -     System.err.println("FATAL: " + e.getMessageAndLocation());
  -     Throwable wrapped = e.getException();
  -     if (wrapped != null) {
  -         System.err.println("     : "+wrapped.getMessage());
  -     }
  -     throw(e);
  +        Throwable wrapped = e.getException();
  +        if (wrapped != null) {
  +            System.err.println(new 
ErrorMsg(ErrorMsg.FATAL_ERR_PLUS_WRAPPED_MSG,
  +                                            e.getMessageAndLocation(),
  +                                            wrapped.getMessage()));
  +        } else {
  +            System.err.println(new ErrorMsg(ErrorMsg.FATAL_ERR_MSG,
  +                                            e.getMessageAndLocation()));
  +        }
  +        throw e;
       }
   
       /**
  @@ -1162,11 +1174,15 @@
       public void warning(TransformerException e)
        throws TransformerException 
       {
  -     System.err.println("WARNING: " + e.getMessageAndLocation());
  -     Throwable wrapped = e.getException();
  -     if (wrapped != null) {
  -         System.err.println("       : "+wrapped.getMessage());
  -     }
  +        Throwable wrapped = e.getException();
  +        if (wrapped != null) {
  +            System.err.println(new 
ErrorMsg(ErrorMsg.WARNING_PLUS_WRAPPED_MSG,
  +                                            e.getMessageAndLocation(),
  +                                            wrapped.getMessage()));
  +        } else {
  +            System.err.println(new ErrorMsg(ErrorMsg.WARNING_MSG,
  +                                            e.getMessageAndLocation()));
  +        }
       }
   
   }
  
  
  
  1.15      +17 -6     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java
  
  Index: ErrorMsg.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ErrorMsg.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ErrorMsg.java     25 Jul 2002 11:44:19 -0000      1.14
  +++ ErrorMsg.java     27 Sep 2002 18:59:33 -0000      1.15
  @@ -163,11 +163,22 @@
       public static final int TRANSFORM_USAGE_STR     = 73;
   
       // Recently added error messages
  -    public static final int STRAY_SORT_ERR          = 74;
  -    public static final int UNSUPPORTED_ENCODING    = 75;
  -    public static final int SYNTAX_ERR              = 76;
  -    public static final int CONSTRUCTOR_NOT_FOUND   = 77;
  -    public static final int NO_JAVA_FUNCT_THIS_REF  = 78;
  +    public static final int STRAY_SORT_ERR              = 74;
  +    public static final int UNSUPPORTED_ENCODING        = 75;
  +    public static final int SYNTAX_ERR                  = 76;
  +    public static final int CONSTRUCTOR_NOT_FOUND       = 77;
  +    public static final int NO_JAVA_FUNCT_THIS_REF      = 78;
  +    public static final int TYPE_CHECK_ERR              = 79;
  +    public static final int TYPE_CHECK_UNK_LOC_ERR      = 80;
  +    public static final int ILLEGAL_CMDLINE_OPTION_ERR  = 81;
  +    public static final int OPTION_MISSING_ARG_ERR      = 82;
  +    public static final int CMDLINE_OPT_MISSING_ARG_ERR = 83;
  +    public static final int WARNING_PLUS_WRAPPED_MSG    = 84;
  +    public static final int WARNING_MSG                 = 85;
  +    public static final int FATAL_ERR_PLUS_WRAPPED_MSG  = 86;
  +    public static final int FATAL_ERR_MSG               = 87;
  +    public static final int ERROR_PLUS_WRAPPED_MSG      = 88;
  +    public static final int ERROR_MSG                   = 89;
   
       // All error messages are localized and are stored in resource bundles.
       // This array and the following 4 strings are read from that bundle.
  
  
  
  1.3       +10 -11    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/TypeCheckError.java
  
  Index: TypeCheckError.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/TypeCheckError.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeCheckError.java       15 Jul 2002 15:57:38 -0000      1.2
  +++ TypeCheckError.java       27 Sep 2002 18:59:33 -0000      1.3
  @@ -96,16 +96,15 @@
       public String toString() {
        String result;
   
  -     if (_error != null) {
  -         result = _error.toString();
  -     }
  -     else if (_node != null) {
  -         result = "Type check error in " + _node.toString() + ".";
  -     }
  -     else {
  -         result = "Type check error (no line information).";
  -     }
  +     if (_error == null) {
  +            if (_node != null) {
  +                _error = new ErrorMsg(ErrorMsg.TYPE_CHECK_ERR,
  +                                      _node.toString());
  +         } else {
  +             _error = new ErrorMsg(ErrorMsg.TYPE_CHECK_UNK_LOC_ERR);
  +         }
  +        }
   
  -     return result;
  +     return _error.toString();
       }
   }
  
  
  
  1.85      +3 -3      
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.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- DOMImpl.java      21 Sep 2002 22:17:04 -0000      1.84
  +++ DOMImpl.java      27 Sep 2002 18:59:33 -0000      1.85
  @@ -209,8 +209,8 @@
            }
        }
   
  -     // TODO: Internationalization?
  -     throw new TransletException("Namespace prefix '" + prefix + "' is 
undeclared.");
  +        BasisLibrary.runTimeError(BasisLibrary.NAMESPACE_PREFIX_ERR, prefix);
  +        return null;
       }
   
       /**
  
  
  
  1.8       +4 -7      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DTDMonitor.java
  
  Index: DTDMonitor.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DTDMonitor.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DTDMonitor.java   17 Dec 2001 15:11:21 -0000      1.7
  +++ DTDMonitor.java   27 Sep 2002 18:59:33 -0000      1.8
  @@ -75,6 +75,7 @@
   import org.apache.xalan.xsltc.*;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
   import org.apache.xalan.xsltc.runtime.Hashtable;
  +import org.apache.xalan.xsltc.runtime.BasisLibrary;
   
   final public class DTDMonitor implements DTDHandler, DeclHandler {
   
  @@ -91,10 +92,6 @@
       private final static String DECL_HANDLER_PROP =
        "http://xml.org/sax/properties/declaration-handler";;
   
  -    // Error message used when the SAX parser does not generate DTD events
  -    private final static String NO_DTD_SUPPORT_STR =
  -     "Your SAX parser does not handle DTD declarations";
  -
       /**
        * Constructor - does nothing
        */
  @@ -117,10 +114,10 @@
            reader.setDTDHandler(this);
        }
        catch (SAXNotRecognizedException e) {
  -         throw(new RuntimeException(NO_DTD_SUPPORT_STR));
  +         BasisLibrary.runTimeError(BasisLibrary.PARSER_DTD_SUPPORT_ERR);
        }
        catch (SAXNotSupportedException e) {
  -         throw(new RuntimeException(NO_DTD_SUPPORT_STR));
  +         BasisLibrary.runTimeError(BasisLibrary.PARSER_DTD_SUPPORT_ERR);
        }
       }
   
  
  
  
  1.7       +3 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DocumentCache.java
  
  Index: DocumentCache.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DocumentCache.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DocumentCache.java        20 Jul 2001 18:52:09 -0000      1.6
  +++ DocumentCache.java        27 Sep 2002 18:59:33 -0000      1.7
  @@ -86,6 +86,7 @@
   import org.apache.xalan.xsltc.dom.DTDMonitor;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
   import org.apache.xalan.xsltc.runtime.Constants;
  +import org.apache.xalan.xsltc.runtime.BasisLibrary;
   
   public final class DocumentCache implements DOMCache {
   
  @@ -214,7 +215,7 @@
            _reader = _parser.getXMLReader();
        }
        catch (ParserConfigurationException e) {
  -         System.err.println("Your SAX parser is not configured correctly.");
  +         BasisLibrary.runTimeError(BasisLibrary.NAMESPACES_SUPPORT_ERR);
            System.exit(-1);
        }
       }
  
  
  
  1.51      +3 -1      
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.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- BasisLibrary.java 16 Sep 2002 19:25:01 -0000      1.50
  +++ BasisLibrary.java 27 Sep 2002 18:59:34 -0000      1.51
  @@ -1209,6 +1209,8 @@
       public static final int STRAY_NAMESPACE_ERR     = 11;
       public static final int NAMESPACE_PREFIX_ERR    = 12;
       public static final int DOM_ADAPTER_INIT_ERR    = 13;
  +    public static final int PARSER_DTD_SUPPORT_ERR  = 14;
  +    public static final int NAMESPACES_SUPPORT_ERR  = 15;
   
       // All error messages are localized and are stored in resource bundles.
       // This array and the following 4 strings are read from that bundle.
  
  
  
  1.2       +10 -7     
xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/getopt/GetOpt.java
  
  Index: GetOpt.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/cmdline/getopt/GetOpt.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetOpt.java       12 Jul 2001 12:54:36 -0000      1.1
  +++ GetOpt.java       27 Sep 2002 18:59:34 -0000      1.2
  @@ -68,6 +68,7 @@
   
   import org.apache.xalan.xsltc.cmdline.getopt.IllegalArgumentException;
   import org.apache.xalan.xsltc.cmdline.getopt.MissingOptArgException;
  +import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
   
   
   /**
  @@ -189,13 +190,15 @@
            char c = theCurrentOption.getArgLetter();
            boolean shouldHaveArg = theOptionMatcher.hasArg(c);
            String arg = theCurrentOption.getArgument();
  -         if(!theOptionMatcher.match(c)){
  -             throw (new IllegalArgumentException("Option " +
  -                     c + " is not valid."));
  +         if(!theOptionMatcher.match(c)) {
  +                ErrorMsg msg = new 
ErrorMsg(ErrorMsg.ILLEGAL_CMDLINE_OPTION_ERR,
  +                                            new Character(c));
  +             throw (new IllegalArgumentException(msg.toString()));
            }
  -         else if(shouldHaveArg && (arg == null)){
  -             throw (new MissingOptArgException("Option " + 
  -                     c + " is missing its argument."));
  +         else if(shouldHaveArg && (arg == null)) {
  +                ErrorMsg msg = new 
ErrorMsg(ErrorMsg.CMDLINE_OPT_MISSING_ARG_ERR,
  +                                            new Character(c));
  +             throw (new MissingOptArgException(msg.toString()));
            }
            retval = c;
        }
  
  
  
  1.20      +6 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Include.java
  
  Index: Include.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Include.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Include.java      20 Jul 2002 23:55:48 -0000      1.19
  +++ Include.java      27 Sep 2002 18:59:34 -0000      1.20
  @@ -125,8 +125,11 @@
                        docToLoad = "file:" + file.getCanonicalPath();
                    }
                    else {
  -                     throw new FileNotFoundException(
  -                       "Could not load file " + docToLoad);
  +                     final ErrorMsg msg =
  +                                       new ErrorMsg(ErrorMsg.FILE_ACCESS_ERR,
  +                                                    docToLoad);
  +                        parser.reportError(Constants.FATAL, msg);
  +                        return;
                    }
                    input = new InputSource(docToLoad);
                }
  
  
  
  1.9       +1 -4      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TransletOutput.java
  
  Index: TransletOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TransletOutput.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TransletOutput.java       16 Sep 2002 19:32:16 -0000      1.8
  +++ TransletOutput.java       27 Sep 2002 18:59:34 -0000      1.9
  @@ -71,9 +71,6 @@
       private Expression _filename;
       private boolean _append;
   
  -    private final static String MISSING_FILE_ATTR =
  -     "The <xsltc:output> element requires a 'file' attribute.";
  -
       /**
        * Displays the contents of this <xsltc:output> element.
        */
  
  
  

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

Reply via email to