aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/function/read_directory.cc34
-rw-r--r--src/function/read_file.cc29
-rw-r--r--src/function/read_xml_file.cc35
3 files changed, 21 insertions, 77 deletions
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index b0ae13f..686767d 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -37,15 +37,11 @@ xalan::XObjectPtr FunctionReadDirectory::execute(
);
if ( boost::filesystem::is_directory(directoryPath) ) {
- xercesc::DOMElement* const contentNode(
- domDocument->createElement(*XercesStringGuard("content"))
- );
-
this->fs_context_.iterate(
argument->str(),
- [&domDocument, &contentNode](const boost::filesystem::path& p) {
+ [&domDocument, &rootNode](const boost::filesystem::path& p) {
xercesc::DOMElement* const itemNode(
- domDocument->createElement(*XercesStringGuard("item"))
+ domDocument->createElement(*XercesStringGuard("result"))
);
switch ( boost::filesystem::status(p).type() ) {
@@ -77,35 +73,13 @@ xalan::XObjectPtr FunctionReadDirectory::execute(
);
itemNode->appendChild(textNode);
- contentNode->appendChild(itemNode);
+ rootNode->appendChild(itemNode);
});
-
- xercesc::DOMElement* const resultNode(
- domDocument->createElement(*XercesStringGuard("status"))
- );
-
- xercesc::DOMText* const resultTextNode(
- domDocument->createTextNode(
- *XercesStringGuard("successful")
- )
- );
-
- resultNode->appendChild(resultTextNode);
-
- rootNode->appendChild(contentNode);
- rootNode->appendChild(resultNode);
} else {
xercesc::DOMElement* const resultNode(
- domDocument->createElement(*XercesStringGuard("status"))
- );
-
- xercesc::DOMText* const resultTextNode(
- domDocument->createTextNode(
- *XercesStringGuard("error")
- )
+ domDocument->createElement(*XercesStringGuard("error"))
);
- resultNode->appendChild(resultTextNode);
rootNode->appendChild(resultNode);
}
}
diff --git a/src/function/read_file.cc b/src/function/read_file.cc
index cfbec59..83456c6 100644
--- a/src/function/read_file.cc
+++ b/src/function/read_file.cc
@@ -48,43 +48,28 @@ xalan::XObjectPtr FunctionReadFile::execute(
(std::istreambuf_iterator<char>())
);
- xercesc::DOMElement* const contentNode(
- domDocument->createElement(*XercesStringGuard("content"))
- );
-
- xercesc::DOMText* const contentTextNode(
- domDocument->createTextNode(
- *XercesStringGuard(fileContent)
- )
+ xercesc::DOMElement* const resultNode(
+ domDocument->createElement(*XercesStringGuard("result"))
);
- xercesc::DOMElement* const resultNode(
- domDocument->createElement(*XercesStringGuard("status"))
+ resultNode->setAttribute(
+ *XercesStringGuard("name"),
+ *XercesStringGuard(filePath.filename().string())
);
xercesc::DOMText* const resultTextNode(
domDocument->createTextNode(
- *XercesStringGuard("successful")
+ *XercesStringGuard(fileContent)
)
);
- contentNode->appendChild(contentTextNode);
resultNode->appendChild(resultTextNode);
-
- rootNode->appendChild(contentNode);
rootNode->appendChild(resultNode);
} else {
xercesc::DOMElement* const resultNode(
- domDocument->createElement(*XercesStringGuard("status"))
+ domDocument->createElement(*XercesStringGuard("error"))
);
- xercesc::DOMText* const resultTextNode(
- domDocument->createTextNode(
- *XercesStringGuard("error")
- )
- );
-
- resultNode->appendChild(resultTextNode);
rootNode->appendChild(resultNode);
}
}
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
index 52f7735..7b54732 100644
--- a/src/function/read_xml_file.cc
+++ b/src/function/read_xml_file.cc
@@ -40,48 +40,33 @@ xalan::XObjectPtr FunctionReadXmlFile::execute(
);
if ( boost::filesystem::is_regular_file(filePath) ) {
- xercesc::DOMElement* const contentNode(
- domDocument->createElement(*XercesStringGuard("content"))
+ xercesc::DOMElement* const resultNode(
+ domDocument->createElement(*XercesStringGuard("result"))
+ );
+
+ resultNode->setAttribute(
+ *XercesStringGuard("name"),
+ *XercesStringGuard(filePath.filename().string())
);
xercesc::XercesDOMParser parser;
boost::filesystem::ifstream file(filePath);
parser.parse(xalan::XSLTInputSource(file));
- xercesc::DOMNode* const contentTreeNode(
+ xercesc::DOMNode* const resultTreeNode(
domDocument->importNode(
parser.getDocument()->getDocumentElement(),
true
)
);
- xercesc::DOMElement* const resultNode(
- domDocument->createElement(*XercesStringGuard("status"))
- );
-
- xercesc::DOMText* const resultTextNode(
- domDocument->createTextNode(
- *XercesStringGuard("successful")
- )
- );
-
- contentNode->appendChild(contentTreeNode);
- resultNode->appendChild(resultTextNode);
-
- rootNode->appendChild(contentNode);
+ resultNode->appendChild(resultTreeNode);
rootNode->appendChild(resultNode);
} else {
xercesc::DOMElement* const resultNode(
- domDocument->createElement(*XercesStringGuard("status"))
- );
-
- xercesc::DOMText* const resultTextNode(
- domDocument->createTextNode(
- *XercesStringGuard("error")
- )
+ domDocument->createElement(*XercesStringGuard("error"))
);
- resultNode->appendChild(resultTextNode);
rootNode->appendChild(resultNode);
}
}