CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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));
48  DDRootDef::instance().set(root);
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_; }
void startElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override
const std::string getSchemaLocation() const
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
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
std::vector< std::string > urls_
const std::vector< std::string > & getURLs() const
DDLSAX2ConfigHandler(DDCompactView &cpv)
XERCES_CPP_NAMESPACE::Attributes Attributes
const std::vector< std::string > & getFileNames() const
const bool doValidation() const