dbertoni    2002/08/30 16:59:24

  Modified:    c/samples/CompileStylesheet CompileStylesheet.cpp
               c/samples/DocumentBuilder DocumentBuilder.cpp
               c/samples/ExternalFunction ExternalFunction.cpp
               c/samples/ParsedSourceWrappers ParsedSourceWrappers.cpp
               c/samples/SimpleTransform SimpleTransform.cpp
               c/samples/StreamTransform StreamTransform.cpp
               c/samples/ThreadSafe ThreadSafe.cpp
               c/samples/TraceListen TraceListen.cpp
               c/samples/UseStylesheetParam UseStylesheetParam.cpp
               c/samples/XalanTransform XalanTransform.cpp
               c/samples/XalanTransformerCallback
                        XalanTransformerCallback.cpp
  Log:
  Fixes for initialization and termination.
  
  Revision  Changes    Path
  1.21      +5 -2      
xml-xalan/c/samples/CompileStylesheet/CompileStylesheet.cpp
  
  Index: CompileStylesheet.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/samples/CompileStylesheet/CompileStylesheet.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- CompileStylesheet.cpp     28 Feb 2002 06:10:53 -0000      1.20
  +++ CompileStylesheet.cpp     30 Aug 2002 23:59:23 -0000      1.21
  @@ -105,11 +105,14 @@
                        }
                }
   
  -             // Terminate Xalan.
  +             // Terminate Xalan...
                XalanTransformer::terminate();
   
  -             // Call the static terminator for Xerces.
  +             // Terminate Xerces...
                XMLPlatformUtils::Terminate();
  +
  +             // Clean up the ICU, if it's integrated.
  +             XalanTransformer::ICUCleanUp();
        }
   
        return theResult;
  
  
  
  1.5       +3 -0      xml-xalan/c/samples/DocumentBuilder/DocumentBuilder.cpp
  
  Index: DocumentBuilder.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/DocumentBuilder/DocumentBuilder.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DocumentBuilder.cpp       28 Feb 2002 06:10:53 -0000      1.4
  +++ DocumentBuilder.cpp       30 Aug 2002 23:59:23 -0000      1.5
  @@ -159,6 +159,9 @@
   
                // Call the static terminator for Xerces.
                XMLPlatformUtils::Terminate();
  +
  +             // Clean up the ICU, if it's integrated.
  +             XalanTransformer::ICUCleanUp();
        }
   
        return theResult;
  
  
  
  1.25      +5 -2      xml-xalan/c/samples/ExternalFunction/ExternalFunction.cpp
  
  Index: ExternalFunction.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/samples/ExternalFunction/ExternalFunction.cpp,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ExternalFunction.cpp      16 Aug 2002 18:34:10 -0000      1.24
  +++ ExternalFunction.cpp      30 Aug 2002 23:59:24 -0000      1.25
  @@ -344,11 +344,14 @@
                        }
                }
   
  -             // Terminate Xalan.
  +             // Terminate Xalan...
                XalanTransformer::terminate();
   
  -             // Call the static terminator for Xerces.
  +             // Terminate Xerces...
                XMLPlatformUtils::Terminate();
  +
  +             // Clean up the ICU, if it's integrated...
  +             XalanTransformer::ICUCleanUp();
        }
   
        return theResult;
  
  
  
  1.4       +5 -2      
xml-xalan/c/samples/ParsedSourceWrappers/ParsedSourceWrappers.cpp
  
  Index: ParsedSourceWrappers.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/samples/ParsedSourceWrappers/ParsedSourceWrappers.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ParsedSourceWrappers.cpp  26 Jul 2002 15:38:01 -0000      1.3
  +++ ParsedSourceWrappers.cpp  30 Aug 2002 23:59:24 -0000      1.4
  @@ -244,11 +244,14 @@
   
                        theResult = transform();
   
  -                     // Terminate Xalan.
  +                     // Terminate Xalan...
                        XalanTransformer::terminate();
   
  -                     // Call the static terminator for Xerces.
  +                     // Terminate Xerces...
                        XMLPlatformUtils::Terminate();
  +
  +                     // Clean up the ICU, if it's integrated...
  +                     XalanTransformer::ICUCleanUp();
                }
                catch(...)
                {
  
  
  
  1.17      +31 -23    xml-xalan/c/samples/SimpleTransform/SimpleTransform.cpp
  
  Index: SimpleTransform.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/SimpleTransform/SimpleTransform.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SimpleTransform.cpp       28 Feb 2002 06:10:54 -0000      1.16
  +++ SimpleTransform.cpp       30 Aug 2002 23:59:24 -0000      1.17
  @@ -29,45 +29,53 @@
        using std::endl;
   #endif
   
  -     int     theResult = 0;
  +     int     theResult = -1;
   
        if (argc != 1)
        {
                cerr << "Usage: SimpleTransform"
                         << endl
                         << endl;
  -
  -             theResult = -1;
        }
        else
        {
  -             // Call the static initializer for Xerces.
  -             XMLPlatformUtils::Initialize();
  -
  -             // Initialize Xalan.
  -             XalanTransformer::initialize();
  -
  +             try
                {
  -                     // Create a XalanTransformer.
  -                     XalanTransformer theXalanTransformer;
  +                     // Call the static initializer for Xerces.
  +                     XMLPlatformUtils::Initialize();
   
  -                     // The assumption is that the executable will be run
  -                     // from same directory as the input files.
  -                     theResult = theXalanTransformer.transform("foo.xml", 
"foo.xsl", "foo.out");
  +                     // Initialize Xalan.
  +                     XalanTransformer::initialize();
   
  -                     if(theResult != 0)
                        {
  -                             cerr << "SimpleTransform Error: \n" << 
theXalanTransformer.getLastError()
  -                                      << endl
  -                                      << endl;
  +                             // Create a XalanTransformer.
  +                             XalanTransformer theXalanTransformer;
  +
  +                             // The assumption is that the executable will 
be run
  +                             // from same directory as the input files.
  +                             theResult = 
theXalanTransformer.transform("foo.xml", "foo.xsl", "foo.out");
  +
  +                             if(theResult != 0)
  +                             {
  +                                     cerr << "SimpleTransform Error: \n" << 
theXalanTransformer.getLastError()
  +                                              << endl
  +                                              << endl;
  +                             }
                        }
  -             }
   
  -             // Terminate Xalan.
  -             XalanTransformer::terminate();
  +                     // Terminate Xalan...
  +                     XalanTransformer::terminate();
   
  -             // Call the static terminator for Xerces.
  -             XMLPlatformUtils::Terminate();
  +                     // Terminate Xerces...
  +                     XMLPlatformUtils::Terminate();
  +
  +                     // Clean up the ICU, if it's integrated...
  +                     XalanTransformer::ICUCleanUp();
  +             }
  +             catch(...)
  +             {
  +                     cerr << "Initialization failed!" << endl;
  +             }
        }
   
        return theResult;
  
  
  
  1.10      +47 -37    xml-xalan/c/samples/StreamTransform/StreamTransform.cpp
  
  Index: StreamTransform.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/StreamTransform/StreamTransform.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- StreamTransform.cpp       22 Aug 2002 15:48:56 -0000      1.9
  +++ StreamTransform.cpp       30 Aug 2002 23:59:24 -0000      1.10
  @@ -40,7 +40,7 @@
   #endif
   #endif
   
  -     int     theResult = 0;
  +     int     theResult = -1;
   
        if (argc != 1)
        {
  @@ -50,28 +50,30 @@
        }
        else
        {
  -             // Call the static initializer for Xerces.
  -             XMLPlatformUtils::Initialize();
  +             try
  +             {
  +                     // Call the static initializer for Xerces.
  +                     XMLPlatformUtils::Initialize();
   
  -             // Initialize Xalan.
  -             XalanTransformer::initialize();
  +                     // Initialize Xalan.
  +                     XalanTransformer::initialize();
   
  -             {
  -                     // Create a XalanTransformer.
  -                     XalanTransformer theXalanTransformer;
  +                     {
  +                             // Create a XalanTransformer.
  +                             XalanTransformer theXalanTransformer;
   
  -                     // A simple input document...
  +                             // A simple input document...
   #if defined(XALAN_NON_ASCII_PLATFORM)
  -                     const char* const  theInputDocument = "<?xml 
version='1.0' encoding='EBCDIC-CP-US' ?><doc>Hello world!</doc>";
  +                             const char* const  theInputDocument = "<?xml 
version='1.0' encoding='EBCDIC-CP-US' ?><doc>Hello world!</doc>";
   #else
  -                     const char* const  theInputDocument = "<?xml 
version='1.0' encoding='ISO-8859-1' ?><doc>Hello world!</doc>";
  +                             const char* const  theInputDocument = "<?xml 
version='1.0' encoding='ISO-8859-1' ?><doc>Hello world!</doc>";
   #endif
   
  -                     // A "hello world" stylesheet.  Note that the encoding 
for the output is platform-dependent,
  -                     // since we're writing to a string.  It could be any 
encoding, but "binary" encodings,
  -                     // or encodings that could produce multi-byte 
characters would require transcoding on
  -                     // some platforms.
  -                     const char* const  theStylesheet =
  +                             // A "hello world" stylesheet.  Note that the 
encoding for the output is platform-dependent,
  +                             // since we're writing to a string.  It could 
be any encoding, but "binary" encodings,
  +                             // or encodings that could produce multi-byte 
characters would require transcoding on
  +                             // some platforms.
  +                             const char* const  theStylesheet =
   #if defined(XALAN_NON_ASCII_PLATFORM)
   "<?xml version='1.0' encoding='EBCDIC-CP-US'?>\
   <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' 
version='1.0'>\
  @@ -90,30 +92,38 @@
   </xsl:stylesheet>";
   #endif
   
  -                     // Our input streams...
  -                     istrstream      theXMLStream(theInputDocument, 
strlen(theInputDocument));
  -                     istrstream      theXSLStream(theStylesheet, 
strlen(theStylesheet));
  -
  -                     XSLTInputSource inputSource(&theXSLStream);
  -
  -                     inputSource.setSystemId(c_wstr(XalanDOMString("foo")));
  -
  -                     // Do the transform.
  -                     theResult = 
theXalanTransformer.transform(&theXMLStream, inputSource, cout);
  -    
  -                     if(theResult != 0)
  -                     {
  -                             cerr << "StreamTransform Error: \n" << 
theXalanTransformer.getLastError()
  -                                      << endl
  -                                      << endl;
  +                             // Our input streams...
  +                             istrstream      theXMLStream(theInputDocument, 
strlen(theInputDocument));
  +                             istrstream      theXSLStream(theStylesheet, 
strlen(theStylesheet));
  +
  +                             XSLTInputSource inputSource(&theXSLStream);
  +
  +                             
inputSource.setSystemId(c_wstr(XalanDOMString("foo")));
  +
  +                             // Do the transform.
  +                             theResult = 
theXalanTransformer.transform(&theXMLStream, inputSource, cout);
  +
  +                             if(theResult != 0)
  +                             {
  +                                     cerr << "StreamTransform Error: \n" << 
theXalanTransformer.getLastError()
  +                                              << endl
  +                                              << endl;
  +                             }
                        }
  -             }
   
  -             // Terminate Xalan.
  -             XalanTransformer::terminate();
  +                     // Terminate Xalan...
  +                     XalanTransformer::terminate();
   
  -             // Call the static terminator for Xerces.
  -             XMLPlatformUtils::Terminate();
  +                     // Terminate Xerces...
  +                     XMLPlatformUtils::Terminate();
  +
  +                     // Clean up the ICU, if it's integrated...
  +                     XalanTransformer::ICUCleanUp();
  +             }
  +             catch(...)
  +             {
  +                     cerr << "Initialization failed!" << endl;
  +             }
        }
   
        return theResult;
  
  
  
  1.19      +44 -32    xml-xalan/c/samples/ThreadSafe/ThreadSafe.cpp
  
  Index: ThreadSafe.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/ThreadSafe/ThreadSafe.cpp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ThreadSafe.cpp    28 Feb 2002 06:10:54 -0000      1.18
  +++ ThreadSafe.cpp    30 Aug 2002 23:59:24 -0000      1.19
  @@ -173,33 +173,21 @@
        }
        else
        {
  -             // Call the static initializer for Xerces.
  -             XMLPlatformUtils::Initialize();
  -
  -             // Initialize Xalan.
  -             XalanTransformer::initialize();
  -
  +             try
                {
  -                     // Create a XalanTransformer.  We won't actually use 
this to transform --
  -                     // it's just acting likely a factory for the compiled 
stylesheet and
  -                     // pre-parsed source.
  -                     XalanTransformer        theXalanTransformer;
  +                     // Call the static initializer for Xerces.
  +                     XMLPlatformUtils::Initialize();
   
  -                     glbError = 
theXalanTransformer.compileStylesheet("birds.xsl", glbCompiledStylesheet);
  +                     // Initialize Xalan.
  +                     XalanTransformer::initialize();
   
  -                     if (glbError != 0)
                        {
  -                             cerr << "ThreadSafe Error: \n" << 
theXalanTransformer.getLastError()
  -                                      << endl
  -                                      << endl;
  -                     }
  -                     else
  -                     {
  -                             assert(glbCompiledStylesheet != 0);
  +                             // Create a XalanTransformer.  We won't 
actually use this to transform --
  +                             // it's just acting likely a factory for the 
compiled stylesheet and
  +                             // pre-parsed source.
  +                             XalanTransformer        theXalanTransformer;
   
  -                             // Compile the XML source document as well. All 
threads will use
  -                             // this binary representation of the source 
tree.
  -                             glbError = 
theXalanTransformer.parseSource("birds.xml", glbParsedSource);
  +                             glbError = 
theXalanTransformer.compileStylesheet("birds.xsl", glbCompiledStylesheet);
   
                                if (glbError != 0)
                                {
  @@ -209,21 +197,45 @@
                                }
                                else
                                {
  -                                     assert(glbParsedSource != 0);
  +                                     assert(glbCompiledStylesheet != 0);
   
  -                                     // Create and run the threads...
  -                                     // Each thread uses the same document 
and 
  -                                     // stylesheet to perform a 
transformation.
  -                                     doThreads(10);
  +                                     // Compile the XML source document as 
well. All threads will use
  +                                     // this binary representation of the 
source tree.
  +                                     glbError = 
theXalanTransformer.parseSource("birds.xml", glbParsedSource);
  +
  +                                     if (glbError != 0)
  +                                     {
  +                                             cerr << "ThreadSafe Error: \n" 
<< theXalanTransformer.getLastError()
  +                                                      << endl
  +                                                      << endl;
  +                                     }
  +                                     else
  +                                     {
  +                                             assert(glbParsedSource != 0);
  +
  +                                             // Create and run the threads...
  +                                             // Each thread uses the same 
document and 
  +                                             // stylesheet to perform a 
transformation.
  +                                             doThreads(10);
  +                                     }
                                }
                        }
  -             }
   
  -             // Terminate Xalan.
  -             XalanTransformer::terminate();
  +                     // Terminate Xalan...
  +                     XalanTransformer::terminate();
   
  -             // Call the static terminator for Xerces.
  -             XMLPlatformUtils::Terminate();
  +                     // Terminate Xerces...
  +                     XMLPlatformUtils::Terminate();
  +
  +                     // Clean up the ICU, if it's integrated...
  +                     XalanTransformer::ICUCleanUp();
  +             }
  +             catch(...)
  +             {
  +                     cerr << "Initialization failed!" << endl;
  +
  +                     glbError = -1;
  +             }
        }
   
        return glbError;
  
  
  
  1.14      +5 -0      xml-xalan/c/samples/TraceListen/TraceListen.cpp
  
  Index: TraceListen.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/TraceListen/TraceListen.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TraceListen.cpp   12 Apr 2002 05:30:05 -0000      1.13
  +++ TraceListen.cpp   30 Aug 2002 23:59:24 -0000      1.14
  @@ -141,9 +141,14 @@
                        }
                }
   
  +             // Terminate Xalan...
                XalanTransformer::terminate();
   
  +             // Terminate Xerces...
                XMLPlatformUtils::Terminate();
  +
  +             // Clean up the ICU, if it's integrated...
  +             XalanTransformer::ICUCleanUp();
        }
        catch(...)
        {
  
  
  
  1.17      +5 -2      
xml-xalan/c/samples/UseStylesheetParam/UseStylesheetParam.cpp
  
  Index: UseStylesheetParam.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/samples/UseStylesheetParam/UseStylesheetParam.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- UseStylesheetParam.cpp    28 Feb 2002 06:10:54 -0000      1.16
  +++ UseStylesheetParam.cpp    30 Aug 2002 23:59:24 -0000      1.17
  @@ -67,11 +67,14 @@
                        }
                }
   
  -             // Terminate Xalan.
  +             // Terminate Xalan...
                XalanTransformer::terminate();
   
  -             // Call the static terminator for Xerces.
  +             // Terminate Xerces...
                XMLPlatformUtils::Terminate();
  +
  +             // Clean up the ICU, if it's integrated...
  +             XalanTransformer::ICUCleanUp();
        }
   
        return theResult;
  
  
  
  1.9       +5 -2      xml-xalan/c/samples/XalanTransform/XalanTransform.cpp
  
  Index: XalanTransform.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/XalanTransform/XalanTransform.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XalanTransform.cpp        10 May 2002 23:59:59 -0000      1.8
  +++ XalanTransform.cpp        30 Aug 2002 23:59:24 -0000      1.9
  @@ -128,11 +128,14 @@
                        }
                }
   
  -             // Terminate Xalan.
  +             // Terminate Xalan...
                XalanTransformer::terminate();
   
  -             // Call the static terminator for Xerces.
  +             // Terminate Xerces...
                XMLPlatformUtils::Terminate();
  +
  +             // Clean up the ICU, if it's integrated...
  +             XalanTransformer::ICUCleanUp();
        }
        catch(...)
        {
  
  
  
  1.8       +6 -3      
xml-xalan/c/samples/XalanTransformerCallback/XalanTransformerCallback.cpp
  
  Index: XalanTransformerCallback.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/samples/XalanTransformerCallback/XalanTransformerCallback.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XalanTransformerCallback.cpp      12 Apr 2002 05:31:47 -0000      1.7
  +++ XalanTransformerCallback.cpp      30 Aug 2002 23:59:24 -0000      1.8
  @@ -155,7 +155,7 @@
       }
       else
       {
  -             // Ooutput file specified, so try to open it...
  +             // Output file specified, so try to open it...
                FILE* const     theOutputFile = fopen(argv[3], "w");
   
                if (theOutputFile == 0)
  @@ -170,11 +170,14 @@
                }
       }
   
  -    // Terminate Xalan.
  +     // Terminate Xalan...
        XalanTransformer::terminate();
   
  -     // Call the static terminator for Xerces.
  +     // Terminate Xerces...
        XMLPlatformUtils::Terminate();
  +
  +     // Clean up the ICU, if it's integrated...
  +     XalanTransformer::ICUCleanUp();
   
        return theResult;
   }
  
  
  

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

Reply via email to