mmidy       99/12/02 12:11:42

  Modified:    src/org/apache/xalan/xslt Process.java
               src/org/apache/xalan/xslt/res XSLTErrorResources.java
                        XSLTErrorResources_en.java
  Log:
  Check for command line errors for Process
  
  Revision  Changes    Path
  1.8       +84 -33    xml-xalan/src/org/apache/xalan/xslt/Process.java
  
  Index: Process.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/Process.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Process.java      1999/11/28 04:25:14     1.7
  +++ Process.java      1999/12/02 20:11:41     1.8
  @@ -224,22 +224,32 @@
           }
           if ("-TCLASS".equalsIgnoreCase(argv[i]))
           {
  -          String className=argv[++i];
  -          try
  -          {
  -            Class traceClass = Class.forName(className);
  -            Constructor traceCtor = traceClass.getConstructor(null);
  -            TraceListener traceL = 
(TraceListener)traceCtor.newInstance(null);
  -            processor.addTraceListener(traceL);
  -          }
  -          catch(Exception e)
  -          {
  -            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0029, new 
Object[] {className})); //"Could not create TraceListener: "+className);
  +          if ( i+1 < argv.length)
  +          {  
  +            String className=argv[++i];
  +            try
  +            {
  +              Class traceClass = Class.forName(className);
  +              Constructor traceCtor = traceClass.getConstructor(null);
  +              TraceListener traceL = 
(TraceListener)traceCtor.newInstance(null);
  +              processor.addTraceListener(traceL);
  +            }
  +            catch(Exception e)
  +            {
  +              
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0029, new 
Object[] {className})); //"Could not create TraceListener: "+className);
  +            }
             }
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-TCLASS"})); //"Missing argument for);
  +            
           }
           else if ("-ESCAPE".equalsIgnoreCase(argv[i])) 
           {
  -          xmlProcessorLiaison.setSpecialCharacters(argv[++i]);
  +          if ( i+1 < argv.length)           
  +            xmlProcessorLiaison.setSpecialCharacters(argv[++i]);            
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-ESCAPE"})); //"Missing argument for);
  +           
           }
           else if ("-INDENT".equalsIgnoreCase(argv[i])) 
           {
  @@ -256,33 +266,63 @@
           } 
           else if ("-IN".equalsIgnoreCase(argv[i])) 
           {
  -          inFileName = argv[++i];
  +          if ( i+1 < argv.length)
  +            inFileName = argv[++i];
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-IN"})); //"Missing argument for);
  +             
           }
           else if ("-OUT".equalsIgnoreCase(argv[i])) 
           {
  -          outFileName = argv[++i];
  +          if ( i+1 < argv.length)
  +            outFileName = argv[++i];
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-OUT"})); //"Missing argument for);
  +            
           }
           else if ("-XSL".equalsIgnoreCase(argv[i])) 
           {
  -          xslFileName = argv[++i];
  +          if ( i+1 < argv.length)            
  +            xslFileName = argv[++i];
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-XSL"})); //"Missing argument for);
  +           
           }
           else if("-LXCIN".equalsIgnoreCase(argv[i]))
           {
  -          compiledStylesheetFileNameIn = argv[++i];
  +          if ( i+1 < argv.length)
  +            compiledStylesheetFileNameIn = argv[++i];
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-LXCIN"})); //"Missing argument for);
  +           
           }
           else if("-LXCOUT".equalsIgnoreCase(argv[i]))
           {
  -          compiledStylesheetFileNameOut = argv[++i];
  +          if ( i+1 < argv.length)
  +            compiledStylesheetFileNameOut = argv[++i];
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-LXCOUT"})); //"Missing argument for);
  +          
           }
           else if ("-PARAM".equalsIgnoreCase(argv[i])) 
           {
  -          String name = argv[++i];
  -          String expression = argv[++i];
  -          processor.setStylesheetParam(name, expression);
  +          if ( i+2 < argv.length)
  +          {  
  +            String name = argv[++i];
  +            String expression = argv[++i];
  +            processor.setStylesheetParam(name, expression);
  +          }
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-PARAM"})); //"Missing argument for);
  +          
           }
           else if ("-treedump".equalsIgnoreCase(argv[i])) 
           {
  -          treedumpFileName = argv[++i];
  +          if ( i+1 < argv.length)
  +            treedumpFileName = argv[++i];
  +          else
  +            
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0097, new 
Object[] {"-treedump"})); //"Missing argument for);
  +          
           }
           else if("-F".equalsIgnoreCase(argv[i]))
           {
  @@ -358,6 +398,9 @@
               dumpFileName = argv[++i];
             }
           }
  +        else
  +          
System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0098, new 
Object[] {argv[i]})); //"Invalid argument:);
  +          
         }
         
         // The main XSL transformation occurs here!
  @@ -399,14 +442,16 @@
           PrintWriter resultWriter;
           String mimeEncoding = null;
           
  -        OutputStream outputStream = System.out;
  -
  +        OutputStream outputStream = null;
           if(null != outFileName)
           {
             outputStream = new FileOutputStream(outFileName);
             // processor.setOutputFileName(outFileName);
           }
           
  +        if (null == outputStream)
  +          outputStream = System.out;
  +        
           if(null != stylesheet)
           {
             if(null != outputType)
  @@ -433,22 +478,28 @@
           }
           else
           {
  -          if(null == compiledStylesheetFileNameOut)
  +          if(null != stylesheet)
             {
  -            Document dummyDoc = xmlProcessorLiaison.createDocument();
  -            stylesheet.process(processor, dummyDoc, new 
XSLTResultTarget(outputStream));
  +            if(null == compiledStylesheetFileNameOut)
  +            {
  +              Document dummyDoc = xmlProcessorLiaison.createDocument();
  +              stylesheet.process(processor, dummyDoc, new 
XSLTResultTarget(outputStream));
  +            }
             }
           }
   
  -        if(null != compiledStylesheetFileNameOut)
  +        if(null != stylesheet)
           {
  -          compiledStylesheetOutputStream 
  -            = new FileOutputStream(compiledStylesheetFileNameOut);
  -          compiledStylesheetOutput 
  -            = new ObjectOutputStream(compiledStylesheetOutputStream);
  +          if(null != compiledStylesheetFileNameOut)
  +          {
  +            compiledStylesheetOutputStream 
  +              = new FileOutputStream(compiledStylesheetFileNameOut);
  +            compiledStylesheetOutput 
  +              = new ObjectOutputStream(compiledStylesheetOutputStream);
             
  -          compiledStylesheetOutput.writeObject(stylesheet);
  -        }
  +            compiledStylesheetOutput.writeObject(stylesheet);
  +          }
  +        }  
         }
         catch(TooManyListenersException tmle)
         {
  
  
  
  1.6       +5 -1      
xml-xalan/src/org/apache/xalan/xslt/res/XSLTErrorResources.java
  
  Index: XSLTErrorResources.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/res/XSLTErrorResources.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XSLTErrorResources.java   1999/11/30 18:11:43     1.5
  +++ XSLTErrorResources.java   1999/12/02 20:11:41     1.6
  @@ -207,7 +207,9 @@
   ERROR0094 = 94, 
   ERROR0095 = 95,
   ERROR0096 = 96,
  -MAX_CODE = 96;                 // this is needed to keep track of the number 
of messages          
  +ERROR0097 = 97,
  +ERROR0098 = 98,  
  +MAX_CODE = 98;                 // this is needed to keep track of the number 
of messages          
   
   public static final int
   WARNING0000 = 0,
  @@ -336,6 +338,8 @@
   {"ER0094", "Can not build FormatterListener in Redirect extension!"},
   {"ER0095", "Prefix in exclude-result-prefixes is not valid: {0}"},
   {"ER0096", "Missing namespace URI for specified prefix"},
  +{"ER0097", "Missing argument for option: {0}"},
  +{"ER0098", "Invalid option: {0}"},
   
   {"WR0001", "Found '}' but no attribute template open!"},
   {"WR0002", "Warning: count attribute does not match an ancestor in 
xsl:number! Target = {0}"},
  
  
  
  1.4       +3 -0      
xml-xalan/src/org/apache/xalan/xslt/res/XSLTErrorResources_en.java
  
  Index: XSLTErrorResources_en.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xslt/res/XSLTErrorResources_en.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSLTErrorResources_en.java        1999/11/30 18:11:44     1.3
  +++ XSLTErrorResources_en.java        1999/12/02 20:11:41     1.4
  @@ -113,6 +113,9 @@
   {"ER0094", "Can not build FormatterListener in Redirect extension!"},
   {"ER0095", "Prefix in exclude-result-prefixes is not valid: {0}"},
   {"ER0096", "Missing namespace URI for specified prefix"},
  +{"ER0097", "Missing argument for option: {0}"},
  +{"ER0098", "Invalid option: {0}"},
  +
   
   {"WR0001", "Found '}' but no attribute template open!"},
   {"WR0002", "Warning: count attribute does not match an ancestor in 
xsl:number! Target = {0}"},
  
  
  

Reply via email to