The text() function now works.

This commit is contained in:
John Wiegley 2007-05-16 05:38:56 +00:00
parent 51ef4d7914
commit 1134fc7eff
2 changed files with 11 additions and 4 deletions

View file

@ -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)) { foreach (const value_t& value, xpath.find_all(xml_document, report)) {
if (value.is_xml_node()) { if (value.is_xml_node()) {
value.as_xml_node()->print(std::cout); value.as_xml_node()->print(std::cout);
std::cout << std::endl; } else {
std::cout << value;
} }
std::cout << std::endl;
} }
return 0; return 0;
} }

View file

@ -2077,7 +2077,8 @@ void xpath_t::path_t::walk_elements(NodeType& start,
break; break;
default: { 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()) { if (final.ptr->is_value()) {
value_t& result(final.ptr->as_value()); value_t& result(final.ptr->as_value());
@ -2100,17 +2101,21 @@ void xpath_t::path_t::walk_elements(NodeType& start,
walk_elements<NodeType>(*value.template as_xml_node<NodeType>(), walk_elements<NodeType>(*value.template as_xml_node<NodeType>(),
element, recurse, scope, func); element, recurse, scope, func);
} else { } else {
if (element->kind > op_t::TERMINALS) if (element->kind == op_t::O_FIND ||
element->kind == op_t::O_RFIND)
throw_(compile_error, throw_(compile_error,
"Non-final expression in XPath selection returns non-node"); "Non-final expression in XPath selection returns non-node");
func(value); func(value);
} }
} }
} }
else { else {
if (element->kind > op_t::TERMINALS) if (element->kind == op_t::O_FIND ||
element->kind == op_t::O_RFIND)
throw_(compile_error, throw_(compile_error,
"Non-final expression in XPath selection returns non-node"); "Non-final expression in XPath selection returns non-node");
func(result); func(result);
} }
} else { } else {