You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Matt Leinhos <ma...@granularity.net> on 2001/11/29 13:32:14 UTC

XSL trans dies on Windows (C++)

Hello,

I've come across a problem that's got me stumped. I've tried this with
both xalan 1.1 and 1.2 for C++, and the results are the same. A program
I've written runs just fine on Linux (RH 6.1 w/ default g++), but it
crashes on Windows under VC++ 6.0 sp5. On Windows, I am using the same
threading and debugging settings as the libs I'm linking against.

I've narrowed the problem down to XSLEngineImpl::process(). If you can,
please try to run the code at the bottom of my message on windows; the
first 'cerr <<' stmt executes fine, but the next one never executes. It
doesn't matter whether the files I'm parsing exists.

Thank you for your time,
Matt

-- 
Matt Leinhos
matt@granularity.net

"What's that you say, Mrs. Robinson? Joltin' Joe has left and gone away."
  -- Simon and Garfunkel

********* BEGIN FILE xsltTest.cpp

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

#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/XalanOutputStreamPrintWriter.hpp>
#include <PlatformSupport/XalanStdOutputStream.hpp>

#include <DOMSupport/DOMSupportDefault.hpp>

#include <XPath/XObjectFactoryDefault.hpp>
#include <XPath/XPathFactoryDefault.hpp>

#include <XSLT/XSLTInputSource.hpp>

#include <PlatformSupport/XSLException.hpp>
#include <util/XMLException.hpp>
#include <sax/SAXException.hpp>
#include <XalanDOM/XalanDOMException.hpp>

#include <XSLT/StylesheetConstructionContextDefault.hpp>
#include <XSLT/StylesheetExecutionContextDefault.hpp>
#include <XSLT/TraceListenerDefault.hpp>
#include <XSLT/XSLTEngineImpl.hpp>
#include <XSLT/XSLTInit.hpp>
#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
#include <XSLT/XSLTResultTarget.hpp>

#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>

#include <XMLSupport/XMLParserLiaisonDefault.hpp>

#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <stdexcept>

using std::string;
using std::ofstream;
using std::ostringstream;
using std::istringstream;
using std::cerr;
using std::endl;

#include <string.h>
#include <stdlib.h>

void main()
{
	ostringstream errstr;
	bool errOccured = false;

	try {
		XMLPlatformUtils::Initialize();

	  XSLTInit theInit;


	  // Create support objects that are necessary for running the processor...
	  XalanSourceTreeDOMSupport theDOMSupport;

	  XalanSourceTreeParserLiaison
       theXalanSourceTreeParserLiaison(theDOMSupport);

	  // Hook the two together...
	  theDOMSupport.setParserLiaison(&theXalanSourceTreeParserLiaison);

	  // Create some more support objects...
	  XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport;
	  XObjectFactoryDefault theXObjectFactory;
	  XPathFactoryDefault theXPathFactory;

	  // Create a processor...
	  XSLTEngineImpl
	     theProcessor( theXalanSourceTreeParserLiaison,
		     theXSLTProcessorEnvSupport,
		     theDOMSupport, theXObjectFactory, theXPathFactory );

	  // Connect the processor to the support object...
	  theXSLTProcessorEnvSupport.setProcessor(&theProcessor);

	  // Create support objects
	  StylesheetConstructionContextDefault
	     theConstructionContext(theProcessor,
			      theXSLTProcessorEnvSupport, theXPathFactory);

	 StylesheetExecutionContextDefault
	     theExecutionContext(theProcessor,
			   theXSLTProcessorEnvSupport,
			   theDOMSupport, theXObjectFactory);

	 XSLTInputSource theXMLSource       ( "people.xml" );
	 XSLTInputSource theStylesheetSource( "trans.xsl"  );
	 ostringstream theResultOSS;

	 XSLTResultTarget theResultTarget( &theResultOSS );

	 cerr << "preparing to parse" << endl;

	 theProcessor.process( theXMLSource,
			 theStylesheetSource,
			 theResultTarget,
			 theConstructionContext,
			 theExecutionContext);

	  cerr << "done parsing" << endl;

   } // try
   catch( XSLException & e ) {
	  errstr << "XSLProcessorException caught: " << e.getMessage() << endl;
      errOccured = true;
   }
   catch( XSLException * e ) {
      errstr << "XSLException caught: " << e -> getMessage() << endl;
      errOccured = true;
   }
   catch( XMLException & e ) {
      errstr << "XMLException caught: " << e.getMessage() << endl;
      errOccured = true;
   }
   catch( std::exception & e ) {
      errstr << "std::exception caught: " << e.what() << endl
	     << "This is an internal error - please contact this server's "
	     << "administrator." << endl;
      errOccured = true;
   }
   catch( ... ) {
      errstr << "Caught unknown exception " << endl
	     << "This may be an internal error - please contact this server's "
	     << "administrator." << endl;
      errOccured = true;
   }

   XMLPlatformUtils::Terminate();

   if( errOccured ) {
	   cerr << "failed!" << endl;
      cerr << errstr.str() << endl;
      exit(1);
   }

   else {
	   cerr << "exiting successfully" << endl;
      exit(0);
   }
}