X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=xml-tree-inc.hpp;h=bb705135a22a47cd89a9651ef650b7dce8c4a0dc;hb=a6ceb9a;hp=d5a921f3c9494d98783b0e337c8e96490008ea63;hpb=9b8afc78da8be3f210cf204b732d4c84ca5080d5;p=SXSI%2FXMLTree.git diff --git a/xml-tree-inc.hpp b/xml-tree-inc.hpp index d5a921f..bb70513 100644 --- a/xml-tree-inc.hpp +++ b/xml-tree-inc.hpp @@ -36,6 +36,20 @@ xml_tree::subtree_tags(xml_tree::node_t x, xml_tree::tag_t label) const }; } +inline uint32_t xml_tree::subtree_elements(xml_tree::node_t x, + xml_tree::tag_t *atts) const +{ + + int32_t size = bp_subtree_size(par, x) - 1; + if (size <= 0) return 0; + size -= subtree_tags(x, xml_tree::PCDATA_OPEN_TAG_ID); + if (size < 3) return (uint32_t) size; + for(; *atts != xml_tree::NIL_TAG_ID; atts++) + size -= subtree_tags(x, *atts); + return (uint32_t) size; + +} + inline bool xml_tree::is_leaf(xml_tree::node_t x) const { return !bp_inspect(this->par, x+1); @@ -206,7 +220,8 @@ inline SXSI::TextCollection *xml_tree::get_text_collection() const inline xml_tree::node_t xml_tree::parent_node(int32_t d) const { - return (xml_tree::node_t) text_positions->select1(d + 1); + xml_tree::node_t res = text_positions->select1(d+1); + return (xml_tree::node_t) res; } inline SXSI::TextCollection::document_result