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 
~DDLSAX2Handler() override
void error(const SAXParseException &exception) override
unsigned int getSpaceCount() const
Get the count of spaces processed so far.
XMLSize_t spaceCount_
XMLSize_t characterCount_
XMLSize_t attrCount_
XMLSize_t elementCount_
unsigned int getElementCount() const
Get the count of elements processed so far.
Log< level::Error, false > LogError
void fatalError(const SAXParseException &exception) override
unsigned int getCharacterCount() const
Get the count of characters processed so far.
void characters(const XMLCh *chars, XMLSize_t length) override
virtual void setUserNS(bool userns)
ZStr< char > cStr(XMLCh const *str)
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
std::string nmspace_
void comment(const XMLCh *chars, XMLSize_t length) override
void endElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname) override
void warning(const SAXParseException &exception) override
void resetDocument() override
string fname
main script
virtual void setNameSpace(const std::string &nms)
void ignorableWhitespace(const XMLCh *chars, XMLSize_t length) override
XERCES_CPP_NAMESPACE::Attributes Attributes
unsigned int getAttrCount() const
Get the count of attributes processed so far.
virtual void dumpStats(const std::string &fname)
Log< level::Warning, false > LogWarning
XERCES_CPP_NAMESPACE::SAXParseException SAXParseException
void startElement(const XMLCh *uri, const XMLCh *localname, const XMLCh *qname, const Attributes &attrs) override