4
4
// ----- a report for the specified colleges of how they accept the results for the various tests and what specific courses they give
5
5
// ----- credit for at their schools with links to the school's pages on the collegeboard.org web site.
7
// 10Apr'18 C.W.Holeman II
8
// Initialize stringstreams with constructor.
9
// 14Mar'18 C.W.Holeman II
10
// Output to standard out instead of hardcoded file name.
7
11
// 13Mar'18 C.W.Holamen II
8
12
// Remove hard coded filename for input college list, using standard input instead. Added timestamp to output file name.
9
13
// 11Mar'18 C.W.Holeman II
57
61
#include "aptcp_tidydoc.hpp"
61
64
// ----- Create XML document content by concatenating the table from each college's policy page.
63
std::stringstream xml_doc; xml_doc << APTCP_XML_DOC_PREFIX;
66
std::stringstream xml_doc(APTCP_XML_DOC_PREFIX, std::ios::in | std::ios::out | std::ios::ate);
65
std::set<College> colleges{}; {
66
std::copy(std::istream_iterator<College>{std::cin},
67
std::istream_iterator<College>{},
68
std::inserter(colleges, colleges.begin()));
70
for (auto c: colleges){
71
auto page {tidy_up_html(fetch_page(c.url())).value_or("optional-empty"+c.name())};
72
auto b {page.find(APTCP_CONTENT_BEGIN)};
73
if (b != std::string::npos){ // Has content?
74
xml_doc << page.substr(b).substr(0,page.substr(b).find(APTCP_CONTENT_END)+std::strlen(APTCP_CONTENT_END)) // Extract it.
75
<< "<info>" << c << "</info>\n";
68
std::set<College> colleges {}; std::copy(std::istream_iterator<College> {std::cin}, std::istream_iterator<College> {},
69
std::inserter(colleges, colleges.begin()));
70
for (auto c : colleges) {
71
auto page {tidy_up_html(fetch_page(c.url()))};
72
if (auto b {page.find(APTCP_CONTENT_BEGIN)}; b != std::string::npos) { // Has content?
73
xml_doc << page.substr(b).substr(0,page.substr(b).find(APTCP_CONTENT_END)+std::strlen(APTCP_CONTENT_END)) // Extract it.
74
<< "<info>" << c << "</info>\n";
78
77
xml_doc << "<warning>" << c << "</warning>\n";
84
83
// ----- Create XSLT style sheet.
86
std::stringstream style_sheet; style_sheet << APTCP_XSLT;
85
std::stringstream style_sheet(APTCP_XSLT, std::ios::in | std::ios::out | std::ios::ate);
88
// ----- Create the transformer.
87
// ----- Create the transformer.
90
89
XALAN_USING_XERCES(XMLPlatformUtils)
91
90
XALAN_USING_XALAN(XalanTransformer)
92
91
XMLPlatformUtils::Initialize();
93
92
XalanTransformer::initialize();
94
XalanTransformer transformer;
95
auto now {std::time(nullptr)};
96
transformer.setStylesheetParam("current_time_p", ("'" + std::string{std::asctime(std::localtime(&now))} + "'").c_str());
98
// ----- Use the transformer to invoke the XSLT style sheet on the XML document.
100
if (transformer.transform(xml_doc, style_sheet, std::cout) != 0) {
93
XalanTransformer transformer {};
95
auto now {std::time(nullptr)};
96
transformer.setStylesheetParam("current_time_p", ("'" + std::string {std::asctime(std::localtime(&now))}+ "'").c_str());
99
// ----- Use the transformer to invoke the XSLT style sheet on the XML document.
101
if (transformer.transform(xml_doc, style_sheet, std::cout) != 0)
101
102
std::cerr << "aptcp/main()/transformer.getLastError(): " << transformer.getLastError() << "\n" << style_sheet.str() << xml_doc.str();