00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "DetectorDescription/Parser/interface/DDLSAX2ExpressionHandler.h"
00018 #include "DetectorDescription/Parser/interface/DDLParser.h"
00019 #include "StrX.h"
00020
00021
00022 #include "DetectorDescription/Base/interface/DDdebug.h"
00023
00024 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00025
00026
00027 #include <xercesc/sax2/Attributes.hpp>
00028 #include <xercesc/sax/SAXParseException.hpp>
00029 #include <xercesc/sax/SAXException.hpp>
00030
00031
00032
00033
00034
00035 #include <iostream>
00036 #include <vector>
00037 #include <string>
00038
00039
00040
00041
00042 DDLSAX2ExpressionHandler::DDLSAX2ExpressionHandler()
00043 {
00044 }
00045
00046 DDLSAX2ExpressionHandler::~DDLSAX2ExpressionHandler()
00047 {
00048 }
00049
00050
00051
00052
00053 void DDLSAX2ExpressionHandler::startElement(const XMLCh* const uri
00054 , const XMLCh* const localname
00055 , const XMLCh* const qname
00056 , const Attributes& attrs)
00057 {
00058
00059
00060 ++elementCount_;
00061 attrCount_ += attrs.getLength();
00062
00063 pElementName = StrX(qname).localForm();
00064
00065 if (pElementName == "Constant")
00066 {
00067 ++elementTypeCounter_[pElementName];
00068 DCOUT_V('P', std::string("DetectorDescription/Parser/interface/DDLSAX2ExpressionHandler: start ") + pElementName);
00069 unsigned int numAtts = attrs.getLength();
00070 std::string varName, varValue;
00071 for (unsigned int i = 0; i < numAtts; ++i)
00072 {
00073 std::string myattname(StrX(attrs.getLocalName(i)).localForm());
00074 std::string myvalue(StrX(attrs.getValue(i)).localForm());
00075
00076 std::string myQName(StrX(attrs.getQName(i)).localForm());
00077 DCOUT_V('P', std::string("DetectorDescription/Parser/interface/DDLSAX2ExpressionHandler: ") + "getLocalName = " + myattname + " getValue = " + myvalue + " getQName = " + myQName);
00078
00079
00080 if (myattname == "name")
00081 varName = myvalue;
00082 else if (myattname == "value")
00083 varValue = myvalue;
00084 }
00085 DDLParser* beingParsed = DDLParser::instance();
00086 std::string nmspace = getnmspace(extractFileName( beingParsed->getCurrFileName()));
00087 ExprEvalInterface & ev = ExprEvalSingleton::instance();
00088 ev.set(nmspace, varName, varValue);
00089 }
00090 }
00091
00092 void DDLSAX2ExpressionHandler::endElement(const XMLCh* const uri
00093 , const XMLCh* const localname
00094 , const XMLCh* const qname)
00095 {
00096
00097 }
00098