Using Xalan I have an XalanTransformer that produces output to a file. How do I make it go to standard out instead?
#include <sstream>
#include <xalanc/Include/PlatformDefinitions.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
constexpr auto REPORT_FILE {"report.html"};
....
std::stringstream xml_doc; xml_doc << ....;
std::stringstream style_sheet; style_sheet << ....;
XALAN_USING_XERCES(XMLPlatformUtils)
XALAN_USING_XALAN(XalanTransformer)
XMLPlatformUtils::Initialize();
XalanTransformer::initialize();
XalanTransformer transformer;
transformer.transform(xml_doc, style_sheet, REPORT_FILE);
#include <iostream>
if (transformer.transform(xml_doc, style_sheet, std::cout) != 0)
The input source and result target can be a file name, a stream or a root node.
int xalanc::XalanTransformer::transform (
const XSLTInputSource &theInputSource,
const XalanCompiledStylesheet *heCompiledStylesheet,
const XSLTResultTarget &theResultTarget)
int xalanc::XalanTransformer::transform
The question used a file name the result target. The answer uses a stream, std:cout
.
The global objects std::cout and std::wcout control output to a stream buffer of implementation-defined type (derived from std::streambuf), associated with the standard C output stream stdout.