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