--- a/bash-completion.sh Wed Oct 30 16:47:42 2019 +0100
+++ b/bash-completion.sh Thu Jan 02 23:31:44 2020 +0100
@@ -28,6 +28,11 @@
"boolean"
)
+ XINCLUDE=(
+ "true"
+ "false"
+ )
+
# FIXME: user must type " and then press TAB otherwise the completion is broken due to the : colon
#
# can be fixed by global modification of environment variable:
@@ -54,6 +59,7 @@
elif [[ "$w3" == "--attribute" && "x$w0" == "x" ]]; then COMPREPLY=("''")
elif [[ "$w1" == "--namespace" && "x$w0" == "x" ]]; then COMPREPLY=("''")
elif [[ "$w2" == "--namespace" ]]; then COMPREPLY=($(compgen -W "${XMLNS[*]}" -- "$w0"))
+ elif [[ "$w1" == "--xinclude" ]]; then COMPREPLY=($(compgen -W "${XINCLUDE[*]}" -- "$w0"))
else
OPTIONS=(
"--namespace"
@@ -61,6 +67,7 @@
"--records"
"--name-is-xpath"
"--attribute"
+ "--xinclude"
)
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
fi
--- a/src/CLIParser.h Wed Oct 30 16:47:42 2019 +0100
+++ b/src/CLIParser.h Thu Jan 02 23:31:44 2020 +0100
@@ -36,6 +36,15 @@
else throw relpipe::cli::RelpipeCLIException(L"Missing CLI argument" + (i > 0 ? (L" after " + arguments[i - 1]) : L""), relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
}
+ /**
+ * TODO: use a common method
+ */
+ bool parseBoolean(const string_t& value) {
+ if (value == L"true") return true;
+ else if (value == L"false") return false;
+ else throw relpipe::cli::RelpipeCLIException(L"Unable to parse boolean value: " + value + L" (expecting true or false)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
+ }
+
void addRelation(Configuration& c, RelationConfiguration& currentRelation) {
if (currentRelation.relation.size()) {
c.relationConfigurations.push_back(currentRelation);
@@ -58,6 +67,7 @@
static const string_t OPTION_NAME_IS_XPATH;
static const string_t OPTION_RECORDS;
static const string_t OPTION_ATTRIBUTE;
+ static const string_t OPTION_XINCLUDE;
Configuration parse(const std::vector<string_t>& arguments) {
Configuration c;
@@ -69,6 +79,8 @@
if (option == OPTION_NAMESPACE) {
c.namespaceMappings.push_back(readNext(arguments, i));
c.namespaceMappings.push_back(readNext(arguments, i));
+ } else if (option == OPTION_XINCLUDE) {
+ c.xinclude = parseBoolean(readNext(arguments, i));
} else if (option == OPTION_RELATION) {
addRelation(c, currentRelation); // previous relation
currentRelation.relation = readNext(arguments, i);
@@ -98,6 +110,7 @@
const string_t CLIParser::OPTION_NAME_IS_XPATH = L"--name-is-xpath";
const string_t CLIParser::OPTION_RECORDS = L"--records";
const string_t CLIParser::OPTION_ATTRIBUTE = L"--attribute";
+const string_t CLIParser::OPTION_XINCLUDE = L"--xinclude";
}
}
--- a/src/Configuration.h Wed Oct 30 16:47:42 2019 +0100
+++ b/src/Configuration.h Thu Jan 02 23:31:44 2020 +0100
@@ -53,6 +53,7 @@
public:
std::vector<RelationConfiguration> relationConfigurations;
std::vector<relpipe::writer::string_t> namespaceMappings;
+ bool xinclude = false;
virtual ~Configuration() {
}
--- a/src/XMLTableCommand.h Wed Oct 30 16:47:42 2019 +0100
+++ b/src/XMLTableCommand.h Thu Jan 02 23:31:44 2020 +0100
@@ -46,6 +46,7 @@
xmlpp::DomParser parser;
parser.parse_stream(input);
+ if (configuration.xinclude) parser.get_document()->process_xinclude(true);
xmlpp::Element* root = parser.get_document()->get_root_node();
xmlpp::Node::PrefixNsMap ns;