src/XMLTableCommand.h
branchv_0
changeset 44 8f424bdd7065
parent 25 0e8a58946c48
equal deleted inserted replaced
43:6b194b178946 44:8f424bdd7065
    41 class XMLCommand {
    41 class XMLCommand {
    42 private:
    42 private:
    43 	std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings.
    43 	std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings.
    44 
    44 
    45 	string_t formatRawXML(string_t rawXML) {
    45 	string_t formatRawXML(string_t rawXML) {
    46 		std::wregex pattern(L"^<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>\n|\n$");
    46 		std::wregex pattern(L"^(<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>\\s*)+|\n$");
       
    47 		// libxml sometimes returns doubled XML declaration (probably a bug), see:
       
    48 		// --relation ini --records '/' --attribute 'xml' string '.' --mode raw-xml # (but not for --records '//*')
       
    49 		// so we remove all of them and also trailing line ends (if any).
    47 		return std::regex_replace(rawXML, pattern, L"");
    50 		return std::regex_replace(rawXML, pattern, L"");
    48 	}
    51 	}
    49 
    52 
    50 	void importNode(xmlpp::Node* parent, xmlpp::Node* child, AttributeRecipe attributeRecipe) {
    53 	void importNode(xmlpp::Node* parent, xmlpp::Node* child, AttributeRecipe attributeRecipe) {
    51 		if (dynamic_cast<xmlpp::AttributeNode*> (child)) parent->add_child_with_new_ns(
    54 		if (dynamic_cast<xmlpp::AttributeNode*> (child)) parent->add_child_with_new_ns(