CMS 3D CMS Logo

SaxToDom2.cc

Go to the documentation of this file.
00001 #include "DetectorDescription/RegressionTest/src/SaxToDom2.h"
00002 #include "DetectorDescription/RegressionTest/src/StrX.h"
00003 #include "DetectorDescription/RegressionTest/src/TinyDom2.h"
00004 
00005 #include <xercesc/sax2/Attributes.hpp>
00006 #include <xercesc/sax/SAXParseException.hpp>
00007 #include <xercesc/sax/SAXException.hpp>
00008 
00009 #include <iostream>
00010 //#include <string>
00011 
00012 using namespace std;
00013 
00014 SaxToDom2::SaxToDom2() 
00015 { 
00016   AttList2 al;
00017   al [ TagName("name") ] = TagName("myTinyDomTest");
00018   Node2 nm(TagName("TinyDom2"), al);
00019   parent_.push_back( nm );
00020 }
00021 
00022 SaxToDom2::~SaxToDom2() 
00023 { }
00024 
00025 
00026 const TinyDom2 & SaxToDom2::dom() const
00027 {
00028    return dom_;
00029 }
00030 
00031 
00032 void SaxToDom2::startElement( const XMLCh* const uri, 
00033                             const XMLCh* const name, 
00034                                const XMLCh* const qname, 
00035                                const Attributes& atts)
00036 {
00037   StrX strx(name); // element-name
00038   AttList2 al;
00039 
00040   for (unsigned int i = 0; i < atts.getLength(); ++i)
00041     {
00042       const XMLCh* aname = atts.getLocalName(i);
00043       const XMLCh* value = atts.getValue(i);
00044       al[TagName((StrX(aname).localForm()))]=TagName(StrX(value).localForm());
00045     }
00046 
00047   // add the new element to the dom-tree
00048   Node2 nm(TagName(strx.localForm()) , al);
00049   Node2 par = parent_.back();
00050   dom_.addEdge(par, nm, AnotherDummy2());
00051 
00052   parent_.push_back(nm);
00053 }
00054 
00055 
00056 void SaxToDom2::endElement(const XMLCh* const uri, 
00057                             const XMLCh* const name, 
00058                                const XMLCh* const qname)
00059 {
00060   parent_.pop_back();
00061 }
00062 
00063 // error handling
00064 void SaxToDom2::error(const SAXParseException& e)
00065 {
00066     cerr << "\nError at file " << StrX(e.getSystemId())
00067                  << ", line " << e.getLineNumber()
00068                  << ", char " << e.getColumnNumber()
00069          << "\n  Message: " << StrX(e.getMessage()) << endl;
00070 }
00071 
00072 

Generated on Tue Jun 9 17:32:29 2009 for CMSSW by  doxygen 1.5.4