source: NonGTP/Xerces/xerces/samples/StdInParse/StdInParseHandlers.cpp @ 358

Revision 358, 4.2 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 1999-2000,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: StdInParseHandlers.cpp,v $
19 * Revision 1.6  2004/09/08 13:55:34  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.5  2003/05/30 09:36:36  gareth
23 * Use new macros for iostream.h and std:: issues.
24 *
25 * Revision 1.4  2002/02/01 22:41:37  peiyongz
26 * sane_include
27 *
28 * Revision 1.3  2000/03/02 19:53:50  roddey
29 * This checkin includes many changes done while waiting for the
30 * 1.1.0 code to be finished. I can't list them all here, but a list is
31 * available elsewhere.
32 *
33 * Revision 1.2  2000/02/06 07:47:25  rahulj
34 * Year 2K copyright swat.
35 *
36 * Revision 1.1.1.1  1999/11/09 01:09:27  twl
37 * Initial checkin
38 *
39 * Revision 1.5  1999/11/08 20:43:43  rahul
40 * Swat for adding in Product name and CVS comment log variable.
41 *
42 */
43
44
45
46// ---------------------------------------------------------------------------
47//  Includes
48// ---------------------------------------------------------------------------
49#include <xercesc/sax/AttributeList.hpp>
50#include <xercesc/sax/SAXParseException.hpp>
51#include <xercesc/sax/SAXException.hpp>
52#include "StdInParse.hpp"
53
54
55// ---------------------------------------------------------------------------
56//  StdInParseHandlers: Constructors and Destructor
57// ---------------------------------------------------------------------------
58StdInParseHandlers::StdInParseHandlers() :
59
60    fElementCount(0)
61    , fAttrCount(0)
62    , fCharacterCount(0)
63    , fSpaceCount(0)
64{
65}
66
67StdInParseHandlers::~StdInParseHandlers()
68{
69}
70
71
72// ---------------------------------------------------------------------------
73//  StdInParseHandlers: Implementation of the SAX DocumentHandler interface
74// ---------------------------------------------------------------------------
75void StdInParseHandlers::endElement(const XMLCh* const name)
76{
77}
78
79void
80StdInParseHandlers::startElement(   const   XMLCh* const    name
81                                    ,       AttributeList&  attributes)
82{
83    fElementCount++;
84    fAttrCount += attributes.getLength();
85}
86
87void StdInParseHandlers::characters(const   XMLCh* const    chars
88                                                                    , const unsigned int    length)
89{
90    fCharacterCount += length;
91}
92
93void StdInParseHandlers::ignorableWhitespace(const  XMLCh* const chars
94                                                                                    , const unsigned int length)
95{
96    fSpaceCount += length;
97}
98
99void StdInParseHandlers::resetDocument()
100{
101    fAttrCount = 0;
102    fCharacterCount = 0;
103    fElementCount = 0;
104    fSpaceCount = 0;
105}
106
107
108
109// ---------------------------------------------------------------------------
110//  StdInParseHandlers: Overrides of the SAX ErrorHandler interface
111// ---------------------------------------------------------------------------
112void StdInParseHandlers::error(const SAXParseException& e)
113{
114    XERCES_STD_QUALIFIER cerr << "\nError at (file " << StrX(e.getSystemId())
115                 << ", line " << e.getLineNumber()
116                 << ", char " << e.getColumnNumber()
117         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
118}
119
120void StdInParseHandlers::fatalError(const SAXParseException& e)
121{
122    XERCES_STD_QUALIFIER cerr << "\nFatal Error at (file " << StrX(e.getSystemId())
123                 << ", line " << e.getLineNumber()
124                 << ", char " << e.getColumnNumber()
125         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
126}
127
128void StdInParseHandlers::warning(const SAXParseException& e)
129{
130    XERCES_STD_QUALIFIER cerr << "\nWarning at (file " << StrX(e.getSystemId())
131                 << ", line " << e.getLineNumber()
132                 << ", char " << e.getColumnNumber()
133         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
134}
Note: See TracBrowser for help on using the repository browser.