CMS 3D CMS Logo

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