aboutsummaryrefslogtreecommitdiff
path: root/src/function/read_directory.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-22 22:49:56 +0200
committerAdrian Kummerländer2014-04-22 22:49:56 +0200
commit34b2f97ac57489d7c9555a3cb0c92c808a4948ea (patch)
treee54b367a4e4d5204c47b1478d1a0253cf42c2f25 /src/function/read_directory.cc
parent7142544d43b431df44d34921b0f3012fa1e0137d (diff)
downloadInputXSLT-34b2f97ac57489d7c9555a3cb0c92c808a4948ea.tar
InputXSLT-34b2f97ac57489d7c9555a3cb0c92c808a4948ea.tar.gz
InputXSLT-34b2f97ac57489d7c9555a3cb0c92c808a4948ea.tar.bz2
InputXSLT-34b2f97ac57489d7c9555a3cb0c92c808a4948ea.tar.lz
InputXSLT-34b2f97ac57489d7c9555a3cb0c92c808a4948ea.tar.xz
InputXSLT-34b2f97ac57489d7c9555a3cb0c92c808a4948ea.tar.zst
InputXSLT-34b2f97ac57489d7c9555a3cb0c92c808a4948ea.zip
Implemented basic XML output of external read-directory function
* output is generated from XML hand-generated in a std::stringstream ** while this works reasonably well it is not how it should by done, i.e. this will have to be reimplemented using xerces / xalan constructs ** => this is intended to try out how a read-directory could work in a XSLT context
Diffstat (limited to 'src/function/read_directory.cc')
-rw-r--r--src/function/read_directory.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index 7b73526..213ef68 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -1,11 +1,16 @@
#include "read_directory.h"
-#include <iostream>
+#include <sstream>
namespace InputXSLT {
FunctionReadDirectory::FunctionReadDirectory(const FilesystemContext& context):
- fs_context_(context) { }
+ fs_context_(context),
+ parser_() { }
+
+FunctionReadDirectory::FunctionReadDirectory(const FunctionReadDirectory& src):
+ fs_context_(src.fs_context_),
+ parser_() { }
xalan::XObjectPtr FunctionReadDirectory::execute(
xalan::XPathExecutionContext& executionContext,
@@ -21,16 +26,21 @@ xalan::XObjectPtr FunctionReadDirectory::execute(
this->generalError(executionContext, context, locator);
}
- std::string files;
+ std::stringstream stream;
+ stream << "<content>";
this->fs_context_.iterate(
arguments[0]->str(),
- [&files](const boost::filesystem::path& p) {
- files += p.string() + "\n";
+ [&stream](const boost::filesystem::path& p) {
+ stream << "<file>" << p.filename().string() << "</file>";
});
- return executionContext.getXObjectFactory().createString(
- xalan::XalanDOMString(files.data())
+ stream << "</content>";
+
+ return executionContext.getXObjectFactory().createNodeSet(
+ this->parser_.parseXMLStream(
+ xalan::XSLTInputSource(stream)
+ )
);
}