cmCTestUploadHandler: Port to cmXMLWriter

This commit is contained in:
Daniel Pfeifer 2015-05-23 23:31:20 +02:00 committed by Brad King
parent ed42c203ed
commit 6cf5cc717f
1 changed files with 25 additions and 21 deletions

View File

@ -13,7 +13,7 @@
#include "cmGeneratedFileStream.h"
#include "cmVersion.h"
#include "cmXMLSafe.h"
#include "cmXMLWriter.h"
//----------------------------------------------------------------------------
cmCTestUploadHandler::cmCTestUploadHandler()
@ -47,32 +47,36 @@ int cmCTestUploadHandler::ProcessHandler()
std::string buildname = cmCTest::SafeBuildIdField(
this->CTest->GetCTestConfiguration("BuildName"));
cmCTest::SetOfStrings::const_iterator it;
ofs << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
<< "<?xml-stylesheet type=\"text/xsl\" "
cmXMLWriter xml(ofs);
xml.StartDocument();
xml.ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" "
"href=\"Dart/Source/Server/XSL/Build.xsl "
"<file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n"
<< "<Site BuildName=\""
<< buildname
<< "\" BuildStamp=\""
<< this->CTest->GetCurrentTag() << "-"
<< this->CTest->GetTestModelString() << "\" Name=\""
<< this->CTest->GetCTestConfiguration("Site") << "\" Generator=\"ctest"
<< cmVersion::GetCMakeVersion()
<< "\">\n";
this->CTest->AddSiteProperties(ofs);
ofs << "<Upload>\n";
"<file:///Dart/Source/Server/XSL/Build.xsl> \"");
xml.StartElement("Site");
xml.Attribute("BuildName", buildname);
xml.Attribute("BuildStamp",
this->CTest->GetCurrentTag() + "-" + this->CTest->GetTestModelString());
xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
xml.Attribute("Generator",
std::string("ctest") + cmVersion::GetCMakeVersion());
this->CTest->AddSiteProperties(xml);
xml.StartElement("Upload");
for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
{
cmCTestOptionalLog(this->CTest, OUTPUT,
"\tUpload file: " << *it << std::endl, this->Quiet);
ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n"
<< "<Content encoding=\"base64\">\n";
ofs << this->CTest->Base64EncodeFile(*it);
ofs << "\n</Content>\n"
<< "</File>\n";
xml.StartElement("File");
xml.Attribute("filename", *it);
xml.StartElement("Content");
xml.Attribute("encoding", "base64");
xml.Content(this->CTest->Base64EncodeFile(*it));
xml.EndElement(); // Content
xml.EndElement(); // File
}
ofs << "</Upload>\n"
<< "</Site>\n";
xml.EndElement(); // Upload
xml.EndElement(); // Site
xml.EndDocument();
return 0;
}