# HG changeset patch # User František Kučera # Date 1606603921 -3600 # Node ID 0e8a58946c48c9f9d6a106dce2d771437cb44319 # Parent ee72fccc52674ffc090fed4409934617cbaf2e2e add --parser-option diff -r ee72fccc5267 -r 0e8a58946c48 bash-completion.sh --- a/bash-completion.sh Wed Nov 25 17:28:17 2020 +0100 +++ b/bash-completion.sh Sat Nov 28 23:52:01 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" diff -r ee72fccc5267 -r 0e8a58946c48 src/CLIParser.h --- a/src/CLIParser.h Wed Nov 25 17:28:17 2020 +0100 +++ b/src/CLIParser.h Sat Nov 28 23:52:01 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"; diff -r ee72fccc5267 -r 0e8a58946c48 src/Configuration.h --- a/src/Configuration.h Wed Nov 25 17:28:17 2020 +0100 +++ b/src/Configuration.h Sat Nov 28 23:52:01 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 relationConfigurations; std::vector namespaceMappings; + std::vector parserOptions; bool xinclude = false; virtual ~Configuration() { @@ -94,4 +104,4 @@ } } -} \ No newline at end of file +} diff -r ee72fccc5267 -r 0e8a58946c48 src/XMLDocumentConstructor.h --- a/src/XMLDocumentConstructor.h Wed Nov 25 17:28:17 2020 +0100 +++ b/src/XMLDocumentConstructor.h Sat Nov 28 23:52:01 2020 +0100 @@ -77,6 +77,9 @@ virtual ~XMLDocumentConstructor() { yaml_parser_delete(&yamlParser); } + + void setOption(const std::string& uri, const std::string& value) { + } void process() { current = parser->get_document()->create_root_node("yaml"); diff -r ee72fccc5267 -r 0e8a58946c48 src/XMLTableCommand.h --- a/src/XMLTableCommand.h Wed Nov 25 17:28:17 2020 +0100 +++ b/src/XMLTableCommand.h Sat Nov 28 23:52:01 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();