CMS 3D CMS Logo

DDLSAX2ConfigHandler.cc
Go to the documentation of this file.
9 
10 #include <string>
11 #include <vector>
12 
13 using namespace cms::xerces;
14 
16  : doValidation_(false), files_(), urls_(), schemaLocation_(), cpv_(cpv) {}
17 
19 
20 // ---------------------------------------------------------------------------
21 // DDLSAX2Handler: Implementation of the SAX DocumentHandler interface
22 //
23 // This is kind-of sneaky-cheating. Basically it ignores all elements except
24 // File elements, and displays attributes up to the name attribute because that
25 // is the only one it cares about at this time. Later we would need a mechanism
26 // to exclude and include sections based on the configuration if we proceed with
27 // that level of selectivity.
28 //
29 // The file name is passed back to DDLParser via SetDDLFileName in order to
30 // process this list of files later.
31 // ---------------------------------------------------------------------------
32 void DDLSAX2ConfigHandler::startElement(const XMLCh* const uri,
33  const XMLCh* const localname,
34  const XMLCh* const qname,
35  const Attributes& attrs) {
36  if (XMLString::equals(qname, uStr("File").ptr())) {
37  std::string name = toString(attrs.getValue(uStr("name").ptr()));
38  std::string url = toString(attrs.getValue(uStr("url").ptr()));
39 
40  files_.emplace_back(name);
41  urls_.emplace_back(url);
42  } else if (XMLString::equals(qname, uStr("Root").ptr())) {
43  std::string fileName = toString(attrs.getValue(uStr("fileName").ptr()));
44  std::string logicalPartName = toString(attrs.getValue(uStr("logicalPartName").ptr()));
45 
46  fileName = fileName.substr(0, fileName.find('.'));
47  DDLogicalPart root(DDName(logicalPartName, fileName));
49  cpv_.setRoot(root);
50  } else if (XMLString::equals(qname, uStr("Schema").ptr())) {
51  schemaLocation_ = toString(attrs.getValue(uStr("schemaLocation").ptr()));
52  doValidation_ = XMLString::equals(attrs.getValue(uStr("validation").ptr()), uStr("true").ptr());
53  }
54 }
55 
56 const std::vector<std::string>& DDLSAX2ConfigHandler::getFileNames(void) const { return files_; }
57 
58 const std::vector<std::string>& DDLSAX2ConfigHandler::getURLs(void) const { return urls_; }
59 
61 
62 const bool DDLSAX2ConfigHandler::doValidation(void) const { return doValidation_; }
const std::vector< std::string > & getURLs() const
void startElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::vector< std::string > files_
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
void setRoot(const DDLogicalPart &root)
static value_type & instance()
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
ZStr< XMLCh > uStr(char const *str)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
const std::string getSchemaLocation() const
const std::vector< std::string > & getFileNames() const
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
std::vector< std::string > urls_
DDLSAX2ConfigHandler(DDCompactView &cpv)
const bool doValidation() const
XERCES_CPP_NAMESPACE::Attributes Attributes