CMS 3D CMS Logo

SaxToDom2.cc
Go to the documentation of this file.
3 #include <xercesc/util/XMLString.hpp>
4 
5 #include <iostream>
6 #include <map>
7 #include <string>
8 
9 using namespace std;
10 
12 
14  AttList2 al;
15  al[TagName("name")] = TagName("myTinyDomTest");
16  Node2 nm(TagName("TinyDom2"), al);
17  parent_.emplace_back(nm);
18 }
19 
21 
22 const TinyDom2& SaxToDom2::dom() const { return dom_; }
23 
24 void SaxToDom2::startElement(const XMLCh* const uri,
25  const XMLCh* const name,
26  const XMLCh* const qname,
27  const Attributes& atts) {
28  char* strx = XMLString::transcode(name); // element-name
29  AttList2 al;
30 
31  for (unsigned int i = 0; i < atts.getLength(); ++i) {
32  char* aname = XMLString::transcode(atts.getLocalName(i));
33  char* value = XMLString::transcode(atts.getValue(i));
34  al[TagName(aname)] = TagName(value);
35  XMLString::release(&aname);
37  }
38 
39  // add the new element to the dom-tree
40  Node2 nm(TagName(strx), al);
41  Node2 par = parent_.back();
42  dom_.addEdge(par, nm, AnotherDummy2());
43 
44  parent_.emplace_back(nm);
45  XMLString::release(&strx);
46 }
47 
48 void SaxToDom2::endElement(const XMLCh* const uri, const XMLCh* const name, const XMLCh* const qname) {
49  parent_.pop_back();
50 }
51 
52 // error handling
54  char* id = XMLString::transcode(e.getSystemId());
55  char* message = XMLString::transcode(e.getMessage());
56  cerr << "\nError at file " << id << ", line " << e.getLineNumber() << ", char " << e.getColumnNumber()
57  << "\n Message: " << message << endl;
58  XMLString::release(&id);
59  XMLString::release(&message);
60 }
TagName
Definition: TagName.h:9
mps_fire.i
i
Definition: mps_fire.py:428
SaxToDom2.h
TagName.h
XERCES_CPP_NAMESPACE_USE
Definition: XMLConfigWriter.cc:40
AttList2
std::map< TagName, TagName > AttList2
Definition: TinyDom2.h:15
SaxToDom2::SaxToDom2
SaxToDom2()
Definition: SaxToDom2.cc:13
SaxToDom2::endElement
void endElement(const XMLCh *uri, const XMLCh *name, const XMLCh *qname) override
Definition: SaxToDom2.cc:48
SaxToDom2::Attributes
XERCES_CPP_NAMESPACE::Attributes Attributes
Definition: SaxToDom2.h:21
SaxToDom2::~SaxToDom2
~SaxToDom2() override
Definition: SaxToDom2.cc:20
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
value
Definition: value.py:1
SaxToDom2::startElement
void startElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override
Definition: SaxToDom2.cc:24
SaxToDom2::dom
const TinyDom2 & dom() const
Definition: SaxToDom2.cc:22
AnotherDummy2
Definition: TinyDom2.h:13
std
Definition: JetResolutionObject.h:76
SaxToDom2::SAXParseException
XERCES_CPP_NAMESPACE::SAXParseException SAXParseException
Definition: SaxToDom2.h:22
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
math::Graph< Node2, AnotherDummy2 >
SaxToDom2::error
void error(const SAXParseException &e) override
Definition: SaxToDom2.cc:53
Node2
std::pair< TagName, AttList2 > Node2
Definition: TinyDom2.h:16
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37