CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DetectorDescription/Parser/src/DDLSAX2Handler.cc

Go to the documentation of this file.
00001 /***************************************************************************
00002                           DDLSAX2Handler.cc  -  description
00003                              -------------------
00004     begin                : Mon Oct 22 2001
00005     email                : case@ucdhep.ucdavis.edu
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *           DDDParser sub-component of DDD                                *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 #include "DetectorDescription/Parser/interface/DDLSAX2Handler.h"
00015 #include "DetectorDescription/Parser/src/StrX.h"
00016 #include "DetectorDescription/Base/interface/DDException.h"
00017 
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 
00020 DDLSAX2Handler::DDLSAX2Handler( void )
00021   : attrCount_(0),
00022     characterCount_(0),
00023     elementCount_(0),
00024     spaceCount_(0),
00025     sawErrors_(false),
00026     userNS_(false)
00027 {}
00028 
00029 DDLSAX2Handler::~DDLSAX2Handler( void )
00030 {}
00031 
00032 // ---------------------------------------------------------------------------
00033 //  DDLSAX2Handler: Implementation of the SAX DocumentHandler interface
00034 // ---------------------------------------------------------------------------
00035 
00036 void
00037 DDLSAX2Handler::startElement( const XMLCh* const uri,
00038                               const XMLCh* const localname,
00039                               const XMLCh* const qname,
00040                               const Attributes& attrs )
00041 {
00042   ++elementCount_;
00043   attrCount_ += attrs.getLength();
00044 }
00045 
00046 void
00047 DDLSAX2Handler::endElement( const XMLCh* const uri,
00048                             const XMLCh* const localname,
00049                             const XMLCh* const qname )
00050 {
00051   // do nothing
00052 }
00053 
00054 void
00055 DDLSAX2Handler::characters( const XMLCh* const chars,
00056                             const unsigned int length )
00057 {
00058   characterCount_ += length;
00059 }
00060 
00061 void
00062 DDLSAX2Handler::comment( const XMLCh *const chars, const unsigned int length )
00063 {
00064   // do nothing default..
00065 }
00066 
00067 void
00068 DDLSAX2Handler::ignorableWhitespace( const XMLCh* const chars,
00069                                      const unsigned int length )
00070 {
00071   spaceCount_ += length;
00072 }
00073 
00074 void
00075 DDLSAX2Handler::resetDocument( void )
00076 {
00077   attrCount_ = 0;
00078   characterCount_ = 0;
00079   elementCount_ = 0;
00080   spaceCount_ = 0;
00081 }
00082 
00083 void
00084 DDLSAX2Handler::dumpStats( const std::string& fname )
00085 {
00086   std::cout << "DetectorDescription/Parser/interface/DDLSAX2Handler::dumpStats, file: " 
00087        << fname << " ("
00088        << getElementCount() << " elems, "
00089        << getAttrCount() << " attrs, "
00090        << getSpaceCount() << " spaces, "
00091        << getCharacterCount() << " chars)" << std::endl;
00092 }
00093 
00094 // ---------------------------------------------------------------------------
00095 //  DDLSAX2Handler: Overrides of the SAX ErrorHandler interface
00096 //  Implements ALL required by the Xerces ErrorHandler interface as of 2007-06-26.
00097 // ---------------------------------------------------------------------------
00098 void
00099 DDLSAX2Handler::error( const SAXParseException& e )
00100 {
00101   sawErrors_ = true;
00102   edm::LogError("DetectorDescription_Parser_DDLSAX2Handler") 
00103     << "\nError at file " << StrX(e.getSystemId())
00104     << ", line " << e.getLineNumber()
00105     << ", char " << e.getColumnNumber()
00106     << "\n  Message: " << StrX(e.getMessage()) << std::endl;
00107 }
00108 
00109 void
00110 DDLSAX2Handler::fatalError( const SAXParseException& e )
00111 {
00112   sawErrors_ = true;
00113   edm::LogError("DetectorDescription_Parser_DDLSAX2Handler") 
00114     << "\nFatal Error at file " << StrX(e.getSystemId())
00115     << ", line " << e.getLineNumber()
00116     << ", char " << e.getColumnNumber()
00117     << "\n  Message: " 
00118     << StrX(e.getMessage()) << std::endl;
00119   throw DDException(std::string("DetectorDescription_Parser_Unrecoverable_Error_from_Xerces: "))
00120     << std::string(StrX(e.getMessage()).localForm())
00121     << " file: " << std::string(StrX(e.getSystemId()).localForm())
00122     << " line: " << e.getLineNumber() << " col: " << e.getColumnNumber();
00123 }
00124 
00125 void
00126 DDLSAX2Handler::warning( const SAXParseException& e )
00127 {
00128   edm::LogWarning("DetectorDescription_Parser_DDLSAX2Handler") 
00129     << "\nWarning at file " << StrX(e.getSystemId())
00130     << ", line " << e.getLineNumber()
00131     << ", char " << e.getColumnNumber()
00132     << "\n  Message: " << StrX(e.getMessage()) << std::endl;
00133 }
00134 
00135 void
00136 DDLSAX2Handler::setUserNS( bool userns )
00137 { 
00138   userNS_ = userns; 
00139 }
00140 
00141 void
00142 DDLSAX2Handler::setNameSpace( const std::string& nms )
00143 {
00144   nmspace_ = nms;
00145 }