aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-07-04 22:41:17 +0200
committerAdrian Kummerlaender2014-07-04 22:41:17 +0200
commitf05e742b88e3ebf7401c252332022f1a2f7eb8b0 (patch)
tree038e011e808eb86e4c8ebfee11132e5c952edaf0
parent784ac42a0f05608e3d9c5e15246dbf76ce9e3d51 (diff)
downloadInputXSLT-f05e742b88e3ebf7401c252332022f1a2f7eb8b0.tar
InputXSLT-f05e742b88e3ebf7401c252332022f1a2f7eb8b0.tar.gz
InputXSLT-f05e742b88e3ebf7401c252332022f1a2f7eb8b0.tar.bz2
InputXSLT-f05e742b88e3ebf7401c252332022f1a2f7eb8b0.tar.lz
InputXSLT-f05e742b88e3ebf7401c252332022f1a2f7eb8b0.tar.xz
InputXSLT-f05e742b88e3ebf7401c252332022f1a2f7eb8b0.tar.zst
InputXSLT-f05e742b88e3ebf7401c252332022f1a2f7eb8b0.zip
Changed FunctionTransform result type to node-set
* using xalan::FormatterToXercesDOM internally ** this required changes to the TransformationFacade::generate member method overloads * TransformationFacade::generate now accepts references to xalan::FormatterListener instances ** "generate(std::basic_ostream<char>&..." instantiates a xalan::FormatterToXML and passes it to the actual generate member method * changed ResultNodeFacade's "getNode" method into a "getResultElement" method ** xalan::FormatterToXercesDOM requires a xercesc::DOMElement instance instead of the previously available xercesc::DOMNode instance ** changed FunctionReadDirectory accordingly * adapted FunctionTransform test case accordingly
-rw-r--r--src/function/read_directory.cc2
-rw-r--r--src/function/transform.cc19
-rw-r--r--src/support/dom/result_node_facade.cc2
-rw-r--r--src/support/dom/result_node_facade.h2
-rw-r--r--src/transformation_facade.cc38
-rw-r--r--src/transformation_facade.h9
-rw-r--r--test/transform/transformation.xsl2
7 files changed, 38 insertions, 36 deletions
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index 884963e..d5357e8 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -29,7 +29,7 @@ xercesc::DOMDocument* FunctionReadDirectory::constructDocument(
if ( boost::filesystem::is_directory(directoryPath) ) {
result.setAttribute("result", "success");
- xercesc::DOMNode* const resultNode = result.getNode();
+ xercesc::DOMNode* const resultNode = result.getResultElement();
FilesystemContext::iterate(
directoryPath,
diff --git a/src/function/transform.cc b/src/function/transform.cc
index bc71125..1d22399 100644
--- a/src/function/transform.cc
+++ b/src/function/transform.cc
@@ -1,11 +1,11 @@
#include "transform.h"
+#include <xalanc/XercesParserLiaison/FormatterToXercesDOM.hpp>
+
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMElement.hpp>
-#include <sstream>
-
#include "transformation_facade.h"
#include "support/xerces_string_guard.h"
#include "support/dom/result_node_facade.h"
@@ -43,11 +43,11 @@ xercesc::DOMDocument* FunctionTransform::constructDocument(
)
);
- xercesc::DOMNode* const rootNode(
+ xercesc::DOMElement* const rootElement(
domDocument->getDocumentElement()
);
- ResultNodeFacade result(domDocument, rootNode, "transformation");
+ ResultNodeFacade result(domDocument, rootElement, "transformation");
if ( auto transformation = TransformationFacade::try_create(
handleErrors(result),
@@ -56,17 +56,16 @@ xercesc::DOMDocument* FunctionTransform::constructDocument(
this->include_resolver_
) ) {
try {
- std::stringstream targetStream;
+ xalan::FormatterToXercesDOM formatter(
+ domDocument,
+ result.getResultElement()
+ );
transformation->generate(
- targetStream,
+ formatter,
parameterObject
);
- result.setContent(
- targetStream.str()
- );
-
result.setAttribute("result", "success");
}
catch (const ErrorCapacitor::exception& exception) {
diff --git a/src/support/dom/result_node_facade.cc b/src/support/dom/result_node_facade.cc
index eeb2cc6..570b4e1 100644
--- a/src/support/dom/result_node_facade.cc
+++ b/src/support/dom/result_node_facade.cc
@@ -22,7 +22,7 @@ ResultNodeFacade::~ResultNodeFacade() {
this->root_node_->appendChild(this->result_node_);
}
-xercesc::DOMNode* ResultNodeFacade::getNode() {
+xercesc::DOMElement* ResultNodeFacade::getResultElement() {
return this->result_node_;
}
diff --git a/src/support/dom/result_node_facade.h b/src/support/dom/result_node_facade.h
index bf73582..c7e831e 100644
--- a/src/support/dom/result_node_facade.h
+++ b/src/support/dom/result_node_facade.h
@@ -18,7 +18,7 @@ class ResultNodeFacade {
);
~ResultNodeFacade();
- xercesc::DOMNode* getNode();
+ xercesc::DOMElement* getResultElement();
void setAttribute(const std::string&, const std::string&);
void setValueNode(const std::string&, const std::string&);
diff --git a/src/transformation_facade.cc b/src/transformation_facade.cc
index 9d248b8..4017cd0 100644
--- a/src/transformation_facade.cc
+++ b/src/transformation_facade.cc
@@ -2,6 +2,9 @@
#include <xalanc/XSLT/XSLTInputSource.hpp>
#include <xalanc/XalanTransformer/XalanCompiledStylesheet.hpp>
+#include <xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp>
+#include <xalanc/PlatformSupport/XalanStdOutputStream.hpp>
+#include <xalanc/XMLSupport/FormatterToXML.hpp>
#include "support/xerces_string_guard.h"
@@ -66,42 +69,45 @@ WarningCapacitor::warning_cache_ptr TransformationFacade::getCachedWarnings() {
return this->warning_capacitor_.discharge();
}
-void TransformationFacade::generate(std::basic_ostream<char>& targetStream) {
+void TransformationFacade::generate(
+ std::basic_ostream<char>& targetStream,
+ const xalan::XObjectPtr& parameter
+) {
StylesheetParameterGuard guard(this->transformer_);
+ guard.set("parameters", parameter);
- this->generate(targetStream, guard);
+ this->generate(targetStream);
}
-void TransformationFacade::generate(
- std::basic_ostream<char>& targetStream,
- const StylesheetParameterGuard::map& parameters
-) {
- StylesheetParameterGuard guard(this->transformer_, parameters);
+void TransformationFacade::generate(std::basic_ostream<char>& targetStream) {
+ StylesheetParameterGuard guard(this->transformer_);
+
+ xalan::XalanStdOutputStream outputStream(targetStream);
+ xalan::XalanOutputStreamPrintWriter outputWriter(outputStream);
- this->generate(targetStream, guard);
+ xalan::FormatterToXML formatter(outputWriter);
+ formatter.setDoIndent(true);
+
+ this->generate(formatter);
}
void TransformationFacade::generate(
- std::basic_ostream<char>& targetStream,
+ xalan::FormatterListener& formatter,
const xalan::XObjectPtr& parameter
) {
StylesheetParameterGuard guard(this->transformer_);
guard.set("parameters", parameter);
- this->generate(targetStream, guard);
+ this->generate(formatter);
}
-
-void TransformationFacade::generate(
- std::basic_ostream<char>& targetStream,
- StylesheetParameterGuard&
-) {
+void TransformationFacade::generate(xalan::FormatterListener& target) {
ErrorCapacitor errorCapacitor(&this->error_multiplexer_);
this->transformer_.transform(
*(this->input_),
this->transformation_,
- targetStream
+ target
);
errorCapacitor.discharge();
diff --git a/src/transformation_facade.h b/src/transformation_facade.h
index ca57de4..e4cbc10 100644
--- a/src/transformation_facade.h
+++ b/src/transformation_facade.h
@@ -39,9 +39,11 @@ class TransformationFacade {
);
void generate(std::basic_ostream<char>&);
- void generate(std::basic_ostream<char>&, const StylesheetParameterGuard::map&);
void generate(std::basic_ostream<char>&, const xalan::XObjectPtr&);
+ void generate(xalan::FormatterListener&);
+ void generate(xalan::FormatterListener&, const xalan::XObjectPtr&);
+
WarningCapacitor::warning_cache_ptr getCachedWarnings();
private:
@@ -52,11 +54,6 @@ class TransformationFacade {
ErrorMultiplexer error_multiplexer_;
WarningCapacitor warning_capacitor_;
- void generate(
- std::basic_ostream<char>&,
- StylesheetParameterGuard&
- );
-
};
template <typename... Arguments>
diff --git a/test/transform/transformation.xsl b/test/transform/transformation.xsl
index 3582527..686bbf5 100644
--- a/test/transform/transformation.xsl
+++ b/test/transform/transformation.xsl
@@ -49,7 +49,7 @@
<xsl:variable name="writerResult">
<xsl:call-template name="writer">
<xsl:with-param name="file" select="string($target)"/>
- <xsl:with-param name="content" select="xalan:nodeset($transformerResult)/transformation/text()"/>
+ <xsl:with-param name="content" select="xalan:nodeset($transformerResult)/transformation/*"/>
</xsl:call-template>
</xsl:variable>