8 #include "xercesc/util/PlatformUtils.hpp"
10 XERCES_CPP_NAMESPACE_USE
53 XMLPlatformUtils::Initialize();
81 parser_ =
new XercesDOMParser();
82 parser_->setValidationScheme(XercesDOMParser::Val_Auto);
83 parser_->setDoNamespaces(
false);
116 XMLPlatformUtils::Initialize();
151 XMLPlatformUtils::Terminate();
157 MemBufInputSource xmlstr_buf((
const XMLByte*)(str.c_str()), str.size(),
"xmlstrbuf");
166 MemBufInputSource xmlstr_buf((
const XMLByte*)(str.c_str()), str.size(),
"xmlstrbuf");
179 edm::LogError(
"XmlConfigReader") <<
"Could not parse file " << fName <<
"\n";
192 edm::LogError(
"XmlConfigReader") <<
"Could not parse file " << fName <<
"\n";
201 DOMElement* rootElement =
doc_->getDocumentElement();
203 if (rootElement->getNodeType() == DOMNode::ELEMENT_NODE) {
207 std::cout <<
"No xml root element found" << std::endl;
214 if (XMLString::equals(element->getTagName(),
kTagHw)) {
217 }
else if (XMLString::equals(element->getTagName(),
kTagAlgo) || XMLString::equals(element->getTagName(),
kTagRunSettings)) {
233 DOMNodeList* processors = element->getElementsByTagName(
kTagProcessor);
234 XMLSize_t nodeCount = processors->getLength();
235 for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
236 DOMNode* currentNode = processors->item(xx);
237 if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) {
238 DOMElement* currentElement =
static_cast<DOMElement*
>( currentNode );
241 DOMNodeList* roles = currentElement->getElementsByTagName(
kTagRole);
243 for (XMLSize_t
i = 0;
i < roles->getLength(); ++
i) {
244 DOMNodeList* roleChilds = roles->item(
i)->getChildNodes();
245 for (XMLSize_t
j = 0;
j < roleChilds->getLength(); ++
j) {
246 if (roleChilds->item(
j)->getNodeType() == DOMNode::TEXT_NODE) {
252 DOMNodeList* crates = currentElement->getElementsByTagName(
kTagCrate);
254 for (XMLSize_t
i = 0;
i < crates->getLength(); ++
i) {
255 DOMNodeList* crateChilds = crates->item(
i)->getChildNodes();
256 for (XMLSize_t
j = 0;
j < crateChilds->getLength(); ++
j) {
257 if (crateChilds->item(
j)->getNodeType() == DOMNode::TEXT_NODE) {
263 DOMNodeList* slots = currentElement->getElementsByTagName(
kTagSlot);
265 for (XMLSize_t
i = 0;
i < slots->getLength(); ++
i) {
266 DOMNodeList* slotChilds = slots->item(
i)->getChildNodes();
267 for (XMLSize_t
j = 0;
j < slotChilds->getLength(); ++
j) {
268 if (slotChilds->item(
j)->getNodeType() == DOMNode::TEXT_NODE) {
278 DOMNodeList* daqttcs = element->getElementsByTagName(
kTagDaqTtc);
279 nodeCount = daqttcs->getLength();
280 for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
281 DOMNode* currentNode = daqttcs->item(xx);
282 if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) {
283 DOMElement* currentElement =
static_cast<DOMElement*
>( currentNode );
286 DOMNodeList* roles = currentElement->getElementsByTagName(
kTagRole);
288 for (XMLSize_t
i = 0;
i < roles->getLength(); ++
i) {
289 DOMNodeList* roleChilds = roles->item(
i)->getChildNodes();
290 for (XMLSize_t
j = 0;
j < roleChilds->getLength(); ++
j) {
291 if (roleChilds->item(
j)->getNodeType() == DOMNode::TEXT_NODE) {
297 DOMNodeList* crates = currentElement->getElementsByTagName(
kTagCrate);
299 for (XMLSize_t
i = 0;
i < crates->getLength(); ++
i) {
300 DOMNodeList* crateChilds = crates->item(
i)->getChildNodes();
301 for (XMLSize_t
j = 0;
j < crateChilds->getLength(); ++
j) {
302 if (crateChilds->item(
j)->getNodeType() == DOMNode::TEXT_NODE) {
311 DOMNodeList* exclBoards = element->getElementsByTagName(
kTagExclBoards);
312 for (XMLSize_t xx = 0; xx < exclBoards->getLength(); ++xx) {
313 DOMElement* exclBoardElem =
static_cast<DOMElement*
>(exclBoards->item(xx));
315 for (DOMElement*
elem = static_cast<DOMElement*>(exclBoardElem->getFirstChild());
elem;
elem =
static_cast<DOMElement*
>(
elem->getNextSibling())) {
316 if (
elem->getNodeType() == DOMNode::ELEMENT_NODE) {
331 if (systemId ==
"") {
335 DOMNodeList* contextElements = element->getElementsByTagName(
kTagContext);
337 for (XMLSize_t
i = 0;
i < contextElements->getLength(); ++
i) {
338 DOMElement* contextElement =
static_cast<DOMElement*
>(contextElements->item(
i));
341 for (DOMElement*
elem = static_cast<DOMElement*>(contextElement->getFirstChild());
elem;
elem =
static_cast<DOMElement*
>(
elem->getNextSibling())) {
342 if (
elem->getNodeType() == DOMNode::ELEMENT_NODE) {
355 for (XMLSize_t
j = 0;
j < colElements->getLength(); ++
j) {
356 DOMNodeList* colChilds = colElements->item(
j)->getChildNodes();
357 for (XMLSize_t
k = 0;
k < colChilds->getLength(); ++
k) {
358 if (colChilds->item(
k)->getNodeType() == DOMNode::TEXT_NODE) {
370 DOMNodeList* colTypesElements =
elem->getElementsByTagName(
kTagTypes);
371 for (XMLSize_t
j = 0;
j < colTypesElements->getLength(); ++
j) {
372 DOMNodeList* colTypesChilds = colTypesElements->item(
j)->getChildNodes();
373 for (XMLSize_t
k = 0;
k < colTypesChilds->getLength(); ++
k) {
374 if (colTypesChilds->item(
k)->getNodeType() == DOMNode::TEXT_NODE) {
385 std::vector<std::string> rowStrs;
386 DOMNodeList* rowElements =
elem->getElementsByTagName(
kTagRow);
387 for (XMLSize_t
j = 0;
j < rowElements->getLength(); ++
j) {
388 DOMNodeList* rowChilds = rowElements->item(
j)->getChildNodes();
389 for (XMLSize_t
k = 0;
k < rowChilds->getLength(); ++
k) {
390 if (rowChilds->item(
k)->getNodeType() == DOMNode::TEXT_NODE) {
405 DOMNodeList* valNodes =
elem->getChildNodes();
406 for (XMLSize_t
j = 0;
j < valNodes->getLength(); ++
j) {
407 if (valNodes->item(
j)->getNodeType() == DOMNode::TEXT_NODE) {
408 value +=
_toString(valNodes->item(
j)->getNodeValue());
423 }
else if (XMLString::equals(
elem->getTagName(),
kTagMask)) {
427 aTrigSystem.
addMask(
id, contextId);
445 for (DOMElement*
elem = static_cast<DOMElement*>(keyElement->getFirstChild());
elem;
elem =
static_cast<DOMElement*
>(
elem->getNextSibling())) {
446 if (
elem->getNodeType() == DOMNode::ELEMENT_NODE) {
453 std::cout <<
"Key not found: " << key << std::endl;
460 DOMElement* rootElement =
doc_->getDocumentElement();
461 if (XMLString::equals(rootElement->getTagName(),
kTagDb)) {
462 DOMNodeList* keyElements = rootElement->getElementsByTagName(
kTagKey);
464 for (XMLSize_t
i = 0;
i < keyElements->getLength(); ++
i) {
465 DOMElement* keyElement =
static_cast<DOMElement*
>(keyElements->item(
i));
479 DOMNodeList* loadElements = keyElement->getElementsByTagName(
kTagLoad);
480 for (XMLSize_t
i = 0;
i < loadElements->getLength(); ++
i) {
481 DOMElement* loadElement =
static_cast<DOMElement*
>(loadElements->item(
i));
483 if (fileName.find(
"/") != 0) {
487 pos = topPath.find_last_of(
"/");
488 if (pos != std::string::npos) {
489 topDir = topPath.substr(0, pos+1);
494 DOMDocument* subDoc =
nullptr;
506 DOMElement* subDocRootElement = subDoc->getDocumentElement();
508 if (XMLString::equals(subDocRootElement->getTagName(),
kTagAlgo) || XMLString::equals(subDocRootElement->getTagName(),
kTagRunSettings)) {
509 DOMNode* importedNode =
doc_->importNode(subDocRootElement,
true);
510 parentNode->appendChild(importedNode);
516 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
517 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
518 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
519 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
520 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
521 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
522 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
523 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
524 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
525 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
526 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
527 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
528 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
529 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
530 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
531 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
532 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
533 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
534 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
535 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
536 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
537 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
538 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
539 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
540 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
545 size_t alphanumBegin = 0, alphanumEnd = strlen(str)-1;
550 str[alphanumEnd+1] =
'\0';
551 return str + alphanumBegin;
556 std::size_t alphanumBegin = str.find_first_not_of(
"\n\t ");
557 std::size_t alphanumEnd = str.find_last_not_of(
"\n\t ");
558 if (alphanumBegin != std::string::npos) {
559 if (alphanumEnd != std::string::npos) {
560 str = str.substr(alphanumBegin, alphanumEnd - alphanumBegin + 1);
562 str = str.substr(alphanumBegin);
void disableDaqProc(const std::string &daqProc)
void readDOMFromFile(const std::string &fName, xercesc::DOMDocument *&doc)
const std::string kTypeTable
void readHwDescription(const xercesc::DOMElement *element, TrigSystem &aTrigSystem, const std::string &sysId="")
const XMLCh * kTagExclude
std::string _toString(const XMLCh *toTranscode)
void readRootElement(TrigSystem &aTrigSystem, const std::string &sysId="")
const char XmlConfigReader_reject_symbols[256]
void addMask(const std::string &id, const std::string &procRole)
void addDaqRole(const std::string &daq, const std::string &role)
void addSetting(const std::string &type, const std::string &id, const std::string &value, const std::string &procRole, const std::string &delim="")
void addProcRole(const std::string &processor, const std::string &role)
const XMLCh * kTagExclBoards
const XMLCh * kTagContext
void buildGlobalDoc(const std::string &key, const std::string &topPath="")
void addProcCrate(const std::string &processor, const std::string &crate)
XMLCh * transcode(const T &fInput)
xercesc::XercesDOMParser * parser_
void readElement(const xercesc::DOMElement *element, TrigSystem &aTrigSystem, const std::string &sysId="")
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void readContexts(const std::string &key, const std::string &sysId, TrigSystem &aTrigSystem)
const XMLCh * kTagDisable
void addDaqCrate(const std::string &daq, const std::string &crate)
xercesc::DOMDocument * doc_
const XMLCh * kAttrModule
void addProcSlot(const std::string &processor, const std::string &slot)
const XMLCh * kTagRunSettings
std::vector< std::vector< double > > tmp
void pruneString(std::string &str)
XMLCh * _toDOMS(std::string temp)
const XMLCh * kTagProcessor
const XMLCh * kTagColumns
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
xercesc::DOMElement * getKeyElement(const std::string &key)
void appendNodesFromSubDoc(xercesc::DOMNode *parentNode, xercesc::DOMDocument *subDoc)
void setSystemId(const std::string id)
void readContext(const xercesc::DOMElement *element, const std::string &sysId, TrigSystem &aTrigSystem)
void addSettingTable(const std::string &id, const std::string &columns, const std::string &types, const std::vector< std::string > &rows, const std::string &procRole, const std::string &delim)