dbertoni    2003/12/29 13:18:58

  Modified:    c/samples/DocumentBuilder DocumentBuilder.cpp
               c/samples/ExternalFunction ExternalFunction.cpp
               c/samples/UseStylesheetParam UseStylesheetParam.cpp
  Log:
  Patch for Bugzilla 22248.
  
  Revision  Changes    Path
  1.12      +33 -21    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DocumentBuilder.cpp       20 Aug 2003 15:53:38 -0000      1.11
  +++ DocumentBuilder.cpp       29 Dec 2003 21:18:58 -0000      1.12
  @@ -194,38 +194,50 @@
        else
        {
                XALAN_USING_XERCES(XMLPlatformUtils)
  +             XALAN_USING_XERCES(XMLException)
   
                // Call the static initializer for Xerces.
  -             XMLPlatformUtils::Initialize();
  -
  -             // Initialize Xalan.
  -             XalanTransformer::initialize();
  +             try
  +             {
  +                      XMLPlatformUtils::Initialize();
  +             }
  +             catch (const XMLException& toCatch)
  +             {
  +                      cerr << "Error during Xerces initialization! "<< endl;
  +                      theResult = -1;
  +             }
   
  +             if (theResult == 0)
                {
  -                     // Create a XalanTransformer.
  -                     XalanTransformer        theXalanTransformer;
  +                     // Initialize Xalan.
  +                     XalanTransformer::initialize();
   
  -                     // Get a document builder from the transformer...
  -                     XalanDocumentBuilder* const             theBuilder = 
theXalanTransformer.createDocumentBuilder();
  +                     {
  +                             // Create a XalanTransformer.
  +                             XalanTransformer        theXalanTransformer;
  +
  +                             // Get a document builder from the 
transformer...
  +                             XalanDocumentBuilder* const             
theBuilder = theXalanTransformer.createDocumentBuilder();
   
  -                     BuildDocument(theBuilder);
  +                             BuildDocument(theBuilder);
   
  -                     // The assumption is that the executable will be run
  -                     // from same directory as the stylesheet file.
  +                             // The assumption is that the executable will 
be run
  +                             // from same directory as the stylesheet file.
   
  -                     // Do the transform.
  -                     theResult = theXalanTransformer.transform(*theBuilder, 
"foo.xsl", "foo.out");
  +                             // Do the transform.
  +                             theResult = 
theXalanTransformer.transform(*theBuilder, "foo.xsl", "foo.out");
       
  -                     if(theResult != 0)
  -                     {
  -                             cerr << "DocumentBuilder error: \n" << 
theXalanTransformer.getLastError()
  -                                      << endl
  -                                      << endl;
  +                             if(theResult != 0)
  +                             {
  +                                     cerr << "DocumentBuilder error: \n" << 
theXalanTransformer.getLastError()
  +                                              << endl
  +                                              << endl;
  +                             }
                        }
  -             }
   
  -             // Terminate Xalan.
  -             XalanTransformer::terminate();
  +                     // Terminate Xalan.
  +                     XalanTransformer::terminate();
  +             }
   
                // Call the static terminator for Xerces.
                XMLPlatformUtils::Terminate();
  
  
  
  1.34      +47 -35    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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ExternalFunction.cpp      17 Nov 2003 21:13:09 -0000      1.33
  +++ ExternalFunction.cpp      29 Dec 2003 21:18:58 -0000      1.34
  @@ -378,53 +378,65 @@
        else
        {
                XALAN_USING_XERCES(XMLPlatformUtils)
  +             XALAN_USING_XERCES(XMLException)
   
                XALAN_USING_XALAN(XalanTransformer)
   
                // Call the static initializer for Xerces.
  -             XMLPlatformUtils::Initialize();
  -
  -             // Initialize Xalan.
  -             XalanTransformer::initialize();
  +             try
  +             {
  +                      XMLPlatformUtils::Initialize();
  +             }
  +             catch (const XMLException& toCatch)
  +             {
  +                      cerr << "Error during Xerces initialization! "<< endl;
  +                      theResult = -1;
  +             }
   
  +             if (theResult == 0)
                {
  -                     // Create a XalanTransformer.
  -                     XalanTransformer        theXalanTransformer;
  +                     // Initialize Xalan.
  +                     XalanTransformer::initialize();
   
  -                     // The namespace for our functions...
  -                     const XalanDOMString    
theNamespace("http://ExternalFunction.xalan-c++.xml.apache.org";);
  +                     {
  +                             // Create a XalanTransformer.
  +                             XalanTransformer        theXalanTransformer;
  +
  +                             // The namespace for our functions...
  +                             const XalanDOMString    
theNamespace("http://ExternalFunction.xalan-c++.xml.apache.org";);
   
  -                     // Install the functions in the local space.  They will 
only
  -                     // be installed in this instance, so no other instances
  -                     // will know about them...
  -                     theXalanTransformer.installExternalFunction(
  -                             theNamespace,
  -                             XalanDOMString("asctime"),
  -                             FunctionAsctime());
  -
  -                     theXalanTransformer.installExternalFunction(
  -                             theNamespace,
  -                             XalanDOMString("square-root"),
  -                             FunctionSquareRoot());
  -
  -                     theXalanTransformer.installExternalFunction(
  -                             theNamespace,
  -                             XalanDOMString("cube"),
  -                             FunctionCube());
  +                             // Install the functions in the local space.  
They will only
  +                             // be installed in this instance, so no other 
instances
  +                             // will know about them...
  +                             theXalanTransformer.installExternalFunction(
  +                                     theNamespace,
  +                                     XalanDOMString("asctime"),
  +                                     FunctionAsctime());
  +
  +                             theXalanTransformer.installExternalFunction(
  +                                     theNamespace,
  +                                     XalanDOMString("square-root"),
  +                                     FunctionSquareRoot());
  +
  +                             theXalanTransformer.installExternalFunction(
  +                                     theNamespace,
  +                                     XalanDOMString("cube"),
  +                                     FunctionCube());
   
  -                     // Do the transform.
  -                     theResult = theXalanTransformer.transform("foo.xml", 
"foo.xsl", "foo.out");
  +                             // Do the transform.
  +                             theResult = 
theXalanTransformer.transform("foo.xml", "foo.xsl", "foo.out");
       
  -                     if(theResult != 0)
  -                     {
  -                             cerr << "ExternalFunction Error: \n" << 
theXalanTransformer.getLastError()
  -                                      << endl
  -                                      << endl;
  +                             if(theResult != 0)
  +                             {
  +                                     cerr << "ExternalFunction Error: \n" << 
theXalanTransformer.getLastError()
  +                                              << endl
  +                                              << endl;
  +                             }
                        }
  -             }
   
  -             // Terminate Xalan...
  -             XalanTransformer::terminate();
  +                     // Terminate Xalan...
  +                     XalanTransformer::terminate();
  +             }
   
                // Terminate Xerces...
                XMLPlatformUtils::Terminate();
  
  
  
  1.23      +38 -24    
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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- UseStylesheetParam.cpp    20 Aug 2003 15:53:38 -0000      1.22
  +++ UseStylesheetParam.cpp    29 Dec 2003 21:18:58 -0000      1.23
  @@ -94,41 +94,55 @@
        else
        {
                XALAN_USING_XERCES(XMLPlatformUtils)
  +             XALAN_USING_XERCES(XMLException)
  +
   
                XALAN_USING_XALAN(XalanTransformer)
   
                // Call the static initializer for Xerces.
  -             XMLPlatformUtils::Initialize();
  -
  -             // Initialize Xalan.
  -             XalanTransformer::initialize();
  -
  +             try
                {
  -                     XALAN_USING_XALAN(XalanDOMString)
  +                      XMLPlatformUtils::Initialize();
  +             }
  +             catch (const XMLException& toCatch)
  +             {
  +                      cerr << "Error during Xerces initialization! "<< endl;
  +                      theResult = -1;
  +             }
   
  -                     // Create a XalanTransformer.
  -                     XalanTransformer        theXalanTransformer;
  +             if ( theResult == 0)
  +             {
   
  -                     // Set the stylesheet parameter name and
  -                     // expression (a string expression).
  -                     theXalanTransformer.setStylesheetParam(
  -                                     XalanDOMString(argv[1]),
  -                                     XalanDOMString(argv[2]));
  -
  -                     // Our input files...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 << "UseStylesheetParam Error: \n" << 
theXalanTransformer.getLastError()
  -                                      << endl
  -                                      << endl;
  +                             XALAN_USING_XALAN(XalanDOMString)
  +
  +                             // Create a XalanTransformer.
  +                             XalanTransformer        theXalanTransformer;
  +
  +                             // Set the stylesheet parameter name and
  +                             // expression (a string expression).
  +                             theXalanTransformer.setStylesheetParam(
  +                                             XalanDOMString(argv[1]),
  +                                             XalanDOMString(argv[2]));
  +
  +                             // Our input files...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 << "UseStylesheetParam Error: \n" 
<< theXalanTransformer.getLastError()
  +                                              << endl
  +                                              << endl;
  +                             }
                        }
  -             }
   
  -             // Terminate Xalan...
  -             XalanTransformer::terminate();
  +                     // Terminate Xalan...
  +                     XalanTransformer::terminate();
  +             }
   
                // Terminate Xerces...
                XMLPlatformUtils::Terminate();
  
  
  

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

Reply via email to