diff options
author | John Wiegley <johnw@newartisans.com> | 2007-05-15 05:44:06 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:51 -0400 |
commit | d89f6e1c447fc5e7fcd0d6e5a236298323f9596e (patch) | |
tree | c044f2774a73c17401234a7c50254f1bb29ddc66 /src/main.cc | |
parent | 7747a8f93bbc582a183fd4c7b8d5f8fd492b8608 (diff) | |
download | fork-ledger-d89f6e1c447fc5e7fcd0d6e5a236298323f9596e.tar.gz fork-ledger-d89f6e1c447fc5e7fcd0d6e5a236298323f9596e.tar.bz2 fork-ledger-d89f6e1c447fc5e7fcd0d6e5a236298323f9596e.zip |
The XPath visitor class is now working
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/main.cc b/src/main.cc index 8aacfcda..13b02290 100644 --- a/src/main.cc +++ b/src/main.cc @@ -46,10 +46,6 @@ #include <fdstream.hpp> #endif -void print_node(ledger::xml::node_t& node) { - node.print(std::cout); -} - static int read_and_report(ledger::report_t * report, int argc, char * argv[], char * envp[]) { @@ -269,25 +265,15 @@ static int read_and_report(ledger::report_t * report, int argc, char * argv[], } else if (verb == "xpath") { std::cout << "XPath parsed:" << std::endl; + xml::xpath_t xpath(*arg); xpath.print(*out, xml_document); *out << std::endl; -#if 1 - try { - xml::xpath_t::path_t path_selection(xpath); - path_selection.visit(xml_document, report, bind(print_node, _1)); - } - catch (...) { - throw; + foreach (xml::node_t * node, xpath.find_all(xml_document, report)) { + node->print(std::cout); + std::cout << std::endl; } -#else - value_t nodelist; - xpath.calc(nodelist, xml_document, report); - - foreach (const value_t& node, nodelist.as_sequence()) - node.as_xml_node()->print(*out); -#endif return 0; } |