aboutsummaryrefslogtreecommitdiff
path: root/src/function/read_xml_file.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-24 13:59:42 +0200
committerAdrian Kummerländer2014-05-24 13:59:42 +0200
commit085935ddd577b0c65b4330318b5ba20492d93126 (patch)
treeb508590d23a3fe7f3a6813313af2abe17fecdf79 /src/function/read_xml_file.cc
parentafc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7 (diff)
downloadInputXSLT-085935ddd577b0c65b4330318b5ba20492d93126.tar
InputXSLT-085935ddd577b0c65b4330318b5ba20492d93126.tar.gz
InputXSLT-085935ddd577b0c65b4330318b5ba20492d93126.tar.bz2
InputXSLT-085935ddd577b0c65b4330318b5ba20492d93126.tar.lz
InputXSLT-085935ddd577b0c65b4330318b5ba20492d93126.tar.xz
InputXSLT-085935ddd577b0c65b4330318b5ba20492d93126.tar.zst
InputXSLT-085935ddd577b0c65b4330318b5ba20492d93126.zip
Implemented ResultNodeFacade as a DOM node construction helper
* wraps result node construction and appends it to root node on destruction * offers a simpler interface for common node construction patterns * simplifies result node construction in all external function implementations ** most noticeable in FunctionReadDirectory * expanded FunctionReadDirectory result nodes by name, extension, and full-path nodes
Diffstat (limited to 'src/function/read_xml_file.cc')
-rw-r--r--src/function/read_xml_file.cc22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
index 4eb44e5..6d0fd04 100644
--- a/src/function/read_xml_file.cc
+++ b/src/function/read_xml_file.cc
@@ -5,12 +5,12 @@
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMElement.hpp>
-#include <xercesc/dom/DOMText.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include "boost/filesystem/fstream.hpp"
#include "support/xerces_string_guard.h"
+#include "support/dom/result_node_facade.h"
namespace {
@@ -61,27 +61,15 @@ xercesc::DOMDocument* FunctionReadXmlFile::constructDocument(
);
if ( boost::filesystem::is_regular_file(filePath) ) {
- xercesc::DOMElement* const resultNode(
- domDocument->createElement(*XercesStringGuard<XMLCh>("result"))
- );
+ ResultNodeFacade result(domDocument, rootNode, "result");
- resultNode->setAttribute(
- *XercesStringGuard<XMLCh>("name"),
- *XercesStringGuard<XMLCh>(filePath.filename().string())
- );
+ result.setAttribute("name", filePath.filename().string());
- xercesc::DOMNode* const resultTreeNode(
+ result.setContent(
importDocumentElement(filePath, domDocument)
);
-
- resultNode->appendChild(resultTreeNode);
- rootNode->appendChild(resultNode);
} else {
- xercesc::DOMElement* const resultNode(
- domDocument->createElement(*XercesStringGuard<XMLCh>("error"))
- );
-
- rootNode->appendChild(resultNode);
+ ResultNodeFacade result(domDocument, rootNode, "error");
}
return domDocument;