sboag       01/01/09 10:14:42

  Modified:    java/src/org/apache/xalan/transformer TransformerImpl.java
  Log:
  Patch attributed to Patch attributed to David Eisenberg <[EMAIL PROTECTED]>.
  
  Note that these caught SAX exceptions should probably be fed
  through the ErrorListener.  One thing at a time.
  
  From David's note:
  
  I'm using Xalan J2 (D06) on Linux, and I invoke
  java org.apache.xalan.xslt.Process from a shell script.
  
  When my source XML file is bad, I get nothing other than "TRaX Transform
  Throwable", which isn't terribly useful.
  
  I've put a patch in TransformerImpl.java to deliver the parser error
  message, as well as a line and column number.  The patchfile is below.
  (The extra "{" and "}" near line 600 are left over from when I was putting
  in some debugging output.)
  
  Revision  Changes    Path
  1.72      +21 -3     
xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- TransformerImpl.java      2001/01/03 10:07:23     1.71
  +++ TransformerImpl.java      2001/01/09 18:14:42     1.72
  @@ -597,11 +597,15 @@
   
         if (null != e)
         {
  -        if (e instanceof javax.xml.transform.TransformerException)
  +        if (e instanceof javax.xml.transform.TransformerException) 
  +        {
             throw (javax.xml.transform.TransformerException) e;
  -        else if (e instanceof org.apache.xml.utils.WrappedRuntimeException)
  +        }
  +        else if (e instanceof org.apache.xml.utils.WrappedRuntimeException) 
  +        {
             throw new javax.xml.transform.TransformerException(
               ((org.apache.xml.utils.WrappedRuntimeException) 
e).getException());
  +        }
           else
           {
             throw new javax.xml.transform.TransformerException(e);
  @@ -615,7 +619,6 @@
       catch (org.apache.xml.utils.WrappedRuntimeException wre)
       {
         Throwable throwable = wre.getException();
  -
         while (throwable
                instanceof org.apache.xml.utils.WrappedRuntimeException)
         {
  @@ -624,6 +627,21 @@
         }
   
         throw new TransformerException(wre.getException());
  +    }
  +    // Patch attributed to David Eisenberg <[EMAIL PROTECTED]>
  +    catch (org.xml.sax.SAXParseException spe)
  +    {
  +       String msg = spe.getMessage();
  +       if (spe.getLineNumber() >= 0 && spe.getColumnNumber() >= 0)
  +       {
  +         msg += "\nLine " + spe.getLineNumber() +
  +                         " Column " + spe.getColumnNumber();
  +       }
  +       else
  +       {
  +         msg += "\n(no line number info available)";
  +       }
  +       throw new TransformerException( msg );
       }
       catch(org.xml.sax.SAXException se)
       {
  
  
  

Reply via email to