CMS 3D CMS Logo

DDLSAX2Handler.cc
Go to the documentation of this file.
5 
6 #include <iostream>
7 
8 using namespace cms::xerces;
9 
11  : attrCount_(0), characterCount_(0), elementCount_(0), spaceCount_(0), sawErrors_(false), userNS_(false) {}
12 
14 
15 // ---------------------------------------------------------------------------
16 // DDLSAX2Handler: Implementation of the SAX DocumentHandler interface
17 // ---------------------------------------------------------------------------
18 
19 void DDLSAX2Handler::startElement(const XMLCh* const uri,
20  const XMLCh* const localname,
21  const XMLCh* const qname,
22  const Attributes& attrs) {
23  ++elementCount_;
24  attrCount_ += attrs.getLength();
25 }
26 
27 void DDLSAX2Handler::endElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname) {
28  // do nothing
29 }
30 
31 void DDLSAX2Handler::characters(const XMLCh* const chars, const XMLSize_t length) { characterCount_ += length; }
32 
33 void DDLSAX2Handler::comment(const XMLCh* const chars, const XMLSize_t length) {
34  // do nothing default..
35 }
36 
37 void DDLSAX2Handler::ignorableWhitespace(const XMLCh* const chars, const XMLSize_t length) { spaceCount_ += length; }
38 
40  attrCount_ = 0;
41  characterCount_ = 0;
42  elementCount_ = 0;
43  spaceCount_ = 0;
44 }
45 
47  std::cout << "DetectorDescription/Parser/interface/DDLSAX2Handler::dumpStats, file: " << fname << " ("
48  << getElementCount() << " elems, " << getAttrCount() << " attrs, " << getSpaceCount() << " spaces, "
49  << getCharacterCount() << " chars)" << std::endl;
50 }
51 
52 // ---------------------------------------------------------------------------
53 // DDLSAX2Handler: Overrides of the SAX ErrorHandler interface
54 // Implements ALL required by the Xerces ErrorHandler interface as of 2007-06-26.
55 // ---------------------------------------------------------------------------
57  sawErrors_ = true;
58  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
59  << "\nError at file " << cStr(e.getSystemId()).ptr() << ", line " << e.getLineNumber() << ", char "
60  << e.getColumnNumber() << "\n Message: " << cStr(e.getMessage()).ptr() << std::endl;
61 }
62 
64  sawErrors_ = true;
65  edm::LogError("DetectorDescription_Parser_DDLSAX2Handler")
66  << "\nFatal Error at file " << cStr(e.getSystemId()).ptr() << ", line " << e.getLineNumber() << ", char "
67  << e.getColumnNumber() << "\n Message: " << cStr(e.getMessage()).ptr() << std::endl;
68  throw cms::Exception("DDException") << "DetectorDescription_Parser_Unrecoverable_Error_from_Xerces: "
69  << toString(e.getMessage()) << " file: " << toString(e.getSystemId())
70  << " line: " << e.getLineNumber() << " col: " << e.getColumnNumber();
71 }
72 
74  edm::LogWarning("DetectorDescription_Parser_DDLSAX2Handler")
75  << "\nWarning at file " << cStr(e.getSystemId()).ptr() << ", line " << e.getLineNumber() << ", char "
76  << e.getColumnNumber() << "\n Message: " << cStr(e.getMessage()).ptr() << std::endl;
77 }
78 
79 void DDLSAX2Handler::setUserNS(bool userns) { userNS_ = userns; }
80 
XercesStrUtils.h
DDLSAX2Handler::getSpaceCount
unsigned int getSpaceCount() const
Get the count of spaces processed so far.
Definition: DDLSAX2Handler.h:44
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
DDLSAX2Handler::characterCount_
XMLSize_t characterCount_
Definition: DDLSAX2Handler.h:81
DDLSAX2Handler::error
void error(const SAXParseException &exception) override
Definition: DDLSAX2Handler.cc:56
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::xerces
Definition: XercesStrUtils.h:14
DDLSAX2Handler::SAXParseException
XERCES_CPP_NAMESPACE::SAXParseException SAXParseException
Definition: DDLSAX2Handler.h:30
DDLSAX2Handler.h
DDLSAX2Handler::elementCount_
XMLSize_t elementCount_
Definition: DDLSAX2Handler.h:82
DDLSAX2Handler::spaceCount_
XMLSize_t spaceCount_
Definition: DDLSAX2Handler.h:83
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
cms::xerces::cStr
ZStr< char > cStr(XMLCh const *str)
Definition: XercesStrUtils.h:32
DDLSAX2Handler::getElementCount
unsigned int getElementCount() const
Get the count of elements processed so far.
Definition: DDLSAX2Handler.h:36
DDLSAX2Handler::setUserNS
virtual void setUserNS(bool userns)
Definition: DDLSAX2Handler.cc:79
toolbox::toString
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
DDLSAX2Handler::attrCount_
XMLSize_t attrCount_
Definition: DDLSAX2Handler.h:80
DDLSAX2Handler::characters
void characters(const XMLCh *chars, XMLSize_t length) override
Definition: DDLSAX2Handler.cc:31
DDLSAX2Handler::DDLSAX2Handler
DDLSAX2Handler()
Definition: DDLSAX2Handler.cc:10
DDLSAX2Handler::comment
void comment(const XMLCh *chars, XMLSize_t length) override
Definition: DDLSAX2Handler.cc:33
DDLSAX2Handler::fatalError
void fatalError(const SAXParseException &exception) override
Definition: DDLSAX2Handler.cc:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDLSAX2Handler::getCharacterCount
unsigned int getCharacterCount() const
Get the count of characters processed so far.
Definition: DDLSAX2Handler.h:40
DDLSAX2Handler::endElement
void endElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname) override
Definition: DDLSAX2Handler.cc:27
DDLSAX2Handler::userNS_
bool userNS_
Definition: DDLSAX2Handler.h:85
DDLSAX2Handler::nmspace_
std::string nmspace_
Definition: DDLSAX2Handler.h:86
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DDLSAX2Handler::setNameSpace
virtual void setNameSpace(const std::string &nms)
Definition: DDLSAX2Handler.cc:81
DDLSAX2Handler::ignorableWhitespace
void ignorableWhitespace(const XMLCh *chars, XMLSize_t length) override
Definition: DDLSAX2Handler.cc:37
DDLSAX2Handler::getAttrCount
unsigned int getAttrCount() const
Get the count of attributes processed so far.
Definition: DDLSAX2Handler.h:38
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
DDLSAX2Handler::resetDocument
void resetDocument() override
Definition: DDLSAX2Handler.cc:39
DDLSAX2Handler::Attributes
XERCES_CPP_NAMESPACE::Attributes Attributes
Definition: DDLSAX2Handler.h:29
Exception
Definition: hltDiff.cc:245
DDLSAX2Handler::sawErrors_
bool sawErrors_
Definition: DDLSAX2Handler.h:84
Exception.h
DDLSAX2Handler::warning
void warning(const SAXParseException &exception) override
Definition: DDLSAX2Handler.cc:73
DDLSAX2Handler::startElement
void startElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override
Definition: DDLSAX2Handler.cc:19
DDLSAX2Handler::~DDLSAX2Handler
~DDLSAX2Handler() override
Definition: DDLSAX2Handler.cc:13
DDLSAX2Handler::dumpStats
virtual void dumpStats(const std::string &fname)
Definition: DDLSAX2Handler.cc:46
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37