aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dummy/transform.xsl8
-rw-r--r--src/function/read_directory.cc24
-rw-r--r--src/function/read_directory.h4
-rw-r--r--src/transformer_facade.cc8
4 files changed, 28 insertions, 16 deletions
diff --git a/dummy/transform.xsl b/dummy/transform.xsl
index c0437a0..6dc45dc 100644
--- a/dummy/transform.xsl
+++ b/dummy/transform.xsl
@@ -23,9 +23,11 @@
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
- <div id="filelist">
- <xsl:value-of select="external:read-directory('.')" />
- </div>
+ <ul id="filelist">
+ <xsl:for-each select="external:read-directory('.')/content/file">
+ <li><xsl:value-of select="."/></li>
+ </xsl:for-each>
+ </ul>
</body>
</html>
</xsl:template>
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)
+ )
);
}
diff --git a/src/function/read_directory.h b/src/function/read_directory.h
index 4a865f2..e7ee0c4 100644
--- a/src/function/read_directory.h
+++ b/src/function/read_directory.h
@@ -6,6 +6,8 @@
#include <xalanc/XPath/Function.hpp>
#include <xalanc/XPath/XObject.hpp>
+#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
+
#include <string>
#include "common.h"
@@ -16,6 +18,7 @@ namespace InputXSLT {
class FunctionReadDirectory : public xalan::Function {
public:
FunctionReadDirectory(const FilesystemContext&);
+ FunctionReadDirectory(const FunctionReadDirectory&);
virtual xalan::XObjectPtr execute(
xalan::XPathExecutionContext&,
@@ -31,6 +34,7 @@ class FunctionReadDirectory : public xalan::Function {
private:
const FilesystemContext& fs_context_;
+ mutable xalan::XercesParserLiaison parser_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString&) const;
diff --git a/src/transformer_facade.cc b/src/transformer_facade.cc
index 055b1f3..01314cd 100644
--- a/src/transformer_facade.cc
+++ b/src/transformer_facade.cc
@@ -1,12 +1,9 @@
#include "transformer_facade.h"
-#include <xalanc/Include/PlatformDefinitions.hpp>
-#include <xercesc/util/PlatformUtils.hpp>
-
#include <xalanc/XSLT/XSLTInputSource.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
-#include <xalanc/XalanTransformer/XercesDOMWrapperParsedSource.hpp>
#include <xalanc/XercesParserLiaison/XercesDOMSupport.hpp>
+#include <xalanc/XalanTransformer/XercesDOMWrapperParsedSource.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
@@ -59,8 +56,7 @@ int TransformerFacade::execute(
xalan::XercesDOMWrapperParsedSource parsedInput(
inputDom,
this->parser_,
- domSupport,
- xalan::XalanDOMString("")
+ domSupport
);
xalan::XSLTInputSource transform(transformation.data());