xalan-c 1.10 problem with XalanTransformer.transform
Hello,
I have a problem with transforming a few streams. First stream always goes
correctly, while second is transforming, I receive:
XSLT Warning: Fatal Error.Occurred at unknown file, line 1, column 1. Invalid
document structure (line 1, column 1.)
SAXParseException: Invalid document structure (, line 1, column 1)
Why ? What's wrong with my code ?
void generate_traces(
const std::string targetIP,
unsigned iterationsNumber,
unsigned connectionsNumber,
unsigned instancesNumber,
const std::string traceType,
const std::string dir,
unsigned sleepTime,
const std::string traceMode,
unsigned isBinary = 0
)
{
XmlPlatformJanitor xercesJanitor;
xalanc::XalanTransformer::initialize();
xalanc::XalanTransformer theXalanTransformer;
std::list<std::string> contentList;
if (fs::is_directory(dir))
{
std::string tempString;
for (fs::directory_iterator itr(dir); itr!=fs::directory_iterator();
++itr)
{
if (fs::is_regular_file(itr->status()) && strcmp(itr-
path().extension().c_str(),".xml")==0)
{
std::cout << itr->path().filename() << ' ' << itr-
path().extension() << '\n'; // display filename only
std::ifstream ifs(itr->path().string().c_str());
contentList.push_front(tempString.assign(
(std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()) ));
}
}
}
// stream xsl
std::stringstream xsl_stream(std::stringstream::in | std::stringstream::out);
xsl_stream << pmtrace::generateXsl<pmtrace::MsgReport>();
xalanc::XSLTInputSource xslIn(xsl_stream);
std::list< std::list<std::string> > streamsList;
std::list<std::string> streamList;
//generating data streams
for (int i=0; i<instancesNumber; i++)
{
std::string uniqueMccMncId = get_number_full_string();
std::string uniqueTraceId = get_number_full_string();
for (std::list<std::string>::const_iterator it = contentList.begin(); it
!= contentList.end(); ++it)
{
std::stringstream result_stream(std::stringstream::in |
std::stringstream::out);
std::stringstream tempstream(std::stringstream::in |
std::stringstream::out);
std::string s = *it;
tempstream << s;
xalanc::XSLTInputSource xmlIn(tempstream);
xalanc::XSLTResultTarget xmlOut(result_stream);
int theResult = theXalanTransformer.transform(xmlIn, xslIn, xmlOut);
if(theResult != 0)
{
std::cout << theXalanTransformer.getLastError() << std::endl;
}
streamList.push_back(result_stream.str());
}
streamsList.push_back(streamList);
streamList.clear();
}
//print_list_of_list_of_string(streamsList);
std::cout << "Size: " << streamsList.size() << "\n";
xalanc::XalanTransformer::terminate();
xalanc::XalanTransformer::ICUCleanUp();
}