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/function/read_directory.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/function/read_directory.cc') diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc index f4baff6..e54e146 100644 --- a/src/function/read_directory.cc +++ b/src/function/read_directory.cc @@ -29,11 +29,18 @@ xercesc::DOMDocument* FunctionReadDirectory::constructDocument( domDocument->getDocumentElement() ); + ResultNodeFacade result(domDocument, rootNode, "directory"); + result.setAttribute("path", directoryPath.string()); + if ( boost::filesystem::is_directory(directoryPath) ) { + result.setAttribute("result", "success"); + + xercesc::DOMNode* const resultNode = result.getNode(); + fsContext.iterate( directoryPath, - [&domDocument, &rootNode](const boost::filesystem::path& p) { - ResultNodeFacade result(domDocument, rootNode, "result"); + [&domDocument, &resultNode](const boost::filesystem::path& p) { + ResultNodeFacade result(domDocument, resultNode, "entry"); switch ( boost::filesystem::status(p).type() ) { case boost::filesystem::regular_file: { @@ -60,7 +67,7 @@ xercesc::DOMDocument* FunctionReadDirectory::constructDocument( result.setValueNode("full", boost::filesystem::canonical(p).string()); }); } else { - ResultNodeFacade result(domDocument, rootNode, "error"); + result.setAttribute("result", "error"); } return domDocument; -- cgit v1.2.3