aboutsummaryrefslogtreecommitdiff
path: root/src/function/read_xml_file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/function/read_xml_file.cc')
-rw-r--r--src/function/read_xml_file.cc86
1 files changed, 0 insertions, 86 deletions
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
deleted file mode 100644
index e4d256d..0000000
--- a/src/function/read_xml_file.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "read_xml_file.h"
-
-#include <xercesc/dom/DOMDocument.hpp>
-#include <xercesc/dom/DOMImplementation.hpp>
-#include <xercesc/dom/DOMElement.hpp>
-#include <xercesc/parsers/XercesDOMParser.hpp>
-#include <xercesc/framework/LocalFileInputSource.hpp>
-
-#include "support/xerces_string_guard.h"
-#include "support/dom/result_node_facade.h"
-
-namespace {
-
-inline xercesc::DOMNode* importDocumentElement(
- const std::string& filePath,
- xercesc::DOMDocument* const domDocument
-) {
- const xercesc::LocalFileInputSource file(
- *InputXSLT::XercesStringGuard<XMLCh>(filePath.data())
- );
-
- xercesc::XercesDOMParser parser;
- parser.parse(file);
-
- return domDocument->importNode(
- parser.getDocument()->getDocumentElement(),
- true
- );
-}
-
-}
-
-namespace InputXSLT {
-
-xercesc::DOMDocument* FunctionReadXmlFile::constructDocument(
- const FilesystemContext& fsContext,
- std::string rawPath
-) {
- boost::filesystem::path filePath(fsContext.resolve(rawPath));
-
- if ( !(boost::filesystem::exists(filePath) &&
- boost::filesystem::is_regular_file(filePath)) ) {
- if ( auto resolvedPath = this->include_resolver_->resolve(rawPath) ) {
- filePath = *resolvedPath;
- }
- }
-
- xercesc::DOMDocument* const domDocument(
- xercesc::DOMImplementation::getImplementation()->createDocument(
- nullptr,
- *XercesStringGuard<XMLCh>("content"),
- nullptr
- )
- );
-
- xercesc::DOMNode* const rootNode(
- domDocument->getDocumentElement()
- );
-
- ResultNodeFacade result(domDocument, rootNode, "file");
- result.setAttribute("path", filePath.string());
-
- if ( boost::filesystem::is_regular_file(filePath) ) {
- try {
- result.setContent(
- importDocumentElement(filePath.string(), domDocument)
- );
-
- result.setAttribute("result", "success");
- }
- catch ( const xercesc::DOMException& exception ) {
- result.setAttribute("result", "error");
-
- result.setValueNode(
- "error",
- *XercesStringGuard<char>(exception.msg)
- );
- }
- } else {
- result.setAttribute("result", "error");
- }
-
- return domDocument;
-}
-
-}