dbertoni    2003/01/09 21:01:31

  Modified:    c/src/XalanTransformer XalanTransformer.cpp
                        XalanTransformer.hpp
  Log:
  Added catch of SAXParseException and move some code to common blocks.
  
  Revision  Changes    Path
  1.65      +96 -29    xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp
  
  Index: XalanTransformer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- XalanTransformer.cpp      25 Nov 2002 20:03:29 -0000      1.64
  +++ XalanTransformer.cpp      10 Jan 2003 05:01:30 -0000      1.65
  @@ -67,7 +67,7 @@
   
   
   
  -#include <xercesc/sax/SAXException.hpp>
  +#include <xercesc/sax/SAXParseException.hpp>
   
   
   
  @@ -262,8 +262,8 @@
   
   static void
   addTraceListeners(
  -                               const XalanTransformer::TraceListenerVectorType&     
 theTraceListeners,
  -                               XSLTEngineImpl&                                      
                                 theEngine)
  +                      const XalanTransformer::TraceListenerVectorType&       
theTraceListeners,
  +                      XSLTEngineImpl&                                               
                         theEngine)
   {
        if (theTraceListeners.empty() == false)
        {
  @@ -316,9 +316,9 @@
   
   int
   XalanTransformer::transform(
  -     const XSLTInputSource&          theInputSource, 
  -     const XSLTInputSource&          theStylesheetSource,
  -     const XSLTResultTarget&         theResultTarget)
  +                     const XSLTInputSource&          theInputSource, 
  +                     const XSLTInputSource&          theStylesheetSource,
  +                     const XSLTResultTarget&         theResultTarget)
   {
        // Parse the source document.
        const XalanParsedSource*        theParsedSource = 0;
  @@ -433,10 +433,65 @@
   
   
   XALAN_USING_XERCES(XMLException)
  +XALAN_USING_XERCES(SAXParseException)
   XALAN_USING_XERCES(SAXException)
   
   
   
  +void
  +FormatSAXParseException(
  +                     const SAXParseException&        theException,
  +                     XalanDOMString&                         theErrorMessage)
  +{
  +     assert(theException.getMessage() != 0);
  +
  +     const XalanDOMChar      theDummy = 0;
  +
  +     const XalanDOMChar* const       theSystemID = theException.getSystemId();
  +
  +     XSLException::defaultFormat(
  +                             theException.getMessage(),
  +                             theSystemID == 0 ? &theDummy : theSystemID,
  +                             theException.getLineNumber(),
  +                             theException.getColumnNumber(),
  +                             c_wstr(XALAN_STATIC_UCODE_STRING("SAXParseException")),
  +                             theErrorMessage);
  +}
  +
  +
  +
  +void
  +FormatSAXParseException(
  +                     const SAXParseException&        theException,
  +                     CharVectorType&                         theErrorMessage)
  +{
  +     XalanDOMString  theBuffer;
  +
  +     FormatSAXParseException(
  +                             theException,
  +                             theBuffer);
  +
  +     TranscodeToLocalCodePage(theBuffer, theErrorMessage, true);
  +}
  +
  +
  +
  +void
  +FormatXalanDOMException(
  +                     const XalanDOMException&        theException,
  +                     CharVectorType&                         theErrorMessage)
  +{
  +     XalanDOMString  theBuffer("XalanDOMException caught.  The code is ");
  +
  +     append(theBuffer, LongToDOMString(long(theException.getExceptionCode())));
  +
  +     append(theBuffer, XalanDOMChar(XalanUnicode::charFullStop));
  +
  +     TranscodeToLocalCodePage(theBuffer, theErrorMessage, true);
  +}
  +
  +
  +
   int
   XalanTransformer::compileStylesheet(
                        const XSLTInputSource&                          
theStylesheetSource,
  @@ -519,6 +574,19 @@
   
                theResult = -1;
        }
  +     catch(const SAXParseException&  e)
  +     {
  +             if (length(theErrorMessage) != 0)
  +             {
  +                     TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, 
true);
  +             }
  +             else
  +             {
  +                     FormatSAXParseException(e, m_errorMessage);
  +             }
  +
  +             theResult = -2;
  +     }
        catch(const SAXException&       e)
        {
                if (length(theErrorMessage) != 0)
  @@ -660,10 +728,16 @@
        }
        catch(const XSLException&       e)
        {
  -             TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
  +             TranscodeToLocalCodePage(e.defaultFormat(), m_errorMessage, true);
   
                theResult = -1;
        }
  +     catch(const SAXParseException&  e)
  +     {
  +             FormatSAXParseException(e, m_errorMessage);
  +
  +             theResult = -2;
  +     }
        catch(const SAXException&       e)
        {
                TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
  @@ -678,13 +752,7 @@
        }
        catch(const XalanDOMException&  e)
        {
  -             XalanDOMString theMessage("XalanDOMException caught.  The code is ");
  -                     
  -             append(theMessage, LongToDOMString(long(e.getExceptionCode())));
  -
  -             append(theMessage, XalanDOMChar(XalanUnicode::charFullStop));
  -
  -             TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
  +             FormatXalanDOMException(e, m_errorMessage);
   
                theResult = -4;
        }
  @@ -862,15 +930,6 @@
   
   
   
  -
  -const char*
  -XalanTransformer::getLastError() const
  -{
  -     return &m_errorMessage[0]; 
  -}
  -
  -
  -
   int
   XalanTransformer::getIndent() const
   {
  @@ -1197,6 +1256,19 @@
   
                theResult = -1;
        }
  +     catch(const SAXParseException&  e)
  +     {
  +             if (length(theErrorMessage) != 0)
  +             {
  +                     TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, 
true);
  +             }
  +             else
  +             {
  +                     FormatSAXParseException(e, m_errorMessage);
  +             }
  +
  +             theResult = -2;
  +     }
        catch(const SAXException&       e)
        {
                if (length(theErrorMessage) != 0)
  @@ -1231,12 +1303,7 @@
                }
                else
                {
  -                     XalanDOMString theMessage("XalanDOMException caught.  The code 
is ");
  -                     
  -                     append(theMessage, 
LongToDOMString(long(e.getExceptionCode())));
  -                     append(theMessage, XalanDOMChar(XalanUnicode::charFullStop));
  -
  -                     TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
  +                     FormatXalanDOMException(e, m_errorMessage);
                }
   
                theResult = -4;
  
  
  
  1.46      +6 -1      xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp
  
  Index: XalanTransformer.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- XalanTransformer.hpp      21 Dec 2002 00:19:26 -0000      1.45
  +++ XalanTransformer.hpp      10 Jan 2003 05:01:30 -0000      1.46
  @@ -666,7 +666,12 @@
         * @return      error message const character pointer.
         */
        const char*
  -     getLastError() const;
  +     getLastError() const
  +     {
  +             assert(m_errorMessage.size() > 0);
  +
  +             return &m_errorMessage[0]; 
  +     }
   
        /**
         * Get the current number of spaces to indent.
  
  
  

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

Reply via email to