source: icXML/icXML-devel/samples/src/PParse/PParseHandlers.cpp @ 2726

Last change on this file since 2726 was 2726, checked in by cameron, 7 years ago

Add original Xerces tests and samples directories

File size: 3.5 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: PParseHandlers.cpp 557282 2007-07-18 14:54:15Z amassari $
20 */
21
22
23
24// ---------------------------------------------------------------------------
25//  Includes
26// ---------------------------------------------------------------------------
27#include <xercesc/util/XMLUniDefs.hpp>
28#include <xercesc/util/XMLUni.hpp>
29#include <xercesc/sax/AttributeList.hpp>
30#include "PParse.hpp"
31
32
33// ---------------------------------------------------------------------------
34//  PParseHandlers: Constructors and Destructor
35// ---------------------------------------------------------------------------
36PParseHandlers::PParseHandlers() :
37
38    fAttrCount(0)
39    , fCharacterCount(0)
40    , fElementCount(0)
41    , fSpaceCount(0) 
42{
43}
44
45PParseHandlers::~PParseHandlers()
46{
47}
48
49
50// ---------------------------------------------------------------------------
51//  PParseHandlers: Overrides of the SAX DocumentHandler interface
52// ---------------------------------------------------------------------------
53void PParseHandlers::startElement(const   XMLCh* const    /* name */
54                                    ,       AttributeList&  attributes)
55{
56    fElementCount++;
57    fAttrCount += attributes.getLength();
58}
59
60void PParseHandlers::characters(  const   XMLCh* const    /* chars */ 
61                                                                    , const XMLSize_t    length)
62{
63    fCharacterCount += length;
64}
65
66void PParseHandlers::ignorableWhitespace( const   XMLCh* const /* chars */
67                                                                                    , const XMLSize_t length)
68{
69    fSpaceCount += length;
70}
71
72void PParseHandlers::resetDocument()
73{
74    fAttrCount = 0;
75    fCharacterCount = 0;
76    fElementCount = 0;
77    fSpaceCount = 0;
78}
79
80
81// ---------------------------------------------------------------------------
82//  PParseHandlers: Overrides of the SAX ErrorHandler interface
83// ---------------------------------------------------------------------------
84void PParseHandlers::error(const SAXParseException& e)
85{
86    XERCES_STD_QUALIFIER cerr << "\nError at file " << StrX(e.getSystemId())
87                 << ", line " << e.getLineNumber()
88                 << ", char " << e.getColumnNumber()
89         << "\n  Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
90}
91
92void PParseHandlers::fatalError(const SAXParseException& e)
93{
94    XERCES_STD_QUALIFIER cerr << "\nFatal Error at file " << StrX(e.getSystemId())
95                 << ", line " << e.getLineNumber()
96                 << ", char " << e.getColumnNumber()
97         << "\n  Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
98}
99
100void PParseHandlers::warning(const SAXParseException& e)
101{
102    XERCES_STD_QUALIFIER cerr << "\nWarning at file " << StrX(e.getSystemId())
103                 << ", line " << e.getLineNumber()
104                 << ", char " << e.getColumnNumber()
105         << "\n  Message: " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
106}
107
Note: See TracBrowser for help on using the repository browser.