Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ACEXML / examples / SAXPrint / Print_Handler.cpp
blobd63a112808fcbbc5542cfba82209fe2fc10f195d
1 // -*- C++ -*-
3 #include "Print_Handler.h"
4 #include "ace/ACE.h"
5 #include "ace/Log_Msg.h"
7 ACEXML_Print_Handler::ACEXML_Print_Handler (ACEXML_Char* fileName)
8 : fileName_(ACE::strnew (fileName)),
9 locator_ (0)
13 ACEXML_Print_Handler::~ACEXML_Print_Handler ()
15 delete[] this->fileName_;
18 void
19 ACEXML_Print_Handler::characters (const ACEXML_Char *cdata,
20 size_t start,
21 size_t length)
23 ACE_DEBUG ((LM_DEBUG,
24 ACE_TEXT ("* Event characters () ** start: %u end: %u ***************\n%s\n- End event characters () ---------------\n"),
25 start, length, cdata));
28 void
29 ACEXML_Print_Handler::endDocument ()
31 ACE_DEBUG ((LM_DEBUG,
32 ACE_TEXT ("* Event endDocument () ***************\n")));
35 void
36 ACEXML_Print_Handler::endElement (const ACEXML_Char *uri,
37 const ACEXML_Char *name,
38 const ACEXML_Char *qName)
40 ACE_DEBUG ((LM_DEBUG,
41 ACE_TEXT ("* Event endElement (%s, %s, %s) ***************\n"),
42 uri, name, qName));
45 void
46 ACEXML_Print_Handler::endPrefixMapping (const ACEXML_Char *prefix)
48 ACE_DEBUG ((LM_DEBUG,
49 ACE_TEXT ("* Event endPrefixMapping (%s) ***************\n"),
50 prefix));
53 void
54 ACEXML_Print_Handler::ignorableWhitespace (const ACEXML_Char *,
55 int,
56 int)
58 // ACE_DEBUG ((LM_DEBUG,
59 // ACE_TEXT ("* Event ignorableWhitespace () ***************\n")));
62 void
63 ACEXML_Print_Handler::processingInstruction (const ACEXML_Char *target,
64 const ACEXML_Char *data)
66 ACE_DEBUG ((LM_DEBUG,
67 ACE_TEXT ("* Event processingInstruction (%s, %s) ***************\n"),
68 target, data));
71 void
72 ACEXML_Print_Handler::setDocumentLocator (ACEXML_Locator * locator)
74 this->locator_ = locator;
75 // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event setDocumentLocator () ***************\n")));
78 void
79 ACEXML_Print_Handler::skippedEntity (const ACEXML_Char *name)
81 ACE_DEBUG ((LM_DEBUG,
82 ACE_TEXT ("* Event skippedEntity (%s) ***************\n"),
83 name));
86 void
87 ACEXML_Print_Handler::startDocument ()
89 ACE_DEBUG ((LM_DEBUG,
90 ACE_TEXT ("* Event startDocument () ***************\n")));
93 void
94 ACEXML_Print_Handler::startElement (const ACEXML_Char *uri,
95 const ACEXML_Char *name,
96 const ACEXML_Char *qName,
97 ACEXML_Attributes *alist)
99 ACE_DEBUG ((LM_DEBUG,
100 ACE_TEXT ("* Event startElement (%s, %s, %s) ***************\n"),
101 uri, name, qName));
103 if (alist != 0)
104 for (size_t i = 0; i < alist->getLength (); ++i)
106 ACE_DEBUG ((LM_DEBUG,
107 ACE_TEXT (" %s = \"%s\"\n"),
108 alist->getQName (i), alist->getValue (i)));
112 void
113 ACEXML_Print_Handler::startPrefixMapping (const ACEXML_Char * prefix,
114 const ACEXML_Char * uri)
116 ACE_DEBUG ((LM_DEBUG,
117 ACE_TEXT ("* Event startPrefixMapping () ***************\n")));
118 ACE_DEBUG ((LM_DEBUG,
119 ACE_TEXT ("Prefix = %s, URI = %s\n"), prefix, uri));
122 // *** Methods inherit from ACEXML_DTDHandler.
124 void
125 ACEXML_Print_Handler::notationDecl (const ACEXML_Char *name,
126 const ACEXML_Char *publicID,
127 const ACEXML_Char *systemID)
129 ACE_DEBUG ((LM_DEBUG,
130 ACE_TEXT ("* Event notationDecl: (%s) "),
131 name));
133 if (publicID == 0)
134 ACE_DEBUG ((LM_DEBUG,
135 ACE_TEXT ("SYSTEM %s\n"),
136 systemID));
137 else if (systemID == 0)
138 ACE_DEBUG ((LM_DEBUG,
139 ACE_TEXT ("PUBLIC %s\n"),
140 publicID));
141 else
142 ACE_DEBUG ((LM_DEBUG,
143 ACE_TEXT ("PUBLIC %s %s\n"),
144 publicID, systemID));
147 void
148 ACEXML_Print_Handler::unparsedEntityDecl (const ACEXML_Char *name,
149 const ACEXML_Char *publicID,
150 const ACEXML_Char *systemID,
151 const ACEXML_Char *notationName)
153 ACE_DEBUG ((LM_DEBUG,
154 ACE_TEXT ("* Unparsed Entity: %s"),
155 name));
157 if (publicID == 0)
158 ACE_DEBUG ((LM_DEBUG,
159 ACE_TEXT (" SYSTEM %s"),
160 systemID));
161 else
162 ACE_DEBUG ((LM_DEBUG,
163 ACE_TEXT (" PUBLIC %s %s"),
164 publicID, systemID));
166 ACE_DEBUG ((LM_DEBUG,
167 ACE_TEXT (" NDATA %s\n"),
168 notationName));
171 // Methods inherit from ACEXML_EnitityResolver.
173 ACEXML_InputSource *
174 ACEXML_Print_Handler::resolveEntity (const ACEXML_Char *,
175 const ACEXML_Char *)
177 // No-op.
178 return 0;
181 // Methods inherit from ACEXML_ErrorHandler.
184 * Receive notification of a recoverable error.
186 void
187 ACEXML_Print_Handler::error (ACEXML_SAXParseException & ex)
189 ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
190 (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
191 this->locator_->getLineNumber(),
192 this->locator_->getColumnNumber()));
193 ex.print();
196 void
197 ACEXML_Print_Handler::fatalError (ACEXML_SAXParseException& ex)
199 ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
200 (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
201 this->locator_->getLineNumber(),
202 this->locator_->getColumnNumber()));
203 ex.print();
206 void
207 ACEXML_Print_Handler::warning (ACEXML_SAXParseException & ex)
209 ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
210 (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
211 this->locator_->getLineNumber(),
212 this->locator_->getColumnNumber()));
213 ex.print();