--- a/bash-completion.sh Sun Oct 25 21:48:11 2020 +0100
+++ b/bash-completion.sh Sat Nov 28 23:51:54 2020 +0100
@@ -28,7 +28,7 @@
"boolean"
)
- XINCLUDE=(
+ BOOLEAN_VALUES=(
"true"
"false"
)
@@ -67,7 +67,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"))
+ elif [[ "$w1" == "--xinclude" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
elif [[ "$w1" == "--mode" ]]; then COMPREPLY=($(compgen -W "${MODE[*]}" -- "$w0"))
elif [[ "$w1" == "--raw-xml-nodelist-wrapper" ]]; then COMPREPLY=("'xml'")
elif [[ "$w2" == "--raw-xml-nodelist-wrapper" && "x$w0" == "x" ]]; then COMPREPLY=("''")
@@ -76,9 +76,14 @@
elif [[ "$w1" == "--raw-xml-attribute-wrapper" ]]; then COMPREPLY=("'attribute'")
elif [[ "$w2" == "--raw-xml-attribute-wrapper" && "x$w0" == "x" ]]; then COMPREPLY=("''")
elif [[ "$w3" == "--raw-xml-attribute-wrapper" && "x$w0" == "x" ]]; then COMPREPLY=("''")
+
+ elif [[ "$w1" == "--parser-option" ]]; then COMPREPLY=("''")
+ elif [[ "$w2" == "--parser-option" && "x$w0" == "x" ]]; then COMPREPLY=("''")
+
else
OPTIONS=(
"--namespace"
+ "--parser-option"
"--relation"
"--records"
"--name-is-xpath"
--- a/src/CLIParser.h Sun Oct 25 21:48:11 2020 +0100
+++ b/src/CLIParser.h Sat Nov 28 23:51:54 2020 +0100
@@ -63,6 +63,7 @@
public:
static const string_t OPTION_NAMESPACE;
+ static const string_t OPTION_PARSER_OPTION;
static const string_t OPTION_RELATION;
static const string_t OPTION_NAME_IS_XPATH;
static const string_t OPTION_RECORDS;
@@ -82,6 +83,8 @@
if (option == OPTION_NAMESPACE) {
c.namespaceMappings.push_back(readNext(arguments, i));
c.namespaceMappings.push_back(readNext(arguments, i));
+ } else if (option == OPTION_PARSER_OPTION) {
+ c.parserOptions.push_back({readNext(arguments, i), readNext(arguments, i)});
} else if (option == OPTION_XINCLUDE) {
c.xinclude = parseBoolean(readNext(arguments, i));
} else if (option == OPTION_RELATION) {
@@ -131,6 +134,7 @@
};
const string_t CLIParser::OPTION_NAMESPACE = L"--namespace";
+const string_t CLIParser::OPTION_PARSER_OPTION = L"--parser-option";
const string_t CLIParser::OPTION_RELATION = L"--relation";
const string_t CLIParser::OPTION_NAME_IS_XPATH = L"--name-is-xpath";
const string_t CLIParser::OPTION_RECORDS = L"--records";
--- a/src/Configuration.h Sun Oct 25 21:48:11 2020 +0100
+++ b/src/Configuration.h Sat Nov 28 23:51:54 2020 +0100
@@ -65,6 +65,15 @@
};
+class ParserOptionRecipe {
+public:
+ relpipe::writer::string_t uri;
+ relpipe::writer::string_t value;
+
+ ParserOptionRecipe(relpipe::writer::string_t uri, relpipe::writer::string_t value) : uri(uri), value(value) {
+ }
+};
+
class RelationConfiguration {
public:
@@ -86,6 +95,7 @@
public:
std::vector<RelationConfiguration> relationConfigurations;
std::vector<relpipe::writer::string_t> namespaceMappings;
+ std::vector<ParserOptionRecipe> parserOptions;
bool xinclude = false;
virtual ~Configuration() {
--- a/src/XMLDocumentConstructor.h Sun Oct 25 21:48:11 2020 +0100
+++ b/src/XMLDocumentConstructor.h Sat Nov 28 23:51:54 2020 +0100
@@ -30,6 +30,9 @@
XMLDocumentConstructor(std::istream* input, xmlpp::DomParser* parser) : input(input), parser(parser) {
}
+
+ void setOption(const std::string& uri, const std::string& value) {
+ }
void process() {
parser->parse_stream(*input);
--- a/src/XMLTableCommand.h Sun Oct 25 21:48:11 2020 +0100
+++ b/src/XMLTableCommand.h Sat Nov 28 23:51:54 2020 +0100
@@ -88,6 +88,7 @@
xmlpp::DomParser parser;
XMLDocumentConstructor documentConstructor(&input, &parser);
+ for (ParserOptionRecipe o : configuration.parserOptions) documentConstructor.setOption(convertor.to_bytes(o.uri), convertor.to_bytes(o.value));
documentConstructor.process();
if (configuration.xinclude) parser.get_document()->process_xinclude(true);
xmlpp::Element* root = parser.get_document()->get_root_node();