diff options
author | Adrian Kummerländer | 2014-05-31 10:44:23 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-05-31 10:44:23 +0200 |
commit | d5367d268e8f2be9dd519b3b90f7baa64d6d50b7 (patch) | |
tree | e10e2b2b3e480c2b994515e35fd486b77b2e34dd | |
parent | 79d3e2bdfd441d6eba2f22af78d5bea5e488daf1 (diff) | |
download | InputXSLT-d5367d268e8f2be9dd519b3b90f7baa64d6d50b7.tar InputXSLT-d5367d268e8f2be9dd519b3b90f7baa64d6d50b7.tar.gz InputXSLT-d5367d268e8f2be9dd519b3b90f7baa64d6d50b7.tar.bz2 InputXSLT-d5367d268e8f2be9dd519b3b90f7baa64d6d50b7.tar.lz InputXSLT-d5367d268e8f2be9dd519b3b90f7baa64d6d50b7.tar.xz InputXSLT-d5367d268e8f2be9dd519b3b90f7baa64d6d50b7.tar.zst InputXSLT-d5367d268e8f2be9dd519b3b90f7baa64d6d50b7.zip |
Using xalan::ProblemListenerBase formatting functionality in ErrorCapacitor
* xalan::ProblemListenerBase provides a static member method called "defaultFormat"
** this method provides formatting of problem messages into xalan::XalanDOMString instances when combined with xalan::DOMStringPrintWriter
* there is no need for implementing custom message formatting
** the only reason why ErrorCapacitor exists is so we are able to capture and print messages at our own volition
-rw-r--r-- | src/support/error_capacitor.cc | 65 | ||||
-rw-r--r-- | src/support/error_capacitor.h | 15 |
2 files changed, 49 insertions, 31 deletions
diff --git a/src/support/error_capacitor.cc b/src/support/error_capacitor.cc index e83ba9a..1a536ed 100644 --- a/src/support/error_capacitor.cc +++ b/src/support/error_capacitor.cc @@ -2,6 +2,8 @@ #include <xercesc/sax/SAXParseException.hpp> +#include <xalanc/PlatformSupport/DOMStringPrintWriter.hpp> + #include <iostream> #include "support/xalan_string.h" @@ -58,42 +60,57 @@ void ErrorCapacitor::fatalError(const xercesc::SAXParseException& exception) { void ErrorCapacitor::resetErrors() { } void ErrorCapacitor::problem( - xalan::ProblemListenerBase::eSource, - xalan::ProblemListenerBase::eClassification, - const xalan::XalanDOMString& message, - const xalan::Locator*, - const xalan::XalanNode* + xalan::ProblemListenerBase::eSource source, + xalan::ProblemListenerBase::eClassification classification, + const xalan::XalanDOMString& message, + const xalan::Locator* locator, + const xalan::XalanNode* node ) { - this->error_cache_->emplace_back( - "XSLT problem: " + toString(message) + xalan::XalanDOMString problemSummary; + xalan::DOMStringPrintWriter writer(problemSummary); + + defaultFormat( + writer, + source, + classification, + message, + locator, + node ); + + this->error_cache_->emplace_back(toString(problemSummary)); } void ErrorCapacitor::problem( - xalan::ProblemListenerBase::eSource, - xalan::ProblemListenerBase::eClassification, - const xalan::XalanNode*, - const xalan::ElemTemplateElement*, - const xalan::XalanDOMString& message, - const xalan::XalanDOMChar*, - xalan::XalanFileLoc, - xalan::XalanFileLoc + xalan::ProblemListenerBase::eSource source, + xalan::ProblemListenerBase::eClassification classification, + const xalan::XalanDOMString& message, + const xalan::XalanNode* node ) { - this->error_cache_->emplace_back( - "XSLT problem: " + toString(message) + xalan::XalanDOMString problemSummary; + xalan::DOMStringPrintWriter writer(problemSummary); + + defaultFormat( + writer, + source, + classification, + message, + node ); + + this->error_cache_->emplace_back(toString(problemSummary)); } void ErrorCapacitor::problem( xalan::ProblemListenerBase::eSource, xalan::ProblemListenerBase::eClassification, - const xalan::XalanDOMString& message, - const xalan::XalanNode* -) { - this->error_cache_->emplace_back( - "XSLT problem: " + toString(message) - ); -} + const xalan::XalanNode*, + const xalan::ElemTemplateElement*, + const xalan::XalanDOMString&, + const xalan::XalanDOMChar*, + xalan::XalanFileLoc, + xalan::XalanFileLoc +) { } void ErrorCapacitor::setPrintWriter(xalan::PrintWriter*) { } diff --git a/src/support/error_capacitor.h b/src/support/error_capacitor.h index d89b5ae..b94d5f8 100644 --- a/src/support/error_capacitor.h +++ b/src/support/error_capacitor.h @@ -2,6 +2,7 @@ #define INPUTXSLT_SRC_SUPPORT_ERROR_CAPACITOR_H_ #include <xercesc/sax/ErrorHandler.hpp> + #include <xalanc/XSLT/ProblemListener.hpp> #include <xalanc/XalanTransformer/XalanTransformer.hpp> @@ -14,7 +15,7 @@ namespace InputXSLT { class ErrorCapacitor : public xercesc::ErrorHandler, - public xalan::ProblemListener { + public xalan::ProblemListener { public: class exception; @@ -42,19 +43,19 @@ class ErrorCapacitor : public xercesc::ErrorHandler, virtual void problem( xalan::ProblemListenerBase::eSource, xalan::ProblemListenerBase::eClassification, - const xalan::XalanNode*, - const xalan::ElemTemplateElement*, const xalan::XalanDOMString&, - const xalan::XalanDOMChar*, - xalan::XalanFileLoc, - xalan::XalanFileLoc + const xalan::XalanNode* ); virtual void problem( xalan::ProblemListenerBase::eSource, xalan::ProblemListenerBase::eClassification, + const xalan::XalanNode*, + const xalan::ElemTemplateElement*, const xalan::XalanDOMString&, - const xalan::XalanNode* + const xalan::XalanDOMChar*, + xalan::XalanFileLoc, + xalan::XalanFileLoc ); virtual void setPrintWriter(xalan::PrintWriter*); |