7 #include <xercesc/dom/DOMNode.hpp>
8 #include <xercesc/dom/DOM.hpp>
9 #include <xercesc/parsers/XercesDOMParser.hpp>
10 #include <xercesc/util/XMLString.hpp>
11 #include <xercesc/sax/SAXException.hpp>
12 #include <xercesc/framework/LocalFileFormatTarget.hpp>
17 using namespace XERCES_CPP_NAMESPACE;
31 XercesDOMParser*
parser =
new XercesDOMParser;
32 parser->setValidationScheme(XercesDOMParser::Val_Never);
33 parser->setDoNamespaces(
false);
34 parser->setDoSchema(
false);
36 parser->parse(filename.c_str());
38 DOMDocument* xmlDoc = parser->getDocument();
40 std::cout <<
"EcalLaserAPDPNRatiosXMLTranslator::Error parsing document" << std::endl;
44 DOMElement* elementRoot = xmlDoc->getDocumentElement();
85 cellnode = cellnode->getNextSibling();
87 while (cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
88 cellnode = cellnode->getNextSibling();
101 std::fstream fs(filename.c_str(),
ios::out);
111 unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(
cms::xerces::uStr(
"LS").ptr()));
113 DOMLSSerializer* writer = impl->createLSSerializer();
114 if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true))
115 writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
117 DOMDocumentType* doctype = impl->createDocumentType(
cms::xerces::uStr(
"XML").ptr(),
nullptr,
nullptr);
119 DOMElement* root = doc->getDocumentElement();
123 string Lasertag =
"Laser", LMtag =
"LM";
124 for (
int cellid = 0; cellid < (int)record.
getTimeMap().size(); cellid++) {
125 DOMElement* cellnode = doc->createElement(
cms::xerces::uStr(Lasertag.c_str()).ptr());
126 root->appendChild(cellnode);
127 stringstream value_s;
132 t123[0] = (record.
getTimeMap())[cellid].t1.value();
133 t123[1] = (record.
getTimeMap())[cellid].t2.value();
134 t123[2] = (record.
getTimeMap())[cellid].t3.value();
135 string Laser_t_tag[3] = {
"t1",
"t2",
"t3"};
136 for (
int i = 0;
i < 3;
i++) {
137 time_t
t = t123[
i] >> 32;
140 localtime_r(&t, <);
141 strftime(buf,
sizeof(buf),
"%F %R:%S", <);
142 buf[
sizeof(
buf) - 1] = 0;
143 DOMDocument* subdoc = cellnode->getOwnerDocument();
144 DOMElement* new_node = subdoc->createElement(
cms::xerces::uStr(Laser_t_tag[
i].c_str()).ptr());
145 cellnode->appendChild(new_node);
146 std::stringstream value_ss;
148 string newstr = value_ss.str() +
" [" +
string(buf) +
"]";
149 DOMText* tvalue = subdoc->createTextNode(
cms::xerces::uStr(newstr.c_str()).ptr());
150 new_node->appendChild(tvalue);
157 DOMElement* cellnode =
writeCell(root, rawid);
174 DOMElement* cellnode =
writeCell(root, rawid);
static int readXML(const std::string &filename, EcalCondHeader &header, EcalLaserAPDPNRatios &record)
static std::string dumpXML(const EcalCondHeader &header, const EcalLaserAPDPNRatios &record)
const std::string Laser_p3_tag("p3")
static EEDetId unhashIndex(int hi)
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
static bool validHashIndex(int i)
std::string toString(XMLCh const *toTranscode)
const EcalLaserAPDPNRatiosMap & getLaserMap() const
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
static const int MIN_HASH
const std::string Cell_tag("cell")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
const std::string Laser_p1_tag("p1")
ZStr< XMLCh > uStr(char const *str)
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalLaserAPDPNRatios &record)
const std::string WeightGroups_tag("EcalWeightGroups")
const EcalLaserTimeStampMap & getTimeMap() const
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
const std::string Laser_p2_tag("p2")
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
tuple dump
OutputFilePath = cms.string('/tmp/zhokin/'), OutputFileExt = cms.string(''),.