// 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 #include #include #include #include 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 = "My first XML ISTREAM Page!!"; 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; }