mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-30 08:38:15 +01:00
output warning message now directed to the message_sink
This commit is contained in:
parent
4ee266a1a8
commit
7f99fa0b1e
2 changed files with 19 additions and 6 deletions
|
@ -44,6 +44,8 @@ public:
|
||||||
to_msg_(0)
|
to_msg_(0)
|
||||||
{
|
{
|
||||||
xpathContext_.setVariableResolver(stack_);
|
xpathContext_.setVariableResolver(stack_);
|
||||||
|
sink_.set_warning_sink(message_sink_.asOutput());
|
||||||
|
message_sink_.asOutput().set_warning_sink(message_sink_.asOutput());
|
||||||
} // ExecutionContext
|
} // ExecutionContext
|
||||||
|
|
||||||
ExecutionContext(Sink& output,
|
ExecutionContext(Sink& output,
|
||||||
|
|
|
@ -26,7 +26,8 @@ protected:
|
||||||
buffering_(0),
|
buffering_(0),
|
||||||
pending_element_(false),
|
pending_element_(false),
|
||||||
pending_attribute_(-1),
|
pending_attribute_(-1),
|
||||||
text_mode_(false)
|
text_mode_(false),
|
||||||
|
warning_sink_(0)
|
||||||
{
|
{
|
||||||
} // Output
|
} // Output
|
||||||
~Output()
|
~Output()
|
||||||
|
@ -112,7 +113,7 @@ public:
|
||||||
|
|
||||||
if(!pending_element_)
|
if(!pending_element_)
|
||||||
{
|
{
|
||||||
std::cerr << "ERROR: Cannot write attribute, no open element" << std::endl;
|
warning("WARNING: Cannot write attribute, no open element");
|
||||||
return;
|
return;
|
||||||
} // if ...
|
} // if ...
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ public:
|
||||||
{
|
{
|
||||||
if(!pending_element_)
|
if(!pending_element_)
|
||||||
{
|
{
|
||||||
std::cerr << "ERROR: Cannot write attribute, no open element" << std::endl;
|
warning("WARNING: Cannot write attribute, no open element");
|
||||||
return;
|
return;
|
||||||
} // if ...
|
} // if ...
|
||||||
|
|
||||||
|
@ -228,6 +229,11 @@ public:
|
||||||
do_disableOutputEscaping(disable);
|
do_disableOutputEscaping(disable);
|
||||||
} // disableOutputEscaping
|
} // disableOutputEscaping
|
||||||
|
|
||||||
|
void set_warning_sink(Output& warning_sink)
|
||||||
|
{
|
||||||
|
warning_sink_ = &warning_sink;
|
||||||
|
} // set_warning_sink
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void do_start_document(const Settings& settings) = 0;
|
virtual void do_start_document(const Settings& settings) = 0;
|
||||||
virtual void do_end_document() = 0;
|
virtual void do_end_document() = 0;
|
||||||
|
@ -267,7 +273,7 @@ private:
|
||||||
{
|
{
|
||||||
if(!buffering_)
|
if(!buffering_)
|
||||||
return false;
|
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;
|
return true;
|
||||||
} // is_buffering
|
} // is_buffering
|
||||||
|
|
||||||
|
@ -321,6 +327,12 @@ private:
|
||||||
}
|
}
|
||||||
} // addNamespaceDeclarations
|
} // addNamespaceDeclarations
|
||||||
|
|
||||||
|
void warning(const std::string& warning_message)
|
||||||
|
{
|
||||||
|
warning_sink_->characters(warning_message);
|
||||||
|
warning_sink_->characters("\n");
|
||||||
|
} // warning
|
||||||
|
|
||||||
int buffering_;
|
int buffering_;
|
||||||
bool pending_element_;
|
bool pending_element_;
|
||||||
int pending_attribute_;
|
int pending_attribute_;
|
||||||
|
@ -330,6 +342,7 @@ private:
|
||||||
std::stringstream buffer_;
|
std::stringstream buffer_;
|
||||||
bool text_mode_;
|
bool text_mode_;
|
||||||
NamespaceStack namespaceStack_;
|
NamespaceStack namespaceStack_;
|
||||||
|
Output* warning_sink_;
|
||||||
}; // class Output
|
}; // class Output
|
||||||
|
|
||||||
class Sink
|
class Sink
|
||||||
|
@ -512,7 +525,6 @@ protected:
|
||||||
|
|
||||||
bool want_namespace_declarations() const { return true; }
|
bool want_namespace_declarations() const { return true; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void close_element_if_empty()
|
void close_element_if_empty()
|
||||||
{
|
{
|
||||||
|
@ -668,7 +680,6 @@ protected:
|
||||||
|
|
||||||
bool want_namespace_declarations() const { return false; }
|
bool want_namespace_declarations() const { return false; }
|
||||||
|
|
||||||
|
|
||||||
void do_start_element(const std::string& qName,
|
void do_start_element(const std::string& qName,
|
||||||
const std::string& namespaceURI,
|
const std::string& namespaceURI,
|
||||||
const SAX::Attributes<std::string>& atts)
|
const SAX::Attributes<std::string>& atts)
|
||||||
|
|
Loading…
Add table
Reference in a new issue