Go to the documentation of this file.00001 #include "DQM/SiStripMonitorClient/interface/SiStripConfigWriter.h"
00002
00003
00004 #include "DQMServices/ClientConfig/interface/ParserFunctions.h"
00005
00006
00007
00008
00009 SiStripConfigWriter::SiStripConfigWriter() {
00010 }
00011
00012
00013
00014 SiStripConfigWriter::~SiStripConfigWriter() {
00015
00016 }
00017
00018
00019
00020 bool SiStripConfigWriter::init(std::string main) {
00021 xercesc::XMLPlatformUtils::Initialize();
00022
00023 xercesc::DOMImplementation* domImpl = xercesc::DOMImplementationRegistry::getDOMImplementation(qtxml::_toDOMS("Range"));
00024 if (!domImpl) return false;
00025 domWriter = (dynamic_cast<xercesc::DOMImplementation*>(domImpl))->createDOMWriter();
00026 if (!domWriter) return false;
00027 domWriter->canSetFeature(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint, true);
00028 theDoc = domImpl->createDocument(0,qtxml::_toDOMS(main), 0);
00029 if (!theDoc) return false;
00030 theTopElement = theDoc->getDocumentElement();
00031 return true;
00032 }
00033
00034
00035
00036 void SiStripConfigWriter::createElement(std::string tag) {
00037 theTopElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00038 lastElement = theDoc->createElement(qtxml::_toDOMS(tag));
00039 theTopElement->appendChild(lastElement);
00040 }
00041
00042
00043
00044 void SiStripConfigWriter::createElement(std::string tag, std::string name) {
00045 theTopElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00046 lastElement = theDoc->createElement(qtxml::_toDOMS(tag));
00047 lastElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name));
00048 theTopElement->appendChild(lastElement);
00049 }
00050
00051
00052
00053 void SiStripConfigWriter::createChildElement(std::string tag, std::string name) {
00054
00055 lastElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00056 xercesc::DOMElement* newElement = theDoc->createElement(qtxml::_toDOMS(tag));
00057 newElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name));
00058 lastElement->appendChild(newElement);
00059 }
00060
00061
00062
00063 void SiStripConfigWriter::createChildElement(std::string tag, std::string name, std::string att_name, std::string att_val) {
00064
00065 lastElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00066 xercesc::DOMElement* newElement = theDoc->createElement(qtxml::_toDOMS(tag));
00067 newElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name));
00068 newElement->setAttribute(qtxml::_toDOMS(att_name), qtxml::_toDOMS(att_val));
00069
00070 lastElement->appendChild(newElement);
00071
00072 }
00073
00074
00075
00076 void SiStripConfigWriter::createChildElement(std::string tag,std::string name,std::string att_name1, std::string att_val1,
00077 std::string att_name2, std::string att_val2) {
00078 lastElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00079 xercesc::DOMElement* newElement = theDoc->createElement(qtxml::_toDOMS(tag));
00080 newElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name));
00081 newElement->setAttribute(qtxml::_toDOMS(att_name1), qtxml::_toDOMS(att_val1));
00082 newElement->setAttribute(qtxml::_toDOMS(att_name2), qtxml::_toDOMS(att_val2));
00083 lastElement->appendChild(newElement);
00084
00085 }
00086
00087
00088
00089 void SiStripConfigWriter::createChildElement(std::string tag,std::string name,std::string att_name1, std::string att_val1,
00090 std::string att_name2, std::string att_val2,
00091 std::string att_name3, std::string att_val3) {
00092
00093 lastElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n")));
00094 xercesc::DOMElement* newElement = theDoc->createElement(qtxml::_toDOMS(tag));
00095 newElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name));
00096 newElement->setAttribute(qtxml::_toDOMS(att_name1), qtxml::_toDOMS(att_val1));
00097 newElement->setAttribute(qtxml::_toDOMS(att_name2), qtxml::_toDOMS(att_val2));
00098 newElement->setAttribute(qtxml::_toDOMS(att_name3), qtxml::_toDOMS(att_val3));
00099 lastElement->appendChild(newElement);
00100
00101 }
00102
00103
00104
00105 void SiStripConfigWriter::write(std::string fname) {
00106 xercesc::XMLFormatTarget* formTarget = new xercesc::LocalFileFormatTarget(fname.c_str());
00107 domWriter->writeNode(formTarget, *theTopElement);
00108 delete formTarget;
00109 theDoc->release();
00110 }