Hi Miro,

This the number one Xerces FAQ.  You cannot call XMLPlatforms::Terminate()
more than once per process.

Although you _can_ call XalanTransformer::initialize() and
XalanTransformer::terminate() more than once per process, it is extremely
efficient to do so, and those calls must be synchronized at the application
level.  If you're not synchronizing those calls, that's the problem.  The
documentation for XalanTransformer::initialize() and
XalanTransformer::terminate() is explicit about this.  From
XalanTransformer.hpp:

     /**
      * Initialize Xalan.
      * Should be called only once per process before creating any
      * instances of XalanTransformer. See class XSLTInit.
      */
     static void
     initialize();

     /**
      * Terminate Xalan.
      * Should be called only once per process after deleting all
      * instances of XalanTransformer. See class XSLTInit.
      */
     static void
     terminate();

This is also made quite clear in all of the sample applications we ship.

I urge you to read the Xerces and Xalan documentation thoroughly before you
post questions to the list.  It will save all of us, but especially
yourself, lots of time.  If, after reading the documentation, you still
feel these points are not clear, please feel free to post suggestions for
the documentation to the list.

By the way, transforming to an ostrstream can be extremely inefficient.  I
suggest you take a look at the callback interfaces in XalanTransformer,
which will allow you to get the results of the transformation directly,
rather than writing it to a dynamically allocated string.  The performance
improvement will be considerable.

Dave



                                                                                
          
                    [EMAIL PROTECTED]                                           
              
                    eus.net              To:     [email protected]   
          
                                         cc:     (bcc: David N 
Bertoni/CAM/Lotus)         
                    10/30/2001           Subject:     Coredump when using       
          
                    07:53 AM             XalanTransformer.transform()           
          
                                                                                
          
                                                                                
          




Hello,

I am using Xalan ver. 1.2 and Xerces ver. 1.5. on HP-UX 11.00. I rebuilt
the libraries with the following options:

runConfigure -p hp-11 -c cc -x aCC -d -r pthread
gmake

I am running a multithreaded application (currently only 2 threads). Each
thread performs XSL transformation using the following code:

Each thread, after it has been created, calls the initialization:
XMLPlatformUtils::Initialize() ;
XalanTransformer::initialize() ;

before it stops, it does clean-up:
XalanTransformer::terminate() ;
XMLPlatformUtils::Terminate() ;

and in between repeatedly (some hundreds of times) performs transformation
using XalanTransformer class and memory streams:

XalanTransformer  theTransformer ;

istrstream        theXMLStream( x.GetOutMsg(), x.GetOutMsgLength() ) ;
istrstream        theXSLStream( pMessage->GetXSL().IntBufNotNull(),
pMessage->GetXSL().Length() ) ;
ostrstream  theOutStream ;

// ---- Set style sheet parameter "UID" equals to ulUID
theTransformer.setStylesheetParam( XalanDOMString(XSL_PARAM_UID),
XalanDOMString(svUID) ) ;
// ---- Perform Xalan transformation
if( theTransformer.transform( &theXMLStream, &theXSLStream, &theOutStream )
== 0 )
  {
  ...

If the traffic is high, the application coredumps in call to the transform
() method. The stack is:
from transform() call to /opt/aCC/include/tree.cc (14 levels incl.
endElement and erase).
If I am running one thread, everything is alright - no coredump.

The stack:
erase(iterator&,iterator)
erase(iterator&,iterator,iterator)
erase(ElemTemplateElement *&)
endElement
endElement
scanEndTag
scanContent
scanDocument(InputSource&,?)
parse(InputSource&,?)
parseXMLStream(InputSource&,DocumentHandler&,XalanDOMString&)
parseXMLStream(InputSource&,DocumentHandler&,XalanDOMString&)
processStylesheet(XSLTInputSource&,StylesheetConstructionContext&)
...
process(XSLTInputSource&,XSLTInputSource&,XSLTResultTarget&)

My question is: Did I do anything wrong? Any help appreciated.
Thanks in advance, Miro.



Reply via email to