You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Holger Floerke <fl...@doctronic.de> on 2002/03/15 10:37:03 UTC

Xalan-C++ - XercesDOMWrapperParsedSource consuming memory

Hi there,

   I try to use the Xalan-C++ TransformerAPI to transform a Xerces-DOM. As 
mentioned in the "usage patterns" I have to use 
XercesDOMWrapperParsedSource to do this. Fine, works.

   The problem is, I see the memory growing in my task-manager (Xalan-C++ 
1.3, Win32 on W2KSP2). You can reproduce this with a simple code I have 
added to this Mail.

   My question is: Am I wrong in using XercesDOMWrapperParsedSource, or is 
this a bug (then I will post it to the bug database)?


tia

HolgeR


#include <Include/PlatformDefinitions.hpp>
#include <util/PlatformUtils.hpp>
#include <parsers/DOMParser.hpp>


#include <XalanTransformer/XalanTransformer.hpp>

#include <XalanTransformer/XercesDOMWrapperParsedSource.hpp>
#include <XercesParserLiaison/XercesParserLiaison.hpp>
#include <XercesParserLiaison/XercesDOMSupport.hpp>

#include <stdio.h>

#include <strstream>
using namespace std;

void main()
{
   XMLPlatformUtils::Initialize();
   XalanTransformer::initialize();

   XercesDOMSupport oDOMSupport;
   XercesParserLiaison oParserLiaison(oDOMSupport);


   // using Xerces-DOM as Source
   DOM_DOMImplementation oImplementation;

   DOM_Document oDocument = oImplementation.createDocument(
                "http://foo",
                "foo:fritz",
                DOM_DocumentType());

   // transforming to death...
   XalanTransformer oTransformer;

   for (;;)
   {
     // using ostrstream as Result
     ostrstream oOStream;

     XSLTResultTarget oResult(oOStream);

     // using istrstream as Stylesheet
     char* pcStylesheet = "<?xml version=\"1.0\"?>\
   <xsl:stylesheet version=\"1.0\" \
   xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"> \
   <xsl:template match=\"fritz\"><A>result</A></xsl:template> \
   </xsl:stylesheet>";

     istrstream oIStream(pcStylesheet,strlen(pcStylesheet));

     XSLTInputSource oStylesheet(&oIStream);


     // consuming memory ???
     const XercesDOMWrapperParsedSource
         oSource (oDocument,
                  oParserLiaison,
                  oDOMSupport,
                  XalanDOMString("FormatterInputSource"));

     // ok
     /*char* pcSource = "<?xml version=\"1.0\"?><foo:fritz 
xmlns:foo=\"http://foo\"/>";
     istrstream oIStreamSource(pcSource,strlen(pcSource));
     XSLTInputSource oSource(&oIStreamSource);*/

     int nResult =
       oTransformer.transform(oSource,
                              oStylesheet,
                              oResult);


     // Am I right?
     oTransformer.destroyParsedSource(&oSource);

     if (nResult != 0)
     {
       printf("XSLTFormatter: Fehler bei der Transformation %i ('%s')",
              nResult,
              oTransformer.getLastError());
       break;
     }
     else
     {
       printf("*");
     };



     delete [] oOStream.str();
   };
}