From 1a744712426c9c19019b8ebebdd0c703aae204a6 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Sat, 31 May 2014 14:18:48 +0200 Subject: Revamped external function result trees * the root node of the result tree of each function is a domain element ** i.e. the root node of "read-xml-file" is "file", the root node of "read-directory" is "directory" * the root node contains the result state of the function call encoded in a "result" attribute ** possible values are "success" and "error" ** the root node may contain additional attributes such as the target path of a called transformation * the actual function result is contained within the child nodes of the function root node ** i.e. the XML file tree returned by "read-xml-file" is a child of the function root node ** if specific errors occured they are also returned as child nodes of the function root node *** this is currently only the case for "transform" where transformation errors are returned as "error" value node childs of the function root node * updated test cases accordingly --- src/support/dom/result_node_facade.cc | 11 +++++++++++ src/support/dom/result_node_facade.h | 4 ++++ 2 files changed, 15 insertions(+) (limited to 'src/support') diff --git a/src/support/dom/result_node_facade.cc b/src/support/dom/result_node_facade.cc index 597448b..eeb2cc6 100644 --- a/src/support/dom/result_node_facade.cc +++ b/src/support/dom/result_node_facade.cc @@ -1,6 +1,7 @@ #include "result_node_facade.h" #include +#include #include "support/xerces_string_guard.h" @@ -21,6 +22,10 @@ ResultNodeFacade::~ResultNodeFacade() { this->root_node_->appendChild(this->result_node_); } +xercesc::DOMNode* ResultNodeFacade::getNode() { + return this->result_node_; +} + void ResultNodeFacade::setAttribute( const std::string& name, const std::string& value @@ -58,4 +63,10 @@ void ResultNodeFacade::setContent(xercesc::DOMNode* node) { this->result_node_->appendChild(node); } +void ResultNodeFacade::setContent(xercesc::DOMNodeList* nodes) { + for ( std::size_t index = 0; index != nodes->getLength(); ++index ) { + this->setContent(nodes->item(index)); + } +} + } diff --git a/src/support/dom/result_node_facade.h b/src/support/dom/result_node_facade.h index ccdd850..bf73582 100644 --- a/src/support/dom/result_node_facade.h +++ b/src/support/dom/result_node_facade.h @@ -18,10 +18,14 @@ class ResultNodeFacade { ); ~ResultNodeFacade(); + xercesc::DOMNode* getNode(); + void setAttribute(const std::string&, const std::string&); void setValueNode(const std::string&, const std::string&); + void setContent(const std::string&); void setContent(xercesc::DOMNode*); + void setContent(xercesc::DOMNodeList*); private: xercesc::DOMDocument* const dom_document_; -- cgit v1.2.3