aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/function/read_directory.cc26
-rw-r--r--src/support/filesystem_context.cc3
-rw-r--r--src/transformation_facade.cc1
-rw-r--r--src/transformation_facade.h5
4 files changed, 26 insertions, 9 deletions
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index 0ed33bc..22653b6 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -34,16 +34,34 @@ xalan::XObjectPtr FunctionReadDirectory::execute(
this->fs_context_.iterate(
arguments[0]->str(),
[&domDocument, &rootNode](const boost::filesystem::path& p) {
- XMLCh* buffer = xercesc::XMLString::transcode("file");
- xercesc::DOMNode* const fileNode = domDocument->createElement(buffer);
+ XMLCh* buffer = xercesc::XMLString::transcode("item");
+ xercesc::DOMElement* const itemNode = domDocument->createElement(buffer);
+ xercesc::XMLString::release(&buffer);
+
+ buffer = xercesc::XMLString::transcode("type");
+
+ if ( boost::filesystem::is_regular_file(p) ) {
+ XMLCh* valueBuffer = xercesc::XMLString::transcode("file");
+
+ itemNode->setAttribute(buffer, valueBuffer);
+
+ xercesc::XMLString::release(&valueBuffer);
+ } else if ( boost::filesystem::is_directory(p) ) {
+ XMLCh* valueBuffer = xercesc::XMLString::transcode("directory");
+
+ itemNode->setAttribute(buffer, valueBuffer);
+
+ xercesc::XMLString::release(&valueBuffer);
+ }
+
xercesc::XMLString::release(&buffer);
buffer = xercesc::XMLString::transcode(p.filename().string().data());
xercesc::DOMText* const textNode = domDocument->createTextNode(buffer);
xercesc::XMLString::release(&buffer);
- fileNode->appendChild(textNode);
- rootNode->appendChild(fileNode);
+ itemNode->appendChild(textNode);
+ rootNode->appendChild(itemNode);
});
return executionContext.getXObjectFactory().createNodeSet(
diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc
index d0813c2..baeccf3 100644
--- a/src/support/filesystem_context.cc
+++ b/src/support/filesystem_context.cc
@@ -40,7 +40,8 @@ void FilesystemContext::iterate(
for ( boost::filesystem::directory_iterator iter(directory);
iter != boost::filesystem::directory_iterator();
++iter ) {
- if ( boost::filesystem::is_regular_file(iter->status()) ) {
+ if ( boost::filesystem::is_regular_file(iter->status()) ||
+ boost::filesystem::is_directory(iter->status()) ) {
func(*iter);
}
}
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
index 58bdb52..19f7772 100644
--- a/src/transformation_facade.cc
+++ b/src/transformation_facade.cc
@@ -9,7 +9,6 @@
#include "function/read_xml_file.h"
#include "function/read_directory.h"
-
namespace InputXSLT {
TransformationFacade::TransformationFacade(const std::string& transformation):
diff --git a/src/transformation_facade.h b/src/transformation_facade.h
index 715d72e..765a376 100644
--- a/src/transformation_facade.h
+++ b/src/transformation_facade.h
@@ -1,10 +1,9 @@
#ifndef INPUTXSLT_SRC_TRANSFORMATION_FACADE_H_
#define INPUTXSLT_SRC_TRANSFORMATION_FACADE_H_
-#include <string>
-
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
-#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
+
+#include <string>
#include "common.h"
#include "support/filesystem_context.h"