10 #include <xercesc/dom/DOMDocument.hpp> 11 #include <xercesc/dom/DOMNodeList.hpp> 22 }
catch (xercesc::XMLException &
e) {
23 char *message = xercesc::XMLString::transcode(e.getMessage());
25 std::cerr <<
"XML toolkit initialization error: " << message << std::endl;
33 parser_ =
new xercesc::XercesDOMParser();
42 }
catch (xercesc::XMLException &
e) {
43 char *message = xercesc::XMLString::transcode(e.getMessage());
44 std::cerr <<
"XML toolkit teardown error: " << message << std::endl;
63 xercesc::DOMNodeList *d1Nodes = element->getElementsByTagName(
tags_->
TAG_1D);
64 const XMLSize_t d1Count = d1Nodes->getLength();
66 for (XMLSize_t d1Index = 0; d1Index < d1Count; ++d1Index) {
67 xercesc::DOMNode *d1Node = d1Nodes->item(d1Index);
69 xercesc::DOMElement *d1Element =
dynamic_cast<xercesc::DOMElement *
>(d1Node);
72 c = xercesc::XMLString::transcode(d1titleXMLCh);
79 c = xercesc::XMLString::transcode(d1xbinsXMLCh);
86 c = xercesc::XMLString::transcode(d1xfromXMLCh);
92 const XMLCh *d1xtoXMLCh = d1Element->getAttribute(
tags_->
ATTR_XTO);
93 c = xercesc::XMLString::transcode(d1xtoXMLCh);
100 c = xercesc::XMLString::transcode(d1ncycleXMLCh);
106 const XMLCh *d1loopXMLCh = d1Element->getAttribute(
tags_->
ATTR_LOOP);
107 c = xercesc::XMLString::transcode(d1loopXMLCh);
121 xercesc::DOMNodeList *d2Nodes = element->getElementsByTagName(
tags_->
TAG_2D);
122 const XMLSize_t d2Count = d2Nodes->getLength();
124 for (XMLSize_t d2Index = 0; d2Index < d2Count; ++d2Index) {
125 xercesc::DOMNode *d2Node = d2Nodes->item(d2Index);
127 xercesc::DOMElement *d2Element =
dynamic_cast<xercesc::DOMElement *
>(d2Node);
129 const XMLCh *d2titleXMLCh = d2Element->getAttribute(
tags_->
ATTR_TITLE);
130 c = xercesc::XMLString::transcode(d2titleXMLCh);
136 const XMLCh *d2xbinsXMLCh = d2Element->getAttribute(
tags_->
ATTR_XBINS);
137 c = xercesc::XMLString::transcode(d2xbinsXMLCh);
143 const XMLCh *d2xfromXMLCh = d2Element->getAttribute(
tags_->
ATTR_XFROM);
144 c = xercesc::XMLString::transcode(d2xfromXMLCh);
150 const XMLCh *d2xtoXMLCh = d2Element->getAttribute(
tags_->
ATTR_XTO);
151 c = xercesc::XMLString::transcode(d2xtoXMLCh);
157 const XMLCh *d2ybinsXMLCh = d2Element->getAttribute(
tags_->
ATTR_YBINS);
158 c = xercesc::XMLString::transcode(d2ybinsXMLCh);
164 const XMLCh *d2yfromXMLCh = d2Element->getAttribute(
tags_->
ATTR_YFROM);
165 c = xercesc::XMLString::transcode(d2yfromXMLCh);
171 const XMLCh *d2ytoXMLCh = d2Element->getAttribute(
tags_->
ATTR_YTO);
172 c = xercesc::XMLString::transcode(d2ytoXMLCh);
179 c = xercesc::XMLString::transcode(d2ncycleXMLCh);
185 const XMLCh *d2loopXMLCh = d2Element->getAttribute(
tags_->
ATTR_LOOP);
186 c = xercesc::XMLString::transcode(d2loopXMLCh);
197 xercesc::DOMNodeList *tpNodes = element->getElementsByTagName(
tags_->
TAG_TPROFILE);
198 const XMLSize_t tpCount = tpNodes->getLength();
200 for (XMLSize_t tpIndex = 0; tpIndex < tpCount; ++tpIndex) {
201 xercesc::DOMNode *tpNode = tpNodes->item(tpIndex);
203 xercesc::DOMElement *tpElement =
dynamic_cast<xercesc::DOMElement *
>(tpNode);
205 const XMLCh *tptitleXMLCh = tpElement->getAttribute(
tags_->
ATTR_TITLE);
206 c = xercesc::XMLString::transcode(tptitleXMLCh);
207 me.
type =
"tprofile";
212 const XMLCh *tpxbinsXMLCh = tpElement->getAttribute(
tags_->
ATTR_XBINS);
213 c = xercesc::XMLString::transcode(tpxbinsXMLCh);
219 const XMLCh *tpxfromXMLCh = tpElement->getAttribute(
tags_->
ATTR_XFROM);
220 c = xercesc::XMLString::transcode(tpxfromXMLCh);
226 const XMLCh *tpxtoXMLCh = tpElement->getAttribute(
tags_->
ATTR_XTO);
227 c = xercesc::XMLString::transcode(tpxtoXMLCh);
233 const XMLCh *tpybinsXMLCh = tpElement->getAttribute(
tags_->
ATTR_YBINS);
234 c = xercesc::XMLString::transcode(tpybinsXMLCh);
240 const XMLCh *tpyfromXMLCh = tpElement->getAttribute(
tags_->
ATTR_YFROM);
241 c = xercesc::XMLString::transcode(tpyfromXMLCh);
247 const XMLCh *tpytoXMLCh = tpElement->getAttribute(
tags_->
ATTR_YTO);
248 c = xercesc::XMLString::transcode(tpytoXMLCh);
255 c = xercesc::XMLString::transcode(tpncycleXMLCh);
261 const XMLCh *tploopXMLCh = tpElement->getAttribute(
tags_->
ATTR_LOOP);
262 c = xercesc::XMLString::transcode(tploopXMLCh);
274 const XMLSize_t tp2dCount = tp2dNodes->getLength();
276 for (XMLSize_t tp2dIndex = 0; tp2dIndex < tp2dCount; ++tp2dIndex) {
277 xercesc::DOMNode *tp2dNode = tp2dNodes->item(tp2dIndex);
279 xercesc::DOMElement *tp2dElement =
dynamic_cast<xercesc::DOMElement *
>(tp2dNode);
281 const XMLCh *tp2dtitleXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_TITLE);
282 c = xercesc::XMLString::transcode(tp2dtitleXMLCh);
283 me.
type =
"tprofile2d";
288 const XMLCh *tp2dxbinsXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_XBINS);
289 c = xercesc::XMLString::transcode(tp2dxbinsXMLCh);
295 const XMLCh *tp2dxfromXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_XFROM);
296 c = xercesc::XMLString::transcode(tp2dxfromXMLCh);
302 const XMLCh *tp2dxtoXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_XTO);
303 c = xercesc::XMLString::transcode(tp2dxtoXMLCh);
309 const XMLCh *tp2dybinsXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_YBINS);
310 c = xercesc::XMLString::transcode(tp2dybinsXMLCh);
316 const XMLCh *tp2dyfromXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_YFROM);
317 c = xercesc::XMLString::transcode(tp2dyfromXMLCh);
323 const XMLCh *tp2dytoXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_YTO);
324 c = xercesc::XMLString::transcode(tp2dytoXMLCh);
330 const XMLCh *tp2dzbinsXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_ZBINS);
331 c = xercesc::XMLString::transcode(tp2dzbinsXMLCh);
337 const XMLCh *tp2dzfromXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_ZFROM);
338 c = xercesc::XMLString::transcode(tp2dzfromXMLCh);
344 const XMLCh *tp2dztoXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_ZTO);
345 c = xercesc::XMLString::transcode(tp2dztoXMLCh);
351 const XMLCh *tp2dncycleXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_NCYCLE);
352 c = xercesc::XMLString::transcode(tp2dncycleXMLCh);
358 const XMLCh *tp2dloopXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_LOOP);
359 c = xercesc::XMLString::transcode(tp2dloopXMLCh);
366 xercesc::DOMNodeList *qNodes = element->getElementsByTagName(
tags_->
TAG_QUERY);
367 const XMLSize_t qCount = qNodes->getLength();
369 for (XMLSize_t qIndex = 0; qIndex < qCount; ++qIndex) {
370 xercesc::DOMNode *qNode = qNodes->item(qIndex);
372 xercesc::DOMElement *qElement =
dynamic_cast<xercesc::DOMElement *
>(qNode);
374 const XMLCh *nameXMLCh = qElement->getAttribute(
tags_->
ATTR_NAME);
375 c = xercesc::XMLString::transcode(nameXMLCh);
377 const XMLCh *argXMLCh = qElement->getAttribute(
tags_->
ATTR_ARG);
378 char *
d = xercesc::XMLString::transcode(argXMLCh);
381 char *
e = xercesc::XMLString::transcode(aliasXMLCh);
388 me.
queries.push_back(tmpQuery);
403 parser_->setValidationScheme(xercesc::XercesDOMParser::Val_Never);
404 parser_->setDoNamespaces(
false);
406 parser_->setLoadExternalDTD(
false);
411 xercesc::DOMDocument *xmlDoc =
parser_->getDocument();
413 xercesc::DOMElement *dbe = xmlDoc->getDocumentElement();
415 if (
nullptr == dbe) {
416 throw(std::runtime_error(
"empty XML document"));
420 xercesc::DOMNodeList *
children = dbe->getChildNodes();
421 const XMLSize_t nodeCount = children->getLength();
423 for (XMLSize_t ix = 0; ix < nodeCount; ++ix) {
424 xercesc::DOMNode *currentNode = children->item(ix);
425 if (
nullptr == currentNode) {
430 if (xercesc::DOMNode::ELEMENT_NODE != currentNode->getNodeType()) {
434 xercesc::DOMElement *currentElement =
dynamic_cast<xercesc::DOMElement *
>(currentNode);
440 }
catch (xercesc::XMLException &
e) {
441 char *message = xercesc::XMLString::transcode(e.getMessage());
443 std::ostringstream buf;
444 buf <<
"Error parsing file: " << message << std::endl;
448 throw(std::runtime_error(buf.str()));
450 }
catch (
const xercesc::DOMException &e) {
451 char *message = xercesc::XMLString::transcode(e.getMessage());
453 std::ostringstream buf;
454 buf <<
"Encountered DOM Exception: " << message << std::endl;
458 throw(std::runtime_error(buf.str()));
MonitorXMLParser(const std::string &fromFile)
void load() noexcept(false)
std::vector< DB_ME > DBMonitoringElements_
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
void handleElement(xercesc::DOMElement *element)
monitor db xml elements parsing tool
std::vector< DbQuery > queries
xercesc::XercesDOMParser * parser_