output warning message now directed to the message_sink

This commit is contained in:
jez 2008-10-21 22:53:00 +01:00
parent 4ee266a1a8
commit 7f99fa0b1e
2 changed files with 19 additions and 6 deletions

View file

@ -44,6 +44,8 @@ public:
to_msg_(0)
{
xpathContext_.setVariableResolver(stack_);
sink_.set_warning_sink(message_sink_.asOutput());
message_sink_.asOutput().set_warning_sink(message_sink_.asOutput());
} // ExecutionContext
ExecutionContext(Sink& output,

View file

@ -26,7 +26,8 @@ protected:
buffering_(0),
pending_element_(false),
pending_attribute_(-1),
text_mode_(false)
text_mode_(false),
warning_sink_(0)
{
} // Output
~Output()
@ -112,7 +113,7 @@ public:
if(!pending_element_)
{
std::cerr << "ERROR: Cannot write attribute, no open element" << std::endl;
warning("WARNING: Cannot write attribute, no open element");
return;
} // if ...
@ -150,7 +151,7 @@ public:
{
if(!pending_element_)
{
std::cerr << "ERROR: Cannot write attribute, no open element" << std::endl;
warning("WARNING: Cannot write attribute, no open element");
return;
} // if ...
@ -228,6 +229,11 @@ public:
do_disableOutputEscaping(disable);
} // disableOutputEscaping
void set_warning_sink(Output& warning_sink)
{
warning_sink_ = &warning_sink;
} // set_warning_sink
protected:
virtual void do_start_document(const Settings& settings) = 0;
virtual void do_end_document() = 0;
@ -267,7 +273,7 @@ private:
{
if(!buffering_)
return false;
std::cerr << "ERROR: non-text ignored when creating processing instruction, comment or attribute" << std::endl;
warning("WARNING: non-text ignored when creating processing instruction, comment or attribute");
return true;
} // is_buffering
@ -321,6 +327,12 @@ private:
}
} // addNamespaceDeclarations
void warning(const std::string& warning_message)
{
warning_sink_->characters(warning_message);
warning_sink_->characters("\n");
} // warning
int buffering_;
bool pending_element_;
int pending_attribute_;
@ -330,6 +342,7 @@ private:
std::stringstream buffer_;
bool text_mode_;
NamespaceStack namespaceStack_;
Output* warning_sink_;
}; // class Output
class Sink
@ -512,7 +525,6 @@ protected:
bool want_namespace_declarations() const { return true; }
private:
void close_element_if_empty()
{
@ -668,7 +680,6 @@ protected:
bool want_namespace_declarations() const { return false; }
void do_start_element(const std::string& qName,
const std::string& namespaceURI,
const SAX::Attributes<std::string>& atts)