25 #ifndef MESSAGE_XML_CALLBACKS20091211H 26 #define MESSAGE_XML_CALLBACKS20091211H 31 #include <boost/algorithm/string.hpp> 32 #include <xercesc/sax2/Attributes.hpp> 33 #include <xercesc/sax2/DefaultHandler.hpp> 35 #include "goby/moos/transitional/xml/xerces_strings.h" 37 #include "goby/acomms/dccl.h" 38 #include "goby/moos/transitional/xml/tags.h" 43 namespace transitional
54 initialize_tags(tags_map_);
57 void startElement(
const XMLCh*
const uri,
58 const XMLCh*
const localname,
59 const XMLCh*
const qname,
60 const xercesc::Attributes& attrs);
62 void endElement(
const XMLCh*
const uri,
63 const XMLCh*
const localname,
64 const XMLCh*
const qname);
66 #if XERCES_VERSION_MAJOR < 3 67 void characters(
const XMLCh*
const chars,
const unsigned int length)
69 current_text.append(toNative(chars), 0, length);
72 void characters(
const XMLCh*
const chars,
const XMLSize_t length)
74 current_text.append(toNative(chars), 0, length);
79 bool in_message_var() {
return xml::in_message_var(parents_); }
80 bool in_header_var() {
return xml::in_header_var(parents_); }
81 bool in_publish() {
return xml::in_publish(parents_); }
84 std::vector<DCCLMessage>& messages;
85 std::string current_text;
87 std::set<xml::Tag> parents_;
88 std::map<std::string, xml::Tag> tags_map_;
90 transitional::DCCLHeaderPart curr_head_piece_;
97 void warning(
const xercesc::SAXParseException& e)
99 std::cout <<
"warning:" << toNative(e.getMessage());
101 void error(
const xercesc::SAXParseException& e)
103 XMLSSize_t line = e.getLineNumber();
104 std::stringstream ss;
105 ss <<
"message xml parsing error on line " << line <<
": " << std::endl
106 << toNative(e.getMessage());
108 throw goby::acomms::DCCLException(ss.str());
110 void fatalError(
const xercesc::SAXParseException& e) { error(e); }
The global namespace for the Goby project.