Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ACEXML / examples / SAXPrint / SAXPrint_Handler.cpp
blobae1fbc605ec266215b6b9e84fdb096f3f782c931
1 // -*- C++ -*-
3 #include "SAXPrint_Handler.h"
4 #include "ace/ACE.h"
5 #include "ace/Log_Msg.h"
7 #if !defined (__ACEXML_INLINE__)
8 # include "SAXPrint_Handler.inl"
9 #endif /* __ACEXML_INLINE__ */
11 ACEXML_SAXPrint_Handler::ACEXML_SAXPrint_Handler (const ACEXML_Char* filename)
12 : indent_ (0), fileName_(ACE::strnew (filename)), locator_ (0)
16 ACEXML_SAXPrint_Handler::~ACEXML_SAXPrint_Handler ()
18 delete [] this->fileName_;
21 void
22 ACEXML_SAXPrint_Handler::characters (const ACEXML_Char *cdata,
23 size_t,
24 size_t)
26 ACE_DEBUG ((LM_DEBUG,
27 ACE_TEXT ("%s"),
28 cdata));
31 void
32 ACEXML_SAXPrint_Handler::endDocument ()
34 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
37 void
38 ACEXML_SAXPrint_Handler::endElement (const ACEXML_Char *,
39 const ACEXML_Char *,
40 const ACEXML_Char *qName)
42 this->dec_indent ();
43 this->print_indent ();
44 ACE_DEBUG ((LM_DEBUG,
45 ACE_TEXT ("</%s>"),
46 qName));
49 void
50 ACEXML_SAXPrint_Handler::endPrefixMapping (const ACEXML_Char *)
52 // ACE_DEBUG ((LM_DEBUG,
53 // ACE_TEXT ("* Event endPrefixMapping (%s) ***************\n"),
54 // prefix));
57 void
58 ACEXML_SAXPrint_Handler::ignorableWhitespace (const ACEXML_Char * cdata,
59 int,
60 int)
62 ACE_DEBUG ((LM_DEBUG,
63 ACE_TEXT ("%s"),
64 cdata));
65 // ACE_DEBUG ((LM_DEBUG,
66 // ACE_TEXT ("* Event ignorableWhitespace () ***************\n")));
69 void
70 ACEXML_SAXPrint_Handler::processingInstruction (const ACEXML_Char *target,
71 const ACEXML_Char *data)
73 this->print_indent ();
74 ACE_DEBUG ((LM_DEBUG,
75 ACE_TEXT ("<?%s %s>\n"),
76 target, data));
79 void
80 ACEXML_SAXPrint_Handler::setDocumentLocator (ACEXML_Locator * locator)
82 this->locator_ = locator;
83 //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event setDocumentLocator () ***************\n")));
86 void
87 ACEXML_SAXPrint_Handler::skippedEntity (const ACEXML_Char *name)
89 ACE_DEBUG ((LM_DEBUG,
90 ACE_TEXT ("* Event skippedEntity (%s) ***************\n"),
91 name));
94 void
95 ACEXML_SAXPrint_Handler::startDocument ()
97 ACE_DEBUG ((LM_DEBUG,
98 ACE_TEXT ("* Event startDocument () ***************\n")));
101 void
102 ACEXML_SAXPrint_Handler::startElement (const ACEXML_Char *,
103 const ACEXML_Char *,
104 const ACEXML_Char *qName,
105 ACEXML_Attributes *alist)
107 this->print_indent ();
109 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("<%s"),
110 qName));
111 if (alist != 0)
112 for (size_t i = 0; i < alist->getLength (); ++i)
114 ACE_DEBUG ((LM_DEBUG,
115 ACE_TEXT (" %s = \"%s\""),
116 alist->getQName (i), alist->getValue (i)));
118 ACE_DEBUG ((LM_DEBUG, ACE_TEXT (">")));
119 this->inc_indent ();
122 void
123 ACEXML_SAXPrint_Handler::startPrefixMapping (const ACEXML_Char * ,
124 const ACEXML_Char *)
126 // ACE_DEBUG ((LM_DEBUG,
127 // ACE_TEXT ("* Event startPrefixMapping () ***************\n")));
128 // ACE_DEBUG ((LM_DEBUG,
129 // ACE_TEXT ("Prefix = %s, URI = %s\n"), prefix, uri));
132 // *** Methods inherited from ACEXML_DTDHandler.
134 void
135 ACEXML_SAXPrint_Handler::notationDecl (const ACEXML_Char *,
136 const ACEXML_Char *,
137 const ACEXML_Char *)
139 // No-op.
142 void
143 ACEXML_SAXPrint_Handler::unparsedEntityDecl (const ACEXML_Char *,
144 const ACEXML_Char *,
145 const ACEXML_Char *,
146 const ACEXML_Char *)
148 // No-op.
151 // Methods inherited from ACEXML_EnitityResolver.
153 ACEXML_InputSource *
154 ACEXML_SAXPrint_Handler::resolveEntity (const ACEXML_Char *,
155 const ACEXML_Char *)
157 // No-op.
158 return 0;
161 // Methods inherited from ACEXML_ErrorHandler.
164 * Receive notification of a recoverable error.
166 void
167 ACEXML_SAXPrint_Handler::error (ACEXML_SAXParseException & ex)
169 ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
170 (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
171 this->locator_->getLineNumber(),
172 this->locator_->getColumnNumber()));
173 ex.print();
176 void
177 ACEXML_SAXPrint_Handler::fatalError (ACEXML_SAXParseException & ex)
179 ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ",
180 (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()),
181 this->locator_->getLineNumber(),
182 this->locator_->getColumnNumber()));
183 ex.print();
186 void
187 ACEXML_SAXPrint_Handler::warning (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_SAXPrint_Handler::print_indent ()
199 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
200 for (size_t i = 0; i < this->indent_; ++i)
201 ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" ")));