diff options
author | John Wiegley <johnw@newartisans.com> | 2007-05-19 03:11:00 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:39:05 -0400 |
commit | 5a72d17d026aa6a1bb0cd32f413963ef9f24ab64 (patch) | |
tree | 5aec31b69f0dcba9ff07f8a8d4abad60a00c0655 /src/xpath.cc | |
parent | cdea8aa18c8bbd018849fb890dba87f7ef1a1140 (diff) | |
download | fork-ledger-5a72d17d026aa6a1bb0cd32f413963ef9f24ab64.tar.gz fork-ledger-5a72d17d026aa6a1bb0cd32f413963ef9f24ab64.tar.bz2 fork-ledger-5a72d17d026aa6a1bb0cd32f413963ef9f24ab64.zip |
Node compilation is beginning to work.
Diffstat (limited to 'src/xpath.cc')
-rw-r--r-- | src/xpath.cc | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/xpath.cc b/src/xpath.cc index 46da665d..98988c64 100644 --- a/src/xpath.cc +++ b/src/xpath.cc @@ -433,23 +433,35 @@ namespace { value_t xpath_fn_last(xpath_t::call_scope_t& scope) { xpath_t::context_scope_t& context(CONTEXT_SCOPE(scope)); - return context.size(); } value_t xpath_fn_position(xpath_t::call_scope_t& scope) { xpath_t::context_scope_t& context(CONTEXT_SCOPE(scope)); - return context.index() + 1; } value_t xpath_fn_text(xpath_t::call_scope_t& scope) { xpath_t::context_scope_t& context(CONTEXT_SCOPE(scope)); - return value_t(context.xml_node().to_value().to_string(), true); } + + value_t xpath_fn_type(xpath_t::call_scope_t& scope) + { + if (scope.size() == 0) { + xpath_t::context_scope_t& context(CONTEXT_SCOPE(scope)); + return string_value(context.value().label()); + } + else if (scope.size() == 1) { + return string_value(scope[0].label()); + } + else { + assert(false); + return string_value("INVALID"); + } + } } xpath_t::ptr_op_t @@ -469,6 +481,8 @@ xpath_t::symbol_scope_t::lookup(const string& name) case 't': if (name == "text") return WRAP_FUNCTOR(bind(xpath_fn_text, _1)); + else if (name == "type") + return WRAP_FUNCTOR(bind(xpath_fn_type, _1)); break; } @@ -1194,10 +1208,10 @@ value_t xpath_t::op_t::calc(scope_t& scope) case ATTR_ID: case ATTR_NAME: - if (optional<const string&> value = - kind == ATTR_ID ? current_xml_node(scope).get_attr(as_long()) : + if (optional<value_t> value = + kind == ATTR_ID ? current_xml_node(scope).get_attr(as_name()) : current_xml_node(scope).get_attr(as_string())) - return value_t(*value, true); + return *value; else throw_(calc_error, "Attribute '" << (kind == ATTR_ID ? |