File indexing completed on 2024-04-06 12:05:33
0001 #include "DetectorDescription/Parser/interface/DDLSAX2ConfigHandler.h"
0002 #include "DetectorDescription/Parser/interface/DDLSAX2Handler.h"
0003 #include "DetectorDescription/Core/interface/DDCompactView.h"
0004 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0005 #include "DetectorDescription/Core/interface/DDName.h"
0006 #include "DetectorDescription/Core/interface/DDRoot.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "Utilities/Xerces/interface/XercesStrUtils.h"
0009
0010 #include <string>
0011 #include <vector>
0012
0013 using namespace cms::xerces;
0014
0015 DDLSAX2ConfigHandler::DDLSAX2ConfigHandler(DDCompactView& cpv)
0016 : doValidation_(false), files_(), urls_(), schemaLocation_(), cpv_(cpv) {}
0017
0018 DDLSAX2ConfigHandler::~DDLSAX2ConfigHandler(void) {}
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 void DDLSAX2ConfigHandler::startElement(const XMLCh* const uri,
0033 const XMLCh* const localname,
0034 const XMLCh* const qname,
0035 const Attributes& attrs) {
0036 if (XMLString::equals(qname, uStr("File").ptr())) {
0037 std::string name = toString(attrs.getValue(uStr("name").ptr()));
0038 std::string url = toString(attrs.getValue(uStr("url").ptr()));
0039
0040 files_.emplace_back(name);
0041 urls_.emplace_back(url);
0042 } else if (XMLString::equals(qname, uStr("Root").ptr())) {
0043 std::string fileName = toString(attrs.getValue(uStr("fileName").ptr()));
0044 std::string logicalPartName = toString(attrs.getValue(uStr("logicalPartName").ptr()));
0045
0046 fileName = fileName.substr(0, fileName.find('.'));
0047 DDLogicalPart root(DDName(logicalPartName, fileName));
0048 DDRootDef::instance().set(root);
0049 cpv_.setRoot(root);
0050 } else if (XMLString::equals(qname, uStr("Schema").ptr())) {
0051 schemaLocation_ = toString(attrs.getValue(uStr("schemaLocation").ptr()));
0052 doValidation_ = XMLString::equals(attrs.getValue(uStr("validation").ptr()), uStr("true").ptr());
0053 }
0054 }
0055
0056 const std::vector<std::string>& DDLSAX2ConfigHandler::getFileNames(void) const { return files_; }
0057
0058 const std::vector<std::string>& DDLSAX2ConfigHandler::getURLs(void) const { return urls_; }
0059
0060 const std::string DDLSAX2ConfigHandler::getSchemaLocation(void) const { return schemaLocation_; }
0061
0062 const bool DDLSAX2ConfigHandler::doValidation(void) const { return doValidation_; }