dbertoni    01/06/21 08:39:48

  Modified:    c/src/XalanTransformer XalanTransformer.hpp
                        XalanTransformer.cpp XalanCAPI.cpp
  Log:
  Changed interfaces to return error codes.
  
  Revision  Changes    Path
  1.25      +14 -9     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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- XalanTransformer.hpp      2001/06/12 19:12:54     1.24
  +++ XalanTransformer.hpp      2001/06/21 15:39:44     1.25
  @@ -286,10 +286,13 @@
         * the instance yourself.
         *
         * @param theStylesheetSource input source
  -      * @return a pointer to a XalanCompiledStylesheet or 0 for failure.
  +      * @param theCompiledStylesheet a reference to a pointer to a 
XalanCompileStylesheet.
  +      * @return 0 for success 
         */
  -     const XalanCompiledStylesheet*
  -     compileStylesheet(const XSLTInputSource&        theStylesheetSource);
  +     int
  +     compileStylesheet(
  +                     const XSLTInputSource&                          
theStylesheetSource,
  +                     const XalanCompiledStylesheet*&         
theCompiledStylesheet);
   
        /**
         * Destroy a XalanCompiledStylesheet instance created by a previous
  @@ -309,14 +312,16 @@
         * or you explicitly call destroyParsedSource().  You must not
         * delete the instance yourself.
         *
  -      * @param theInputSource        input source
  -      * @param useXercesDOM          input use default or xerces dom source 
tree
  -      * @return      a pointer to a XalanParsedSource or 0 for failure.
  +      * @param theInputSource input source
  +      * @param theParsedSource a reference to a pointer to a 
XalanParsedSource.
  +      * @param useXercesDOM input use default or xerces dom source tree
  +      * @return 0 for success 
         */
  -     const XalanParsedSource*
  +     int
        parseSource(
  -                     const XSLTInputSource&  theInputSource, 
  -                     bool                                    useXercesDOM = 
false);
  +                     const XSLTInputSource&          theInputSource,
  +                     const XalanParsedSource*&       theParsedSource,
  +                     bool                                            
useXercesDOM = false);
   
        /**
         * Destroy a parsed source created by a previous call to parseSource().
  
  
  
  1.22      +80 -44    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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- XalanTransformer.cpp      2001/06/12 19:12:53     1.21
  +++ XalanTransformer.cpp      2001/06/21 15:39:45     1.22
  @@ -494,18 +494,28 @@
        const XSLTResultTarget&         theResultTarget)
   {
        // Parse the source document.
  -     const XalanParsedSource* const  theParsedXML =
  -             parseSource(theInputSource);
  +     const XalanParsedSource*        theParsedSource = 0;
   
  -     // Make sure the parsed source is destroyed when
  -     // the transformation is finished...
  -     EnsureDestroyParsedSource       theGuard(*this, theParsedXML);
  +     const int       theResult = parseSource(theInputSource, 
theParsedSource);
   
  -     // Do the transformation...
  -     return transform(
  -                                     *theParsedXML, 
  -                                     theStylesheetSource,
  -                                     theResultTarget);
  +     if (theResult != 0)
  +     {
  +             return theResult;
  +     }
  +     else
  +     {
  +             assert(theParsedSource != 0);
  +
  +             // Make sure the parsed source is destroyed when
  +             // the transformation is finished...
  +             EnsureDestroyParsedSource       theGuard(*this, 
theParsedSource);
  +
  +             // Do the transformation...
  +             return transform(
  +                                             *theParsedSource,
  +                                             theStylesheetSource,
  +                                             theResultTarget);
  +     }
   }
   
   
  @@ -516,19 +526,28 @@
                        const XalanCompiledStylesheet*  theCompiledStylesheet,
                        const XSLTResultTarget&                 theResultTarget)
   {
  -     // Parse the source document.
  -     const XalanParsedSource* const  theParsedXML =
  -             parseSource(theInputSource);
  -
  -     // Make sure the parsed source is destroyed when
  -     // the transformation is finished...
  -     EnsureDestroyParsedSource       theGuard(*this, theParsedXML);
  +     const XalanParsedSource*        theParsedSource = 0;
   
  -     // Do the transformation...
  -     return transform(
  -                                     *theParsedXML, 
  -                                     theCompiledStylesheet,
  -                                     theResultTarget);
  +     const int       theResult = parseSource(theInputSource, 
theParsedSource);
  +
  +     if (theResult != 0)
  +     {
  +             return theResult;
  +     }
  +     else
  +     {
  +             assert(theParsedSource != 0);
  +
  +             // Make sure the parsed source is destroyed when
  +             // the transformation is finished...
  +             EnsureDestroyParsedSource       theGuard(*this, 
theParsedSource);
  +
  +             // Do the transformation...
  +             return transform(
  +                                             *theParsedSource,
  +                                             theCompiledStylesheet,
  +                                             theResultTarget);
  +     }
   }
   
   
  @@ -618,8 +637,10 @@
   
   
   
  -const XalanCompiledStylesheet*
  -XalanTransformer::compileStylesheet(const XSLTInputSource&           
theStylesheetSource)
  +int
  +XalanTransformer::compileStylesheet(
  +                     const XSLTInputSource&                          
theStylesheetSource,
  +                     const XalanCompiledStylesheet*&         
theCompiledStylesheet)
   {
        // Clear the error message.
        m_errorMessage.resize(1, '\0');
  @@ -627,6 +648,8 @@
        // Store error messages from problem listener.
        XalanDOMString  theErrorMessage;
   
  +     int                             theResult = 0;
  +
        try
        {
                // Create some support objects that are necessary for running 
the processor...
  @@ -654,22 +677,20 @@
   
                // Create a problem listener and send output to a 
XalanDOMString.
                DOMStringPrintWriter    thePrintWriter(theErrorMessage);
  -             
  +
                ProblemListenerDefault  theProblemListener(&thePrintWriter);
   
                theProcessor.setProblemListener(&theProblemListener);
   
                // Create a new XalanCompiledStylesheet.
  -             XalanCompiledStylesheet* const  theCompiledStylesheet =
  +             theCompiledStylesheet =
                        new XalanCompiledStylesheetDefault(
  -                                             theStylesheetSource, 
  +                                             theStylesheetSource,
                                                theXSLTProcessorEnvSupport,
                                                theProcessor);
   
                // Store it in a vector.
                m_compiledStylesheets.push_back(theCompiledStylesheet);
  -
  -             return theCompiledStylesheet;
        }
        catch (XSLException& e)
        {
  @@ -681,6 +702,8 @@
                {
                        TranscodeToLocalCodePage(e.getMessage(), 
m_errorMessage, true);
                }
  +
  +             theResult = -1;
        }
        catch (SAXException& e)
        {
  @@ -691,7 +714,9 @@
                else
                {
                        TranscodeToLocalCodePage(e.getMessage(), 
m_errorMessage, true);
  -             }               
  +             }
  +
  +             theResult = -2;
        }
        catch (XMLException& e)
        {
  @@ -703,6 +728,8 @@
                {
                        TranscodeToLocalCodePage(e.getMessage(), 
m_errorMessage, true);
                }
  +
  +             theResult = -3;
        }
        catch(const XalanDOMException&  e)
        {
  @@ -713,16 +740,18 @@
                else
                {
                        XalanDOMString theMessage("XalanDOMException caught.  
The code is ");
  -                     
  +
                        append(theMessage,  
LongToDOMString(long(e.getExceptionCode())));
   
  -                     append(theMessage,  XalanDOMString("."));               
                                 
  +                     append(theMessage,  XalanDOMString("."));
   
                        TranscodeToLocalCodePage(theMessage, m_errorMessage, 
true);
                }
  +
  +             theResult = -4;
        }
   
  -     return 0;
  +     return theResult;
   }
   
   
  @@ -750,44 +779,49 @@
   
   
   
  -const XalanParsedSource*
  +int
   XalanTransformer::parseSource(
  -                     const XSLTInputSource&  theInputSource,
  -                     bool                                    useXercesDOM)
  +                     const XSLTInputSource&          theInputSource,
  +                     const XalanParsedSource*&       theParsedSource,
  +                     bool                                            
useXercesDOM)
   {
        // Clear the error message.
        m_errorMessage.clear();
        m_errorMessage.push_back(0);
   
  +     int     theResult = 0;
  +
        try
        {
  -             XalanParsedSource* theParsedDocument = 0;
  -
                if(useXercesDOM == true)
                {
  -                     theParsedDocument = new 
XercesDOMParsedSource(theInputSource);
  +                     theParsedSource = new 
XercesDOMParsedSource(theInputSource);
                }
                else
                {
  -                     theParsedDocument = new 
XalanDefaultParsedSource(theInputSource);
  +                     theParsedSource = new 
XalanDefaultParsedSource(theInputSource);
                }
   
                // Store it in a vector.
  -             m_parsedSources.push_back(theParsedDocument);
  -
  -             return theParsedDocument;
  +             m_parsedSources.push_back(theParsedSource);
        }
        catch (XSLException& e)
        {
                TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
  +
  +             theResult = -1;
        }
        catch (SAXException& e)
        {
                TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
  +
  +             theResult = -2;
        }
        catch (XMLException& e)
        {
                TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
  +
  +             theResult = -3;
        }
        catch(const XalanDOMException&  e)
        {
  @@ -798,9 +832,11 @@
                append(theMessage,  XalanDOMString("."));                       
                         
   
                TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
  +
  +             theResult = -3;
        }
   
  -     return 0;
  +     return theResult;
   }
   
   
  
  
  
  1.19      +22 -3     xml-xalan/c/src/XalanTransformer/XalanCAPI.cpp
  
  Index: XalanCAPI.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanCAPI.cpp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- XalanCAPI.cpp     2001/06/15 21:45:14     1.18
  +++ XalanCAPI.cpp     2001/06/21 15:39:46     1.19
  @@ -329,7 +329,13 @@
                        const char*             theXSLFileName,
                        XalanHandle             theXalanHandle)
   {
  -     return 
getTransformer(theXalanHandle)->compileStylesheet(theXSLFileName);
  +     const XalanCompiledStylesheet*  theCompiledStylesheet = 0;
  +
  +     getTransformer(theXalanHandle)->compileStylesheet(
  +             theXSLFileName,
  +             theCompiledStylesheet);
  +
  +     return theCompiledStylesheet;
   }
   
   
  @@ -339,7 +345,13 @@
                        const char*             theXMLFileName,
                        XalanHandle             theXalanHandle)
   {
  -     return getTransformer(theXalanHandle)->parseSource(theXMLFileName);
  +     const XalanParsedSource*        theParsedSource = 0;
  +
  +     getTransformer(theXalanHandle)->parseSource(
  +             theXMLFileName,
  +             theParsedSource);
  +
  +     return theParsedSource;
   }
   
   
  @@ -349,7 +361,14 @@
                        const char*             theXMLFileName,
                        XalanHandle             theXalanHandle)
   {
  -     return getTransformer(theXalanHandle)->parseSource(theXMLFileName, 
true);
  +     const XalanParsedSource*        theParsedSource = 0;
  +
  +     getTransformer(theXalanHandle)->parseSource(
  +             theXMLFileName,
  +             theParsedSource,
  +             true);
  +
  +     return theParsedSource;
   }
   
   
  
  
  

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

Reply via email to