// This example uses an xslt source file, and outputs the result to stdout.
// But, it uses an istream to hold the XML, instead of using an xml source file.

// 1. include required headers
//
#include <Include/PlatformDefinitions.hpp>
#include <util/PlatformUtils.hpp>
#include <XalanTransformer/XalanTransformer.hpp>


#include <iostream>
#include <strstream>
#include <string>

using namespace std;
int main(void)
{

	// 2. Initialize Xerces and Xalan
	//
	XMLPlatformUtils::Initialize();
	XalanTransformer::initialize();

	// 3. Create a XalanTransformer
	//
	XalanTransformer theXalanTransformer;

	// 4. Prepare the input and output sources
	//
	std::string xmlstring  = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><maphrase>My first XML ISTREAM Page!!</maphrase>";
	istrstream istr(xmlstring.c_str(), xmlstring.length());

	
	XSLTInputSource xmlIn(&istr);
	XSLTInputSource xslIn("foo.xsl");
	XSLTResultTarget xmlOut(cout);


	cout << "Content-Type: text/html\n\n";

	// 5. Perform the transformation
	//
	int theResult = theXalanTransformer.transform(xmlIn, xslIn, xmlOut);
	
	// 6. 0 result means no error
	//
	cout << "Result of Transformation  is " << theResult << "\n";


	// 5. Shutdown the transformation engines...
	//
	XalanTransformer::terminate();
	XMLPlatformUtils::Terminate();
	XalanTransformer::ICUCleanUp();
	
	return 0;
}



