mmidy       01/01/26 07:54:13

  Modified:    java/compat_src/org/apache/xalan/xpath/xml
                        ProblemListenerDefault.java
               java/compat_src/org/apache/xalan/xslt XSLTEngineImpl.java
  Log:
  Allow problem listener to specify whether or not to throw an exception
  
  Revision  Changes    Path
  1.5       +79 -62    
xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/ProblemListenerDefault.java
  
  Index: ProblemListenerDefault.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xpath/xml/ProblemListenerDefault.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProblemListenerDefault.java       2001/01/25 20:39:17     1.4
  +++ ProblemListenerDefault.java       2001/01/26 15:54:13     1.5
  @@ -131,10 +131,12 @@
     throws org.xml.sax.SAXException   
     {
       if (m_problemListener != null)
  -      m_problemListener.problem(where, classification, styleNode, 
sourceNode, msg, id, lineNo, charOffset);
  +      return m_problemListener.problem(where, classification, styleNode, 
sourceNode, msg, id, lineNo, charOffset);
       else
  +    {  
         this.error(new SAXParseException(msg, null, id, lineNo, charOffset));
  -    return false;   
  +      return false;   
  +    }
     } 
     
     public void warning(SAXParseException exception) throws SAXException
  @@ -145,12 +147,14 @@
       }
       else
       {
  -      m_problemListener.problem(XSLPROCESSOR, WARNING,
  +      boolean shouldthrow = m_problemListener.problem(XSLPROCESSOR, WARNING,
                                   null, null,
                                   exception.getMessage(),
                                   exception.getSystemId(),
                                   exception.getLineNumber(),  
                                   exception.getColumnNumber()); 
  +      if (shouldthrow)
  +        throw new SAXException(exception);
       }
     }
     
  @@ -162,12 +166,14 @@
       }
       else
       {
  -      m_problemListener.problem(XSLPROCESSOR, ERROR,
  +      boolean shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
                                   null, null,
                                   exception.getMessage(),
                                   exception.getSystemId(),
                                   exception.getLineNumber(),  
                                   exception.getColumnNumber()); 
  +      if (shouldthrow)
  +        throw new SAXException(exception);
       }
     }
     
  @@ -179,12 +185,14 @@
       }
       else
       {
  -      m_problemListener.problem(XSLPROCESSOR, ERROR,
  +      boolean shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
                                   null, null,
                                   exception.getMessage(),
                                   exception.getSystemId(),
                                   exception.getLineNumber(),  
                                   exception.getColumnNumber()); 
  +      if (shouldthrow)
  +        throw new SAXException(exception);
       }
     }
     
  @@ -196,31 +204,34 @@
       }
       else
       {
  +      boolean shouldthrow = true;
         try{
  -      javax.xml.transform.SourceLocator locator = exception.getLocator();
  -      if (locator != null)
  -      {
  -        m_problemListener.problem(XSLPROCESSOR, WARNING,
  -                                  null, null,
  -                                  exception.getMessage(),
  -                                  locator.getSystemId(),
  -                                  locator.getLineNumber(),  
  -                                  locator.getColumnNumber());
  -      }
  -      else 
  -      {
  -        m_problemListener.problem(XSLPROCESSOR, MESSAGE,
  -                                  null, null,
  -                                  exception.getMessage(),
  -                                  null,
  -                                  0,  
  -                                  0);
  +        javax.xml.transform.SourceLocator locator = exception.getLocator();
  +        if (locator != null)
  +        {
  +          shouldthrow = m_problemListener.problem(XSLPROCESSOR, WARNING,
  +                                                  null, null,
  +                                                  exception.getMessage(),
  +                                                  locator.getSystemId(),
  +                                                  locator.getLineNumber(),  
  +                                                  locator.getColumnNumber());
  +        }
  +        else 
  +        {
  +          shouldthrow = m_problemListener.problem(XSLPROCESSOR, MESSAGE,
  +                                                  null, null,
  +                                                  exception.getMessage(),
  +                                                  null,
  +                                                  0,  
  +                                                  0);
  +        }
         }
  -      }
         catch (SAXException se)
         {
           throw new TransformerException(se);
         }
  +      if (shouldthrow)
  +        throw new TransformerException(exception);
       }
     }
     
  @@ -232,31 +243,34 @@
       }
       else
       {
  +      boolean shouldthrow = true;
         try{
  -      javax.xml.transform.SourceLocator locator = exception.getLocator();
  -      if (locator != null)
  -      {
  -        m_problemListener.problem(XSLPROCESSOR, ERROR,
  -                                  null, null,
  -                                  exception.getMessage(),
  -                                  locator.getSystemId(),
  -                                  locator.getLineNumber(),  
  -                                  locator.getColumnNumber());
  +        javax.xml.transform.SourceLocator locator = exception.getLocator();
  +        if (locator != null)
  +        {
  +          shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
  +                                                  null, null,
  +                                                  exception.getMessage(),
  +                                                  locator.getSystemId(),
  +                                                  locator.getLineNumber(),  
  +                                                  locator.getColumnNumber());
  +        }
  +        else 
  +        {
  +          shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
  +                                                  null, null,
  +                                                  exception.getMessage(),
  +                                                  null,
  +                                                  0,  
  +                                                  0);
  +        }
         }
  -      else 
  -      {
  -        m_problemListener.problem(XSLPROCESSOR, ERROR,
  -                                  null, null,
  -                                  exception.getMessage(),
  -                                  null,
  -                                  0,  
  -                                  0);
  -      }
  -      }
         catch (SAXException se)
         {
           throw new TransformerException(se);
         }
  +      if (shouldthrow)
  +        throw new TransformerException(exception);
       }
     }
     
  @@ -268,31 +282,34 @@
       }
       else
       {
  +      boolean shouldthrow = true;
         try{
  -      javax.xml.transform.SourceLocator locator = exception.getLocator();
  -      if (locator != null)
  -      {
  -        m_problemListener.problem(XSLPROCESSOR, ERROR,
  -                                  null, null,
  -                                  exception.getMessage(),
  -                                  locator.getSystemId(),
  -                                  locator.getLineNumber(),  
  -                                  locator.getColumnNumber());
  -      }
  -      else 
  -      {
  -        m_problemListener.problem(XSLPROCESSOR, ERROR,
  -                                  null, null,
  -                                  exception.getMessage(),
  -                                  null,
  -                                  0,  
  -                                  0);
  -      }
  +        javax.xml.transform.SourceLocator locator = exception.getLocator();
  +        if (locator != null)
  +        {
  +          shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
  +                                                  null, null,
  +                                                  exception.getMessage(),
  +                                                  locator.getSystemId(),
  +                                                  locator.getLineNumber(),  
  +                                                  locator.getColumnNumber());
  +        }
  +        else 
  +        {
  +          shouldthrow = m_problemListener.problem(XSLPROCESSOR, ERROR,
  +                                                  null, null,
  +                                                  exception.getMessage(),
  +                                                  null,
  +                                                  0,  
  +                                                  0);
  +        }
         }
         catch (SAXException se)
         {
           throw new TransformerException(se);
         }
  +      if (shouldthrow)
  +        throw new TransformerException(exception);
       }
     }
     /*
  
  
  
  1.18      +1 -1      
xml-xalan/java/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java
  
  Index: XSLTEngineImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XSLTEngineImpl.java       2001/01/25 22:42:22     1.17
  +++ XSLTEngineImpl.java       2001/01/26 15:54:13     1.18
  @@ -446,7 +446,7 @@
           error(XSLTErrorResources.ER_FAILED_PROCESS_STYLESHEET); //"Failed to 
process stylesheet!");
         }
   
  -      if(null != sourceTree)
  +      else if(null != sourceTree)
         {
           try{
             m_transformerImpl = (TransformerImpl)templates.newTransformer(); 
  
  
  

Reply via email to