CMS 3D CMS Logo

DDLSAX2ConfigHandler.cc
Go to the documentation of this file.
9 #include <string>
10 #include <vector>
11 
12 using namespace cms::xerces;
13 
15  : doValidation_(false),
16  files_(),
17  urls_(),
18  schemaLocation_(),
19  cpv_(cpv)
20 {}
21 
23 {}
24 
25 // ---------------------------------------------------------------------------
26 // DDLSAX2Handler: Implementation of the SAX DocumentHandler interface
27 //
28 // This is kind-of sneaky-cheating. Basically it ignores all elements except
29 // File elements, and displays attributes up to the name attribute because that
30 // is the only one it cares about at this time. Later we would need a mechanism
31 // to exclude and include sections based on the configuration if we proceed with
32 // that level of selectivity.
33 //
34 // The file name is passed back to DDLParser via SetDDLFileName in order to
35 // process this list of files later.
36 // ---------------------------------------------------------------------------
37 void
38 DDLSAX2ConfigHandler::startElement( const XMLCh* const uri,
39  const XMLCh* const localname,
40  const XMLCh* const qname,
41  const Attributes& attrs )
42 {
43  if( XMLString::equals( qname, uStr("File").ptr()))
44  {
45  std::string name = toString(attrs.getValue(uStr("name").ptr()));
46  std::string url = toString(attrs.getValue(uStr("url").ptr()));
47 
48  files_.push_back(name);
49  urls_.push_back(url);
50  }
51  else if( XMLString::equals( qname, uStr("Root").ptr()))
52  {
53  std::string fileName = toString(attrs.getValue(uStr("fileName").ptr()));
54  std::string logicalPartName = toString(attrs.getValue(uStr("logicalPartName").ptr()));
55 
56  fileName = fileName.substr(0, fileName.find("."));
57  DDLogicalPart root(DDName(logicalPartName,fileName));
58  DDRootDef::instance().set(root);
59  cpv_.setRoot(root);
60  }
61  else if( XMLString::equals( qname, uStr("Schema").ptr()))
62  {
63  schemaLocation_ = toString(attrs.getValue(uStr("schemaLocation").ptr()));
64  doValidation_ = (XMLString::equals(attrs.getValue(uStr("validation").ptr()), uStr("true").ptr()) ? true : false);
65  }
66 }
67 
68 const std::vector<std::string>&
70 {
71  return files_;
72 }
73 
74 const std::vector<std::string>&
76 {
77  return urls_;
78 }
79 
80 const std::string
82 {
83  return schemaLocation_;
84 }
85 
86 const bool
88 {
89  return doValidation_;
90 }
const std::string getSchemaLocation() const
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
std::vector< std::string > files_
type of data representation of DDCompactView
Definition: DDCompactView.h:90
void setRoot(const DDLogicalPart &root)
don&#39;t use : interface not stable ....
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:92
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)
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
const std::vector< std::string > & getFileNames() const
const bool doValidation() const
XERCES_CPP_NAMESPACE::Attributes Attributes