source: icXML/icXML-devel/samples/src/MemParse/MemParseHandlers.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.6 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: MemParseHandlers.cpp 557282 2007-07-18 14:54:15Z amassari $
20 */
21
22
23
24// ---------------------------------------------------------------------------
25//  Includes
26// ---------------------------------------------------------------------------
27#include "MemParse.hpp"
28#include <string.h>
29#include <xercesc/sax/AttributeList.hpp>
30#include <xercesc/sax/SAXParseException.hpp>
31#include <xercesc/sax/SAXException.hpp>
32
33
34
35// ---------------------------------------------------------------------------
36//  MemParseHandlers: Constructors and Destructor
37// ---------------------------------------------------------------------------
38MemParseHandlers::MemParseHandlers() :
39    fAttrCount(0)
40    , fCharacterCount(0)
41    , fElementCount(0)
42    , fSpaceCount(0)
43{
44}
45
46MemParseHandlers::~MemParseHandlers()
47{
48}
49
50
51// ---------------------------------------------------------------------------
52//  MemParseHandlers: Implementation of the SAX DocumentHandler interface
53// ---------------------------------------------------------------------------
54void MemParseHandlers::startElement(const   XMLCh* const    /* name */
55                                    ,       AttributeList&  attributes)
56{
57    fElementCount++;
58    fAttrCount += attributes.getLength();
59}
60
61void MemParseHandlers::characters(  const   XMLCh* const    /* chars */
62                                    , const XMLSize_t    length)
63{
64    fCharacterCount += length;
65}
66
67void MemParseHandlers::ignorableWhitespace( const   XMLCh* const /* chars */
68                                            , const XMLSize_t length)
69{
70    fSpaceCount += length;
71}
72
73void MemParseHandlers::resetDocument()
74{
75    fAttrCount = 0;
76    fCharacterCount = 0;
77    fElementCount = 0;
78    fSpaceCount = 0;
79}
80
81
82
83// ---------------------------------------------------------------------------
84//  MemParseHandlers: Overrides of the SAX ErrorHandler interface
85// ---------------------------------------------------------------------------
86void MemParseHandlers::error(const SAXParseException& e)
87{
88    XERCES_STD_QUALIFIER cerr << "\nError at (file " << StrX(e.getSystemId())
89                 << ", line " << e.getLineNumber()
90                 << ", char " << e.getColumnNumber()
91         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
92}
93
94void MemParseHandlers::fatalError(const SAXParseException& e)
95{
96    XERCES_STD_QUALIFIER cerr << "\nFatal Error at (file " << StrX(e.getSystemId())
97                 << ", line " << e.getLineNumber()
98                 << ", char " << e.getColumnNumber()
99         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
100}
101
102void MemParseHandlers::warning(const SAXParseException& e)
103{
104    XERCES_STD_QUALIFIER cerr << "\nWarning at (file " << StrX(e.getSystemId())
105                 << ", line " << e.getLineNumber()
106                 << ", char " << e.getColumnNumber()
107         << "): " << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl;
108}
109
110
Note: See TracBrowser for help on using the repository browser.