source: NonGTP/Xerces/xerces/samples/PParse/PParseHandlers.cpp @ 358

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

xerces added

Line 
1/*
2 * Copyright 1999-2001,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 * $Id: PParseHandlers.cpp,v 1.8 2004/09/08 13:55:32 peiyongz Exp $
19 */
20
21
22
23// ---------------------------------------------------------------------------
24//  Includes
25// ---------------------------------------------------------------------------
26#include <xercesc/util/XMLUniDefs.hpp>
27#include <xercesc/util/XMLUni.hpp>
28#include <xercesc/sax/AttributeList.hpp>
29#include "PParse.hpp"
30
31
32// ---------------------------------------------------------------------------
33//  PParseHandlers: Constructors and Destructor
34// ---------------------------------------------------------------------------
35PParseHandlers::PParseHandlers() :
36
37    fElementCount(0)
38    , fAttrCount(0)
39    , fCharacterCount(0)
40    , fSpaceCount(0)
41{
42}
43
44PParseHandlers::~PParseHandlers()
45{
46}
47
48
49// ---------------------------------------------------------------------------
50//  PParseHandlers: Overrides of the SAX DocumentHandler interface
51// ---------------------------------------------------------------------------
52void PParseHandlers::startElement(const   XMLCh* const    name
53                                    ,       AttributeList&  attributes)
54{
55    fElementCount++;
56    fAttrCount += attributes.getLength();
57}
58
59void PParseHandlers::characters(  const   XMLCh* const    chars
60                                                                    , const unsigned int    length)
61{
62    fCharacterCount += length;
63}
64
65void PParseHandlers::ignorableWhitespace( const   XMLCh* const chars
66                                                                                    , const unsigned int length)
67{
68    fSpaceCount += length;
69}
70
71void PParseHandlers::resetDocument()
72{
73    fAttrCount = 0;
74    fCharacterCount = 0;
75    fElementCount = 0;
76    fSpaceCount = 0;
77}
78
79
80// ---------------------------------------------------------------------------
81//  PParseHandlers: Overrides of the SAX ErrorHandler interface
82// ---------------------------------------------------------------------------
83void PParseHandlers::error(const SAXParseException& e)
84{
85    XERCES_STD_QUALIFIER cerr << "\nError at file " << StrX(e.getSystemId())
86                 << ", line " << e.getLineNumber()
87                 << ", char " << e.getColumnNumber()
88         << "\n  Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
89}
90
91void PParseHandlers::fatalError(const SAXParseException& e)
92{
93    XERCES_STD_QUALIFIER cerr << "\nFatal Error at file " << StrX(e.getSystemId())
94                 << ", line " << e.getLineNumber()
95                 << ", char " << e.getColumnNumber()
96         << "\n  Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
97}
98
99void PParseHandlers::warning(const SAXParseException& e)
100{
101    XERCES_STD_QUALIFIER cerr << "\nWarning at file " << StrX(e.getSystemId())
102                 << ", line " << e.getLineNumber()
103                 << ", char " << e.getColumnNumber()
104         << "\n  Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
105}
106
Note: See TracBrowser for help on using the repository browser.