source: icXML/icXML-devel/samples/src/StdInParse/StdInParseHandlers.cpp @ 2733

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