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),
17  files_(),
18  urls_(),
19  schemaLocation_(),
20  cpv_(cpv)
21 {}
22 
24 {}
25 
26 // ---------------------------------------------------------------------------
27 // DDLSAX2Handler: Implementation of the SAX DocumentHandler interface
28 //
29 // This is kind-of sneaky-cheating. Basically it ignores all elements except
30 // File elements, and displays attributes up to the name attribute because that
31 // is the only one it cares about at this time. Later we would need a mechanism
32 // to exclude and include sections based on the configuration if we proceed with
33 // that level of selectivity.
34 //
35 // The file name is passed back to DDLParser via SetDDLFileName in order to
36 // process this list of files later.
37 // ---------------------------------------------------------------------------
38 void
39 DDLSAX2ConfigHandler::startElement( const XMLCh* const uri,
40  const XMLCh* const localname,
41  const XMLCh* const qname,
42  const Attributes& attrs )
43 {
44  if( XMLString::equals( qname, uStr("File").ptr()))
45  {
46  std::string name = toString(attrs.getValue(uStr("name").ptr()));
47  std::string url = toString(attrs.getValue(uStr("url").ptr()));
48 
49  files_.emplace_back(name);
50  urls_.emplace_back(url);
51  }
52  else if( XMLString::equals( qname, uStr("Root").ptr()))
53  {
54  std::string fileName = toString(attrs.getValue(uStr("fileName").ptr()));
55  std::string logicalPartName = toString(attrs.getValue(uStr("logicalPartName").ptr()));
56 
57  fileName = fileName.substr(0, fileName.find("."));
58  DDLogicalPart root(DDName(logicalPartName,fileName));
59  DDRootDef::instance().set(root);
60  cpv_.setRoot(root);
61  }
62  else if( XMLString::equals( qname, uStr("Schema").ptr()))
63  {
64  schemaLocation_ = toString(attrs.getValue(uStr("schemaLocation").ptr()));
65  doValidation_ = XMLString::equals(attrs.getValue(uStr("validation").ptr()), uStr("true").ptr());
66  }
67 }
68 
69 const std::vector<std::string>&
71 {
72  return files_;
73 }
74 
75 const std::vector<std::string>&
77 {
78  return urls_;
79 }
80 
81 const std::string
83 {
84  return schemaLocation_;
85 }
86 
87 const bool
89 {
90  return doValidation_;
91 }
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:15
std::vector< std::string > files_
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
void setRoot(const DDLogicalPart &root)
static value_type & instance()
ZStr< XMLCh > uStr(char const *str)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
std::string toString(const std::pair< T, T > &aT)
Definition: CaloEllipse.h:72
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