From 1134fc7eff7094700abf16c2e532d7c3c40ae68d Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 16 May 2007 05:38:56 +0000 Subject: The text() function now works. --- src/main.cc | 4 +++- src/xpath.cc | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.cc b/src/main.cc index fbda5c3d..5f7882bf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -271,8 +271,10 @@ static int read_and_report(ledger::report_t * report, int argc, char * argv[], foreach (const value_t& value, xpath.find_all(xml_document, report)) { if (value.is_xml_node()) { value.as_xml_node()->print(std::cout); - std::cout << std::endl; + } else { + std::cout << value; } + std::cout << std::endl; } return 0; } diff --git a/src/xpath.cc b/src/xpath.cc index d56aa2f1..8594a283 100644 --- a/src/xpath.cc +++ b/src/xpath.cc @@ -2077,7 +2077,8 @@ void xpath_t::path_t::walk_elements(NodeType& start, break; default: { - xpath_t final(name->compile(start, scope, true)); + function_scope_t xpath_fscope(start, 0, 1, scope); + xpath_t final(name->compile(start, &xpath_fscope, true)); if (final.ptr->is_value()) { value_t& result(final.ptr->as_value()); @@ -2100,17 +2101,21 @@ void xpath_t::path_t::walk_elements(NodeType& start, walk_elements(*value.template as_xml_node(), element, recurse, scope, func); } else { - if (element->kind > op_t::TERMINALS) + if (element->kind == op_t::O_FIND || + element->kind == op_t::O_RFIND) throw_(compile_error, "Non-final expression in XPath selection returns non-node"); + func(value); } } } else { - if (element->kind > op_t::TERMINALS) + if (element->kind == op_t::O_FIND || + element->kind == op_t::O_RFIND) throw_(compile_error, "Non-final expression in XPath selection returns non-node"); + func(result); } } else { -- cgit v1.2.3