diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 48a7ec741..16edd1faa 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1719,54 +1719,56 @@ void cmCTest::EndXML(cmXMLWriter& xml) } //---------------------------------------------------------------------- -int cmCTest::GenerateCTestNotesOutput(std::ostream& os, +int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml, const cmCTest::VectorOfStrings& files) { std::string buildname = cmCTest::SafeBuildIdField( this->GetCTestConfiguration("BuildName")); cmCTest::VectorOfStrings::const_iterator it; - os << "\n" - << " \"?>\n" - << "CurrentTag << "-" << this->GetTestModelString() << "\" Name=\"" - << this->GetCTestConfiguration("Site") << "\" Generator=\"ctest" - << cmVersion::GetCMakeVersion() - << "\">\n"; - this->AddSiteProperties(os); - os << "" << std::endl; + " \""); + xml.StartElement("Site"); + xml.Attribute("BuildName", buildname); + xml.Attribute("BuildStamp", this->CurrentTag+"-"+this->GetTestModelString()); + xml.Attribute("Name", this->GetCTestConfiguration("Site")); + xml.Attribute("Generator",std::string("ctest")+cmVersion::GetCMakeVersion()); + this->AddSiteProperties(xml); + xml.StartElement("Notes"); for ( it = files.begin(); it != files.end(); it ++ ) { cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl); std::string note_time = this->CurrentTime(); - os << "\n" - << "\n" - << "" << note_time << "\n" - << "" << std::endl; + xml.StartElement("Note"); + xml.Attribute("Name", *it); + xml.Element("Time", cmSystemTools::GetTime()); + xml.Element("DateTime", note_time); + xml.StartElement("Text"); cmsys::ifstream ifs(it->c_str()); if ( ifs ) { std::string line; while ( cmSystemTools::GetLineFromStream(ifs, line) ) { - os << cmXMLSafe(line) << std::endl; + xml.Content(line); + xml.Content("\n"); } ifs.close(); } else { - os << "Problem reading file: " << *it << std::endl; + xml.Content("Problem reading file: " + *it + "\n"); cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << *it << " while creating notes" << std::endl); } - os << "\n" - << "" << std::endl; + xml.EndElement(); // Text + xml.EndElement(); // Note } - os << "\n" - << "" << std::endl; + xml.EndElement(); // Notes + xml.EndElement(); // Site + xml.EndDocument(); return 1; } @@ -1779,8 +1781,8 @@ int cmCTest::GenerateNotesFile(const VectorOfStrings &files) cmCTestLog(this, ERROR_MESSAGE, "Cannot open notes file" << std::endl); return 1; } - - this->GenerateCTestNotesOutput(ofs, files); + cmXMLWriter xml(ofs); + this->GenerateCTestNotesOutput(xml, files); return 0; } diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 47c337a73..7153e8f82 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -557,7 +557,7 @@ private: bool UpdateCTestConfiguration(); //! Create note from files. - int GenerateCTestNotesOutput(std::ostream& os, + int GenerateCTestNotesOutput(cmXMLWriter& xml, const VectorOfStrings& files); //! Check if the argument is the one specified