test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SaxToDom2.cc
Go to the documentation of this file.
3 
4 #include <xercesc/sax2/Attributes.hpp>
5 #include <xercesc/sax/SAXParseException.hpp>
6 #include <xercesc/sax/SAXException.hpp>
7 
8 #include <iostream>
9 //#include <string>
10 
11 using namespace std;
12 
14 {
15  AttList2 al;
16  al [ TagName("name") ] = TagName("myTinyDomTest");
17  Node2 nm(TagName("TinyDom2"), al);
18  parent_.push_back( nm );
19 }
20 
22 { }
23 
24 
25 const TinyDom2 & SaxToDom2::dom() const
26 {
27  return dom_;
28 }
29 
30 
31 void SaxToDom2::startElement( const XMLCh* const uri,
32  const XMLCh* const name,
33  const XMLCh* const qname,
34  const Attributes& atts)
35 {
36  StrX strx(name); // element-name
37  AttList2 al;
38 
39  for (unsigned int i = 0; i < atts.getLength(); ++i)
40  {
41  const XMLCh* aname = atts.getLocalName(i);
42  const XMLCh* value = atts.getValue(i);
43  al[TagName((StrX(aname).localForm()))]=TagName(StrX(value).localForm());
44  }
45 
46  // add the new element to the dom-tree
47  Node2 nm(TagName(strx.localForm()) , al);
48  Node2 par = parent_.back();
49  dom_.addEdge(par, nm, AnotherDummy2());
50 
51  parent_.push_back(nm);
52 }
53 
54 
55 void SaxToDom2::endElement(const XMLCh* const uri,
56  const XMLCh* const name,
57  const XMLCh* const qname)
58 {
59  parent_.pop_back();
60 }
61 
62 // error handling
64 {
65  cerr << "\nError at file " << StrX(e.getSystemId())
66  << ", line " << e.getLineNumber()
67  << ", char " << e.getColumnNumber()
68  << "\n Message: " << StrX(e.getMessage()) << endl;
69 }
70 
71 
int i
Definition: DBlmapReader.cc:9
XERCES_CPP_NAMESPACE::SAXParseException SAXParseException
Definition: SaxToDom2.h:22
void error(const SAXParseException &e)
Definition: SaxToDom2.cc:63
Definition: TagName.h:9
XERCES_CPP_NAMESPACE::Attributes Attributes
Definition: SaxToDom2.h:21
~SaxToDom2()
Definition: SaxToDom2.cc:21
void endElement(const XMLCh *const uri, const XMLCh *const name, const XMLCh *const qname)
Definition: SaxToDom2.cc:55
const char * localForm() const
Definition: StrX.h:66
Definition: StrX.h:32
std::pair< TagName, AttList2 > Node2
Definition: TinyDom2.h:14
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
Definition: SaxToDom2.cc:31
const TinyDom2 & dom() const
Definition: SaxToDom2.cc:25
std::map< TagName, TagName > AttList2
Definition: TinyDom2.h:13