10 #include <xercesc/dom/DOMDocument.hpp>
11 #include <xercesc/dom/DOMNodeList.hpp>
16 #include "../interface/MonitorXMLParser.h"
24 }
catch( xercesc::XMLException&
e ){
28 std::cerr <<
"XML toolkit initialization error: " << message << std::endl;
37 parser_ =
new xercesc::XercesDOMParser();
48 }
catch ( xercesc::XMLException&
e ){
50 std::cerr <<
"XML toolkit teardown error: " << message << std::endl;
74 xercesc::DOMNodeList* d1Nodes = element->getElementsByTagName(
tags_->
TAG_1D );
75 const XMLSize_t d1Count = d1Nodes->getLength();
77 for( XMLSize_t d1Index = 0; d1Index < d1Count; ++d1Index ){
79 xercesc::DOMNode* d1Node = d1Nodes->item( d1Index ) ;
81 xercesc::DOMElement* d1Element =
dynamic_cast< xercesc::DOMElement*
>( d1Node ) ;
83 const XMLCh* d1titleXMLCh = d1Element->getAttribute(
tags_->
ATTR_TITLE ) ;
90 const XMLCh* d1xbinsXMLCh = d1Element->getAttribute(
tags_->
ATTR_XBINS ) ;
92 s.clear(); s.str( c );
96 const XMLCh* d1xfromXMLCh = d1Element->getAttribute(
tags_->
ATTR_XFROM ) ;
98 s.clear(); s.str( c );
102 const XMLCh* d1xtoXMLCh = d1Element->getAttribute(
tags_->
ATTR_XTO ) ;
104 s.clear(); s.str( c );
108 const XMLCh* d1ncycleXMLCh = d1Element->getAttribute(
tags_->
ATTR_NCYCLE ) ;
110 s.clear(); s.str( c );
114 const XMLCh* d1loopXMLCh = d1Element->getAttribute(
tags_->
ATTR_LOOP ) ;
116 s.clear(); s.str( c );
129 xercesc::DOMNodeList* d2Nodes = element->getElementsByTagName(
tags_->
TAG_2D );
130 const XMLSize_t d2Count = d2Nodes->getLength();
132 for( XMLSize_t d2Index = 0; d2Index < d2Count; ++d2Index ){
134 xercesc::DOMNode* d2Node = d2Nodes->item( d2Index ) ;
136 xercesc::DOMElement* d2Element =
dynamic_cast< xercesc::DOMElement*
>( d2Node ) ;
138 const XMLCh* d2titleXMLCh = d2Element->getAttribute(
tags_->
ATTR_TITLE ) ;
145 const XMLCh* d2xbinsXMLCh = d2Element->getAttribute(
tags_->
ATTR_XBINS ) ;
147 s.clear(); s.str( c );
151 const XMLCh* d2xfromXMLCh = d2Element->getAttribute(
tags_->
ATTR_XFROM ) ;
153 s.clear(); s.str( c );
157 const XMLCh* d2xtoXMLCh = d2Element->getAttribute(
tags_->
ATTR_XTO ) ;
159 s.clear(); s.str( c );
163 const XMLCh* d2ybinsXMLCh = d2Element->getAttribute(
tags_->
ATTR_YBINS ) ;
165 s.clear(); s.str( c );
169 const XMLCh* d2yfromXMLCh = d2Element->getAttribute(
tags_->
ATTR_YFROM ) ;
171 s.clear(); s.str( c );
175 const XMLCh* d2ytoXMLCh = d2Element->getAttribute(
tags_->
ATTR_YTO ) ;
177 s.clear(); s.str( c );
181 const XMLCh* d2ncycleXMLCh = d2Element->getAttribute(
tags_->
ATTR_NCYCLE ) ;
183 s.clear(); s.str( c );
187 const XMLCh* d2loopXMLCh = d2Element->getAttribute(
tags_->
ATTR_LOOP ) ;
189 s.clear(); s.str( c );
199 xercesc::DOMNodeList* tpNodes = element->getElementsByTagName(
tags_->
TAG_TPROFILE );
200 const XMLSize_t tpCount = tpNodes->getLength();
202 for( XMLSize_t tpIndex = 0; tpIndex < tpCount; ++tpIndex ){
204 xercesc::DOMNode* tpNode = tpNodes->item( tpIndex ) ;
206 xercesc::DOMElement* tpElement =
dynamic_cast< xercesc::DOMElement*
>( tpNode ) ;
208 const XMLCh* tptitleXMLCh = tpElement->getAttribute(
tags_->
ATTR_TITLE ) ;
210 me.
type =
"tprofile";
215 const XMLCh* tpxbinsXMLCh = tpElement->getAttribute(
tags_->
ATTR_XBINS ) ;
217 s.clear(); s.str( c );
221 const XMLCh* tpxfromXMLCh = tpElement->getAttribute(
tags_->
ATTR_XFROM ) ;
223 s.clear(); s.str( c );
227 const XMLCh* tpxtoXMLCh = tpElement->getAttribute(
tags_->
ATTR_XTO ) ;
229 s.clear(); s.str( c );
233 const XMLCh* tpybinsXMLCh = tpElement->getAttribute(
tags_->
ATTR_YBINS ) ;
235 s.clear(); s.str( c );
239 const XMLCh* tpyfromXMLCh = tpElement->getAttribute(
tags_->
ATTR_YFROM ) ;
241 s.clear(); s.str( c );
245 const XMLCh* tpytoXMLCh = tpElement->getAttribute(
tags_->
ATTR_YTO ) ;
247 s.clear(); s.str( c );
251 const XMLCh* tpncycleXMLCh = tpElement->getAttribute(
tags_->
ATTR_NCYCLE ) ;
253 s.clear(); s.str( c );
257 const XMLCh* tploopXMLCh = tpElement->getAttribute(
tags_->
ATTR_LOOP ) ;
259 s.clear(); s.str( c );
270 const XMLSize_t tp2dCount = tp2dNodes->getLength();
272 for( XMLSize_t tp2dIndex = 0; tp2dIndex < tp2dCount; ++tp2dIndex ){
274 xercesc::DOMNode* tp2dNode = tp2dNodes->item( tp2dIndex ) ;
276 xercesc::DOMElement* tp2dElement =
dynamic_cast< xercesc::DOMElement*
>( tp2dNode ) ;
278 const XMLCh* tp2dtitleXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_TITLE ) ;
280 me.
type =
"tprofile2d";
285 const XMLCh* tp2dxbinsXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_XBINS ) ;
287 s.clear(); s.str( c );
291 const XMLCh* tp2dxfromXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_XFROM ) ;
293 s.clear(); s.str( c );
297 const XMLCh* tp2dxtoXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_XTO ) ;
299 s.clear(); s.str( c );
303 const XMLCh* tp2dybinsXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_YBINS ) ;
305 s.clear(); s.str( c );
309 const XMLCh* tp2dyfromXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_YFROM ) ;
311 s.clear(); s.str( c );
315 const XMLCh* tp2dytoXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_YTO ) ;
317 s.clear(); s.str( c );
321 const XMLCh* tp2dzbinsXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_ZBINS ) ;
323 s.clear(); s.str( c );
327 const XMLCh* tp2dzfromXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_ZFROM ) ;
329 s.clear(); s.str( c );
333 const XMLCh* tp2dztoXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_ZTO ) ;
335 s.clear(); s.str( c );
339 const XMLCh* tp2dncycleXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_NCYCLE ) ;
341 s.clear(); s.str( c );
345 const XMLCh* tp2dloopXMLCh = tp2dElement->getAttribute(
tags_->
ATTR_LOOP ) ;
347 s.clear(); s.str( c );
354 xercesc::DOMNodeList* qNodes = element->getElementsByTagName(
tags_->
TAG_QUERY );
355 const XMLSize_t qCount = qNodes->getLength();
357 for( XMLSize_t qIndex = 0; qIndex < qCount; ++qIndex ){
359 xercesc::DOMNode* qNode = qNodes->item( qIndex ) ;
361 xercesc::DOMElement* qElement =
dynamic_cast< xercesc::DOMElement*
>( qNode ) ;
363 const XMLCh* nameXMLCh = qElement->getAttribute(
tags_->
ATTR_NAME ) ;
366 const XMLCh* argXMLCh = qElement->getAttribute(
tags_->
ATTR_ARG ) ;
369 const XMLCh* aliasXMLCh = qElement->getAttribute(
tags_->
ATTR_ALIAS ) ;
377 me.
queries.push_back( tmpQuery );
396 parser_->setValidationScheme( xercesc::XercesDOMParser::Val_Never );
397 parser_->setDoNamespaces(
false );
399 parser_->setLoadExternalDTD(
false );
405 xercesc::DOMDocument* xmlDoc =
parser_->getDocument();
407 xercesc::DOMElement* dbe = xmlDoc->getDocumentElement();
410 throw( std::runtime_error(
"empty XML document" ) ) ;
415 xercesc::DOMNodeList* children = dbe->getChildNodes();
416 const XMLSize_t nodeCount = children->getLength();
418 for( XMLSize_t ix = 0 ; ix < nodeCount ; ++ix ){
419 xercesc::DOMNode* currentNode = children->item( ix );
420 if(
NULL == currentNode ){
425 if( xercesc::DOMNode::ELEMENT_NODE != currentNode->getNodeType() ){
429 xercesc::DOMElement* currentElement =
dynamic_cast< xercesc::DOMElement*
>( currentNode );
436 }
catch( xercesc::XMLException&
e ){
440 std::ostringstream buf ;
441 buf <<
"Error parsing file: " << message << std::endl;
445 throw( std::runtime_error( buf.str() ) );
447 }
catch(
const xercesc::DOMException& e ){
451 std::ostringstream buf;
452 buf <<
"Encountered DOM Exception: " << message << std::endl;
456 throw( std::runtime_error( buf.str() ) );
MonitorXMLParser(const std::string &fromFile)
std::vector< DbQuery > queries
XMLCh * transcode(const T &fInput)
std::vector< DB_ME > DBMonitoringElements_
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
void handleElement(xercesc::DOMElement *element)
xercesc::XercesDOMParser * parser_