You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/11/06 19:51:06 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath Expression.java

sboag       00/11/06 10:51:03

  Modified:    java/src/org/apache/xpath Expression.java
  Log:
  Check for null reader and null error handler in warn and error functions.
  
  Revision  Changes    Path
  1.6       +19 -7     xml-xalan/java/src/org/apache/xpath/Expression.java
  
  Index: Expression.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/Expression.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Expression.java	2000/11/03 23:28:14	1.5
  +++ Expression.java	2000/11/06 18:50:58	1.6
  @@ -64,6 +64,7 @@
   
   import org.xml.sax.ErrorHandler;
   import org.xml.sax.SAXParseException;
  +import org.xml.sax.XMLReader;
   
   import javax.xml.transform.TransformerConfigurationException;
   import org.apache.xalan.utils.SAXSourceLocator;
  @@ -107,14 +108,23 @@
     {
   
       java.lang.String fmsg = XSLMessages.createXPATHWarning(msg, args);
  -    ErrorHandler eh = xctxt.getPrimaryReader().getErrorHandler();
  -
  -    if (null != eh)
  +    XMLReader reader = xctxt.getPrimaryReader();
  +    
  +    if (null != reader && null != reader.getErrorHandler())
       {
  +      ErrorHandler eh = reader.getErrorHandler();
   
         // TO DO: Need to get stylesheet Locator from here.
         eh.warning(new SAXParseException(fmsg, (SAXSourceLocator)xctxt.getSAXLocator()));
       }
  +    else
  +    {
  +      // Where to send diagnostics in this case?
  +      SourceLocator slocator = m_xpath.getLocator();
  +      System.out.println(fmsg + "; file " + slocator.getSystemId()
  +                         + "; line " + slocator.getLineNumber() + "; column "
  +                         + slocator.getColumnNumber());    
  +    }
     }
   
     /**
  @@ -155,12 +165,13 @@
     {
   
       java.lang.String fmsg = XSLMessages.createXPATHMessage(msg, args);
  -    ErrorHandler eh = xctxt.getPrimaryReader().getErrorHandler();
  -
  -    if (null != eh)
  +    XMLReader reader = xctxt.getPrimaryReader();
  +    if((null != reader) && (null != reader.getErrorHandler()))
       {
  +      ErrorHandler eh = reader.getErrorHandler();
  +
         SAXParseException te = new SAXParseException(fmsg,
  -                      (SAXSourceLocator)m_xpath.getLocator());
  +                                                   (SAXSourceLocator)m_xpath.getLocator());
         eh.fatalError(te);
       }
       else
  @@ -170,5 +181,6 @@
                            + "; line " + slocator.getLineNumber() + "; column "
                            + slocator.getColumnNumber());
       }
  +    
     }
   }