0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-27 13:33:17 +08:00

Removed document order optimization (it helps on a tiny percentage of queries), XPath tests now compute their own order

git-svn-id: http://pugixml.googlecode.com/svn/trunk@400 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine 2010-05-09 20:37:49 +00:00
parent e96af87b5d
commit 5ff56a6d68
12 changed files with 74 additions and 272 deletions

View File

@ -262,7 +262,7 @@ namespace pugi
struct xml_attribute_struct
{
/// Default ctor
xml_attribute_struct(): document_order(0), name_allocated(false), value_allocated(false), name(0), value(0), prev_attribute(0), next_attribute(0)
xml_attribute_struct(): padding(0), name_allocated(false), value_allocated(false), name(0), value(0), prev_attribute(0), next_attribute(0)
{
}
@ -281,7 +281,7 @@ namespace pugi
}
}
unsigned int document_order : 30; ///< Document order value
unsigned int padding : 30;
unsigned int name_allocated : 1;
unsigned int value_allocated : 1;
@ -297,7 +297,7 @@ namespace pugi
{
/// Default ctor
/// \param type - node type
xml_node_struct(xml_node_type type = node_element): name_allocated(false), value_allocated(false), document_order(0), type(type), parent(0), name(0), value(0), first_child(0), last_child(0), prev_sibling(0), next_sibling(0), first_attribute(0), last_attribute(0)
xml_node_struct(xml_node_type type = node_element): name_allocated(false), value_allocated(false), padding(0), type(type), parent(0), name(0), value(0), first_child(0), last_child(0), prev_sibling(0), next_sibling(0), first_attribute(0), last_attribute(0)
{
}
@ -357,7 +357,7 @@ namespace pugi
unsigned int name_allocated : 1;
unsigned int value_allocated : 1;
unsigned int document_order : 27; ///< Document order value
unsigned int padding : 27;
unsigned int type : 3; ///< Node type; see xml_node_type.
xml_node_struct* parent; ///< Pointer to parent
@ -2890,7 +2890,7 @@ namespace pugi
unsigned int xml_attribute::document_order() const
{
return _attr ? _attr->document_order : 0;
return 0;
}
xml_attribute& xml_attribute::operator=(const char_t* rhs)
@ -3683,35 +3683,7 @@ namespace pugi
unsigned int xml_node::document_order() const
{
return _root ? _root->document_order : 0;
}
void xml_node::precompute_document_order_impl()
{
if (type() != node_document) return;
unsigned int current = 1;
xml_node cur = *this;
for (;;)
{
cur._root->document_order = current++;
for (xml_attribute a = cur.first_attribute(); a; a = a.next_attribute())
a._attr->document_order = current++;
if (cur.first_child())
cur = cur.first_child();
else if (cur.next_sibling())
cur = cur.next_sibling();
else
{
while (cur && !cur.next_sibling()) cur = cur.parent();
cur = cur.next_sibling();
if (!cur) break;
}
}
return 0;
}
void xml_node::print(xml_writer& writer, const char_t* indent, unsigned int flags, encoding_t encoding, unsigned int depth) const
@ -4154,7 +4126,6 @@ namespace pugi
void xml_document::precompute_document_order()
{
precompute_document_order_impl();
}
#ifndef PUGIXML_NO_STL

View File

@ -644,7 +644,7 @@ namespace pugi
bool as_bool() const;
/// \internal Document order or 0 if not set
unsigned int document_order() const;
PUGIXML_DEPRECATED unsigned int document_order() const;
public:
/**
@ -787,9 +787,6 @@ namespace pugi
/// \internal Initializing ctor
explicit xml_node(xml_node_struct* p);
/// \internal Precompute document order (valid only for document node)
void precompute_document_order_impl();
/// \internal Get allocator
xml_allocator& get_allocator() const;
@ -1457,7 +1454,7 @@ namespace pugi
#endif
/// \internal Document order or 0 if not set
unsigned int document_order() const;
PUGIXML_DEPRECATED unsigned int document_order() const;
/**
* Print subtree to writer
@ -2019,7 +2016,7 @@ namespace pugi
* Compute document order for the whole tree
* Sometimes this makes evaluation of XPath queries faster.
*/
void precompute_document_order();
PUGIXML_DEPRECATED void precompute_document_order();
};
#ifndef PUGIXML_NO_XPATH

View File

@ -213,12 +213,6 @@ namespace
{
bool operator()(const xpath_node& lhs, const xpath_node& rhs) const
{
unsigned int lo = lhs.attribute() ? lhs.attribute().document_order() : lhs.node().document_order();
unsigned int ro = rhs.attribute() ? rhs.attribute().document_order() : rhs.node().document_order();
if (lo != 0 && ro != 0)
return lo < ro;
xml_node ln = lhs.node(), rn = rhs.node();
if (lhs.attribute() && rhs.attribute())

View File

@ -1,3 +1,5 @@
#define _SCL_SECURE_NO_WARNINGS
#include "test.hpp"
#include "writer_string.hpp"
@ -5,6 +7,38 @@
#include <math.h>
#include <float.h>
#include <algorithm>
#include <vector>
#ifndef PUGIXML_NO_XPATH
static void build_document_order(std::vector<pugi::xpath_node>& result, pugi::xml_node root)
{
result.push_back(pugi::xpath_node());
pugi::xml_node cur = root;
for (;;)
{
result.push_back(cur);
for (pugi::xml_attribute a = cur.first_attribute(); a; a = a.next_attribute())
result.push_back(pugi::xpath_node(a, cur));
if (cur.first_child())
cur = cur.first_child();
else if (cur.next_sibling())
cur = cur.next_sibling();
else
{
while (cur && !cur.next_sibling()) cur = cur.parent();
cur = cur.next_sibling();
if (!cur) break;
}
}
}
#endif
bool test_string_equal(const pugi::char_t* lhs, const pugi::char_t* rhs)
{
return (!lhs || !rhs) ? lhs == rhs : pugi::impl::strequal(lhs, rhs);
@ -82,21 +116,33 @@ void xpath_node_set_tester::check(bool condition)
}
}
xpath_node_set_tester::xpath_node_set_tester(const pugi::xml_node& node, const pugi::char_t* query, const char* message): last(0), message(message)
{
pugi::xpath_query q(query);
result = q.evaluate_node_set(node);
}
xpath_node_set_tester::xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message): last(0), message(message)
{
result = set;
if (result.empty())
{
document_order = 0;
document_size = 0;
}
else
{
std::vector<pugi::xpath_node> order;
build_document_order(order, (result[0].attribute() ? result[0].parent() : result[0].node()).root());
document_order = new pugi::xpath_node[order.size()];
std::copy(order.begin(), order.end(), document_order);
document_size = order.size();
}
}
xpath_node_set_tester::~xpath_node_set_tester()
{
// check that we processed everything
check(last == result.size());
delete[] document_order;
}
xpath_node_set_tester& xpath_node_set_tester::operator%(unsigned int expected)
@ -105,10 +151,8 @@ xpath_node_set_tester& xpath_node_set_tester::operator%(unsigned int expected)
check(last < result.size());
// check document order
pugi::xpath_node node = result.begin()[last];
unsigned int order = node.attribute() ? node.attribute().document_order() : node.node().document_order();
check(order == expected);
check(expected < document_size);
check(result.begin()[last] == document_order[expected]);
// continue to the next element
last++;

View File

@ -45,13 +45,15 @@ bool test_xpath_fail_compile(const pugi::char_t* query);
struct xpath_node_set_tester
{
pugi::xpath_node* document_order;
size_t document_size;
pugi::xpath_node_set result;
unsigned int last;
const char* message;
void check(bool condition);
xpath_node_set_tester(const pugi::xml_node& node, const pugi::char_t* query, const char* message);
xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message);
~xpath_node_set_tester();
@ -123,7 +125,7 @@ struct dummy_fixture {};
#define CHECK_XPATH_NUMBER(node, query, expected) CHECK_TEXT(test_xpath_number(node, query, expected), STRINGIZE(query) " does not evaluate to " STRINGIZE(expected) " in context " STRINGIZE(node))
#define CHECK_XPATH_NUMBER_NAN(node, query) CHECK_TEXT(test_xpath_number_nan(node, query), STRINGIZE(query) " does not evaluate to NaN in context " STRINGIZE(node))
#define CHECK_XPATH_FAIL(query) CHECK_TEXT(test_xpath_fail_compile(query), STRINGIZE(query) " should not compile")
#define CHECK_XPATH_NODESET(node, query) xpath_node_set_tester(node, query, CHECK_JOIN2(STRINGIZE(query) " does not evaluate to expected set in context " STRINGIZE(node), " at "__FILE__ ":", __LINE__))
#define CHECK_XPATH_NODESET(node, query) xpath_node_set_tester(node.select_nodes(query), CHECK_JOIN2(STRINGIZE(query) " does not evaluate to expected set in context " STRINGIZE(node), " at "__FILE__ ":", __LINE__))
#endif
#define STR(text) PUGIXML_TEXT(text)

View File

@ -8,24 +8,6 @@
#include <string>
TEST_XML(xpath_document_order, "<node><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2></node>")
{
CHECK(xml_node().document_order() == 0);
CHECK(doc.child(STR("node")).document_order() == 0);
CHECK(doc.document_order() == 0);
doc.precompute_document_order();
CHECK(doc.document_order() == 1);
CHECK(doc.child(STR("node")).document_order() == 2);
CHECK(doc.child(STR("node")).child(STR("child1")).document_order() == 3);
CHECK(doc.child(STR("node")).child(STR("child1")).attribute(STR("attr1")).document_order() == 4);
CHECK(doc.child(STR("node")).child(STR("child1")).attribute(STR("attr2")).document_order() == 5);
CHECK(doc.child(STR("node")).child(STR("child2")).document_order() == 6);
CHECK(doc.child(STR("node")).child(STR("child2")).attribute(STR("attr1")).document_order() == 7);
CHECK(doc.child(STR("node")).child(STR("child2")).first_child().document_order() == 8);
}
TEST(xpath_allocator_many_pages)
{
pugi::string_t query = STR("0");
@ -55,8 +37,6 @@ TEST_XML(xpath_sort_complex, "<node><child1 attr1='value1' attr2='value2'/><chil
ns.sort(true);
xpath_node_set reverse_sorted = ns;
doc.precompute_document_order();
xpath_node_set_tester(sorted, "sorted order failed") % 2 % 3 % 4 % 5 % 6 % 7 % 8;
xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 8 % 7 % 6 % 5 % 4 % 3 % 2;
}
@ -71,8 +51,6 @@ TEST_XML(xpath_sort_children, "<node><child><subchild id='1'/></child><child><su
ns.sort(true);
xpath_node_set reverse_sorted = ns;
doc.precompute_document_order();
xpath_node_set_tester(sorted, "sorted order failed") % 4 % 7;
xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 7 % 4;
}
@ -95,8 +73,6 @@ TEST_XML(xpath_sort_attributes, "<node/>")
ns.sort(false);
xpath_node_set sorted = ns;
doc.precompute_document_order();
xpath_node_set_tester(sorted, "sorted order failed") % 3 % 4 % 5;
xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 5 % 4 % 3;
}

View File

@ -8,28 +8,24 @@
TEST_XML(xpath_api_select_nodes, "<node><head/><foo/><foo/><tail/></node>")
{
doc.precompute_document_order();
xpath_node_set ns1 = doc.select_nodes(STR("node/foo"));
xpath_query q(STR("node/foo"));
xpath_node_set ns2 = doc.select_nodes(q);
CHECK(ns1.size() == 2 && ns1[0].node().document_order() == 4 && ns1[1].node().document_order() == 5);
CHECK(ns2.size() == 2 && ns2[0].node().document_order() == 4 && ns2[1].node().document_order() == 5);
xpath_node_set_tester(ns1, "ns1") % 4 % 5;
xpath_node_set_tester(ns2, "ns2") % 4 % 5;
}
TEST_XML(xpath_api_select_single_node, "<node><head/><foo/><foo/><tail/></node>")
TEST_XML(xpath_api_select_single_node, "<node><head/><foo id='1'/><foo/><tail/></node>")
{
doc.precompute_document_order();
xpath_node n1 = doc.select_single_node(STR("node/foo"));
xpath_query q(STR("node/foo"));
xpath_node n2 = doc.select_single_node(q);
CHECK(n1.node().document_order() == 4);
CHECK(n2.node().document_order() == 4);
CHECK(n1.node().attribute(STR("id")).as_int() == 1);
CHECK(n2.node().attribute(STR("id")).as_int() == 1);
xpath_node n3 = doc.select_single_node(STR("node/bar"));
@ -38,8 +34,8 @@ TEST_XML(xpath_api_select_single_node, "<node><head/><foo/><foo/><tail/></node>"
xpath_node n4 = doc.select_single_node(STR("node/head/following-sibling::foo"));
xpath_node n5 = doc.select_single_node(STR("node/tail/preceding-sibling::foo"));
CHECK(n4.node().document_order() == 4);
CHECK(n5.node().document_order() == 4);
CHECK(n4.node().attribute(STR("id")).as_int() == 1);
CHECK(n5.node().attribute(STR("id")).as_int() == 1);
}
TEST(xpath_api_exception_what)

View File

@ -504,8 +504,6 @@ TEST(xpath_string_translate)
TEST_XML(xpath_nodeset_last, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node"));
// last with 0 arguments
@ -520,8 +518,6 @@ TEST_XML(xpath_nodeset_last, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></node>")
TEST_XML(xpath_nodeset_position, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node"));
// position with 0 arguments

View File

@ -404,8 +404,6 @@ TEST(xpath_operators_boolean_precedence)
TEST_XML(xpath_operators_union, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/><tail/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));

View File

@ -4,8 +4,6 @@
TEST_XML(xpath_paths_axes_child, "<node attr='value'><child attr='value'><subchild/></child><another/><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -17,8 +15,6 @@ TEST_XML(xpath_paths_axes_child, "<node attr='value'><child attr='value'><subchi
TEST_XML(xpath_paths_axes_descendant, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -32,8 +28,6 @@ TEST_XML(xpath_paths_axes_descendant, "<node attr='value'><child attr='value'><s
TEST_XML(xpath_paths_axes_parent, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -48,8 +42,6 @@ TEST_XML(xpath_paths_axes_parent, "<node attr='value'><child attr='value'><subch
TEST_XML(xpath_paths_axes_ancestor, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -64,8 +56,6 @@ TEST_XML(xpath_paths_axes_ancestor, "<node attr='value'><child attr='value'><sub
TEST_XML(xpath_paths_axes_following_sibling, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -78,8 +68,6 @@ TEST_XML(xpath_paths_axes_following_sibling, "<node attr1='value' attr2='value'>
TEST_XML(xpath_paths_axes_preceding_sibling, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -92,8 +80,6 @@ TEST_XML(xpath_paths_axes_preceding_sibling, "<node attr1='value' attr2='value'>
TEST_XML(xpath_paths_axes_following, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><almost/><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -107,8 +93,6 @@ TEST_XML(xpath_paths_axes_following, "<node attr1='value' attr2='value'><child a
TEST_XML(xpath_paths_axes_preceding, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><almost/><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -122,8 +106,6 @@ TEST_XML(xpath_paths_axes_preceding, "<node attr1='value' attr2='value'><child a
TEST_XML(xpath_paths_axes_attribute, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another xmlns:foo='bar'><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -145,8 +127,6 @@ TEST_XML(xpath_paths_axes_namespace, "<node xmlns:foo='bar'/>")
TEST_XML(xpath_paths_axes_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -161,8 +141,6 @@ TEST_XML(xpath_paths_axes_self, "<node attr='value'><child attr='value'><subchil
TEST_XML(xpath_paths_axes_descendant_or_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -176,8 +154,6 @@ TEST_XML(xpath_paths_axes_descendant_or_self, "<node attr='value'><child attr='v
TEST_XML(xpath_paths_axes_ancestor_or_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -192,8 +168,6 @@ TEST_XML(xpath_paths_axes_ancestor_or_self, "<node attr='value'><child attr='val
TEST_XML(xpath_paths_axes_abbrev, "<node attr='value'><foo/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -213,8 +187,6 @@ TEST_XML(xpath_paths_axes_abbrev, "<node attr='value'><foo/></node>")
TEST_XML(xpath_paths_nodetest_all, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:c4/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -228,8 +200,6 @@ TEST_XML(xpath_paths_nodetest_all, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:
TEST_XML_FLAGS(xpath_paths_nodetest_name, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:c4/><?c1?></node>", parse_default | parse_pi)
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -249,8 +219,6 @@ TEST_XML_FLAGS(xpath_paths_nodetest_name, "<node a1='v1' x:a2='v2'><c1/><x:c2/><
TEST_XML(xpath_paths_nodetest_all_in_namespace, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:c4/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -269,8 +237,6 @@ TEST_XML(xpath_paths_nodetest_all_in_namespace, "<node a1='v1' x:a2='v2'><c1/><x
TEST_XML_FLAGS(xpath_paths_nodetest_type, "<node attr='value'>pcdata<child/><?pi1 value?><?pi2 value?><!--comment--><![CDATA[cdata]]></node>", parse_default | parse_pi | parse_comments)
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -305,8 +271,6 @@ TEST_XML_FLAGS(xpath_paths_nodetest_type, "<node attr='value'>pcdata<child/><?pi
TEST_XML(xpath_paths_absolute, "<node><foo><foo/><foo/></foo></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -322,8 +286,6 @@ TEST_XML(xpath_paths_absolute, "<node><foo><foo/><foo/></foo></node>")
TEST_XML(xpath_paths_step_abbrev, "<node><foo/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -341,8 +303,6 @@ TEST_XML(xpath_paths_step_abbrev, "<node><foo/></node>")
TEST_XML(xpath_paths_relative_abbrev, "<node><foo><foo/><foo/></foo></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -355,8 +315,6 @@ TEST_XML(xpath_paths_relative_abbrev, "<node><foo><foo/><foo/></foo></node>")
TEST_XML(xpath_paths_absolute_abbrev, "<node><foo><foo/><foo/></foo></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -369,8 +327,6 @@ TEST_XML(xpath_paths_absolute_abbrev, "<node><foo><foo/><foo/></foo></node>")
TEST_XML(xpath_paths_predicate_boolean, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[position()=1]")) % 6;
@ -381,8 +337,6 @@ TEST_XML(xpath_paths_predicate_boolean, "<node><chapter/><chapter/><chapter/><ch
TEST_XML(xpath_paths_predicate_number, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[1]")) % 6;
@ -393,8 +347,6 @@ TEST_XML(xpath_paths_predicate_number, "<node><chapter/><chapter/><chapter/><cha
TEST_XML(xpath_paths_predicate_several, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node"));
CHECK_XPATH_NODESET(n, STR("employee")) % 3 % 4 % 6 % 8 % 11;
@ -407,8 +359,6 @@ TEST_XML(xpath_paths_predicate_several, "<node><employee/><employee secretary=''
TEST_XML(xpath_paths_predicate_filter_boolean, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[position()=1]")) % 6;
@ -419,8 +369,6 @@ TEST_XML(xpath_paths_predicate_filter_boolean, "<node><chapter/><chapter/><chapt
TEST_XML(xpath_paths_predicate_filter_number, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[1]")) % 6;
@ -431,8 +379,6 @@ TEST_XML(xpath_paths_predicate_filter_number, "<node><chapter/><chapter/><chapte
TEST_XML(xpath_paths_predicate_filter_posinv, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node"));
CHECK_XPATH_NODESET(n, STR("employee")) % 3 % 4 % 6 % 8 % 11;
@ -442,8 +388,6 @@ TEST_XML(xpath_paths_predicate_filter_posinv, "<node><employee/><employee secret
TEST_XML(xpath_paths_step_compose, "<node><foo><foo/><foo/></foo><foo/></node>")
{
doc.precompute_document_order();
xml_node n = doc.child(STR("node"));
CHECK_XPATH_NODESET(n, STR("(.)/foo")) % 3 % 6;
@ -456,8 +400,6 @@ TEST_XML(xpath_paths_step_compose, "<node><foo><foo/><foo/></foo><foo/></node>")
TEST_XML(xpath_paths_descendant_double_slash_w3c, "<node><para><para/><para/><para><para/></para></para><para/></node>")
{
doc.precompute_document_order();
CHECK_XPATH_NODESET(doc, STR("//para")) % 3 % 4 % 5 % 6 % 7 % 8;
CHECK_XPATH_NODESET(doc, STR("/descendant::para")) % 3 % 4 % 5 % 6 % 7 % 8;
CHECK_XPATH_NODESET(doc, STR("//para[1]")) % 3 % 4 % 7;
@ -466,8 +408,6 @@ TEST_XML(xpath_paths_descendant_double_slash_w3c, "<node><para><para/><para/><pa
TEST_XML(xpath_paths_needs_sorting, "<node><child/><child/><child><subchild/><subchild/></child></node>")
{
doc.precompute_document_order();
CHECK_XPATH_NODESET(doc, STR("(node/child/subchild)[2]")) % 7;
}

View File

@ -4,8 +4,6 @@
TEST_XML(xpath_paths_abbrev_w3c_1, "<node><para/><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -15,8 +13,6 @@ TEST_XML(xpath_paths_abbrev_w3c_1, "<node><para/><foo/><para/></node>")
TEST_XML(xpath_paths_abbrev_w3c_2, "<node><para/><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -26,8 +22,6 @@ TEST_XML(xpath_paths_abbrev_w3c_2, "<node><para/><foo/><para/></node>")
TEST_XML(xpath_paths_abbrev_w3c_3, "<node>pcdata<child/><![CDATA[cdata]]></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -37,8 +31,6 @@ TEST_XML(xpath_paths_abbrev_w3c_3, "<node>pcdata<child/><![CDATA[cdata]]></node>
TEST_XML(xpath_paths_abbrev_w3c_4, "<node name='value' foo='bar' />")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -48,8 +40,6 @@ TEST_XML(xpath_paths_abbrev_w3c_4, "<node name='value' foo='bar' />")
TEST_XML(xpath_paths_abbrev_w3c_5, "<node name='value' foo='bar' />")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -59,8 +49,6 @@ TEST_XML(xpath_paths_abbrev_w3c_5, "<node name='value' foo='bar' />")
TEST_XML(xpath_paths_abbrev_w3c_6, "<node><para/><para/><para/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -70,8 +58,6 @@ TEST_XML(xpath_paths_abbrev_w3c_6, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_abbrev_w3c_7, "<node><para/><para/><para/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -81,8 +67,6 @@ TEST_XML(xpath_paths_abbrev_w3c_7, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_abbrev_w3c_8, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
CHECK_XPATH_NODESET(c, STR("*/para"));
@ -91,8 +75,6 @@ TEST_XML(xpath_paths_abbrev_w3c_8, "<node><para><para/><para/><foo><para/></foo>
TEST_XML(xpath_paths_abbrev_w3c_9, "<doc><chapter/><chapter/><chapter/><chapter/><chapter><section/><section/><section/></chapter><chapter/></doc>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("doc")).child(STR("chapter"));
@ -103,8 +85,6 @@ TEST_XML(xpath_paths_abbrev_w3c_9, "<doc><chapter/><chapter/><chapter/><chapter/
TEST_XML(xpath_paths_abbrev_w3c_10, "<chapter><para><para/><para/><foo><para/></foo></para><foo/><para/></chapter>")
{
doc.precompute_document_order();
xml_node c;
CHECK_XPATH_NODESET(c, STR("chapter//para"));
@ -113,8 +93,6 @@ TEST_XML(xpath_paths_abbrev_w3c_10, "<chapter><para><para/><para/><foo><para/></
TEST_XML(xpath_paths_abbrev_w3c_11, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -125,8 +103,6 @@ TEST_XML(xpath_paths_abbrev_w3c_11, "<node><para><para/><para/><foo><para/></foo
TEST_XML(xpath_paths_abbrev_w3c_12, "<node><olist><item/></olist><item/><olist><olist><item/><item/></olist></olist></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -137,8 +113,6 @@ TEST_XML(xpath_paths_abbrev_w3c_12, "<node><olist><item/></olist><item/><olist><
TEST_XML(xpath_paths_abbrev_w3c_13, "<node><child/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -149,8 +123,6 @@ TEST_XML(xpath_paths_abbrev_w3c_13, "<node><child/></node>")
TEST_XML(xpath_paths_abbrev_w3c_14, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -161,8 +133,6 @@ TEST_XML(xpath_paths_abbrev_w3c_14, "<node><para><para/><para/><foo><para/></foo
TEST_XML(xpath_paths_abbrev_w3c_15, "<node lang='en'><child/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -173,8 +143,6 @@ TEST_XML(xpath_paths_abbrev_w3c_15, "<node lang='en'><child/></node>")
TEST_XML(xpath_paths_abbrev_w3c_16, "<node lang='en'><child/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -185,8 +153,6 @@ TEST_XML(xpath_paths_abbrev_w3c_16, "<node lang='en'><child/></node>")
TEST_XML(xpath_paths_abbrev_w3c_17, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -196,8 +162,6 @@ TEST_XML(xpath_paths_abbrev_w3c_17, "<node><para/><para type='warning'/><para ty
TEST_XML(xpath_paths_abbrev_w3c_18, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -207,8 +171,6 @@ TEST_XML(xpath_paths_abbrev_w3c_18, "<node><para/><para type='warning'/><para ty
TEST_XML(xpath_paths_abbrev_w3c_19a, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -218,8 +180,6 @@ TEST_XML(xpath_paths_abbrev_w3c_19a, "<node><para/><para type='warning'/><para t
TEST_XML(xpath_paths_abbrev_w3c_19b, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -229,8 +189,6 @@ TEST_XML(xpath_paths_abbrev_w3c_19b, "<node><para/><para type='warning'/><para t
TEST_XML(xpath_paths_abbrev_w3c_20, "<node><chapter><title>foo</title></chapter><chapter><title>Introduction</title></chapter><chapter><title>introduction</title></chapter><chapter/><chapter><title>Introduction</title><title>foo</title></chapter></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -240,8 +198,6 @@ TEST_XML(xpath_paths_abbrev_w3c_20, "<node><chapter><title>foo</title></chapter>
TEST_XML(xpath_paths_abbrev_w3c_21, "<node><chapter><title>foo</title></chapter><chapter><title>Introduction</title></chapter><chapter><title>introduction</title></chapter><chapter/><chapter><title>Introduction</title><title>foo</title></chapter></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -251,8 +207,6 @@ TEST_XML(xpath_paths_abbrev_w3c_21, "<node><chapter><title>foo</title></chapter>
TEST_XML(xpath_paths_abbrev_w3c_22, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));

View File

@ -4,8 +4,6 @@
TEST_XML(xpath_paths_w3c_1, "<node><para/><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -15,8 +13,6 @@ TEST_XML(xpath_paths_w3c_1, "<node><para/><foo/><para/></node>")
TEST_XML(xpath_paths_w3c_2, "<node><para/><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -26,8 +22,6 @@ TEST_XML(xpath_paths_w3c_2, "<node><para/><foo/><para/></node>")
TEST_XML(xpath_paths_w3c_3, "<node>pcdata<child/><![CDATA[cdata]]></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -37,8 +31,6 @@ TEST_XML(xpath_paths_w3c_3, "<node>pcdata<child/><![CDATA[cdata]]></node>")
TEST_XML(xpath_paths_w3c_4, "<node>pcdata<child/><![CDATA[cdata]]></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -48,8 +40,6 @@ TEST_XML(xpath_paths_w3c_4, "<node>pcdata<child/><![CDATA[cdata]]></node>")
TEST_XML(xpath_paths_w3c_5, "<node name='value' foo='bar' />")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -59,8 +49,6 @@ TEST_XML(xpath_paths_w3c_5, "<node name='value' foo='bar' />")
TEST_XML(xpath_paths_w3c_6, "<node name='value' foo='bar' />")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -70,8 +58,6 @@ TEST_XML(xpath_paths_w3c_6, "<node name='value' foo='bar' />")
TEST_XML(xpath_paths_w3c_7, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -82,8 +68,6 @@ TEST_XML(xpath_paths_w3c_7, "<node><para><para/><para/><foo><para/></foo></para>
TEST_XML(xpath_paths_w3c_8, "<node><div><font><div><div/></div></font></div></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -93,8 +77,6 @@ TEST_XML(xpath_paths_w3c_8, "<node><div><font><div><div/></div></font></div></no
TEST_XML(xpath_paths_w3c_9, "<node><div><font><div><div/></div></font></div></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -104,8 +86,6 @@ TEST_XML(xpath_paths_w3c_9, "<node><div><font><div><div/></div></font></div></no
TEST_XML(xpath_paths_w3c_10, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -116,8 +96,6 @@ TEST_XML(xpath_paths_w3c_10, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_11, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -128,8 +106,6 @@ TEST_XML(xpath_paths_w3c_11, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_12, "<chapter><para><para/><para/><foo><para/></foo></para><foo/><para/></chapter>")
{
doc.precompute_document_order();
xml_node c;
CHECK_XPATH_NODESET(c, STR("child::chapter/descendant::para"));
@ -138,8 +114,6 @@ TEST_XML(xpath_paths_w3c_12, "<chapter><para><para/><para/><foo><para/></foo></p
TEST_XML(xpath_paths_w3c_13, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
CHECK_XPATH_NODESET(c, STR("child::*/child::para"));
@ -148,8 +122,6 @@ TEST_XML(xpath_paths_w3c_13, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_14, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -162,8 +134,6 @@ TEST_XML(xpath_paths_w3c_14, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_15, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -174,8 +144,6 @@ TEST_XML(xpath_paths_w3c_15, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_16, "<node><olist><item/></olist><item/><olist><olist><item/><item/></olist></olist></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -186,8 +154,6 @@ TEST_XML(xpath_paths_w3c_16, "<node><olist><item/></olist><item/><olist><olist><
TEST_XML(xpath_paths_w3c_17, "<node><para/><para/><para/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -197,8 +163,6 @@ TEST_XML(xpath_paths_w3c_17, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_w3c_18, "<node><para/><para/><para/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -208,8 +172,6 @@ TEST_XML(xpath_paths_w3c_18, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_w3c_19, "<node><para/><para/><para/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -219,8 +181,6 @@ TEST_XML(xpath_paths_w3c_19, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_w3c_20, "<node><para/><para/><para/><para/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -230,8 +190,6 @@ TEST_XML(xpath_paths_w3c_20, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_w3c_21, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
@ -241,8 +199,6 @@ TEST_XML(xpath_paths_w3c_21, "<node><chapter/><chapter/><chapter/><chapter/><cha
TEST_XML(xpath_paths_w3c_22, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
@ -252,8 +208,6 @@ TEST_XML(xpath_paths_w3c_22, "<node><chapter/><chapter/><chapter/><chapter/><cha
TEST_XML(xpath_paths_w3c_23, "<node><figure><figure/><figure/><foo><figure/></foo></figure><foo/><figure/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -264,8 +218,6 @@ TEST_XML(xpath_paths_w3c_23, "<node><figure><figure/><figure/><foo><figure/></fo
TEST_XML(xpath_paths_w3c_24, "<doc><chapter/><chapter/><chapter/><chapter/><chapter><section/><section/><section/></chapter><chapter/></doc>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("doc")).child(STR("chapter"));
@ -276,8 +228,6 @@ TEST_XML(xpath_paths_w3c_24, "<doc><chapter/><chapter/><chapter/><chapter/><chap
TEST_XML(xpath_paths_w3c_25, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -287,8 +237,6 @@ TEST_XML(xpath_paths_w3c_25, "<node><para/><para type='warning'/><para type='war
TEST_XML(xpath_paths_w3c_26, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -298,8 +246,6 @@ TEST_XML(xpath_paths_w3c_26, "<node><para/><para type='warning'/><para type='war
TEST_XML(xpath_paths_w3c_27a, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -309,8 +255,6 @@ TEST_XML(xpath_paths_w3c_27a, "<node><para/><para type='warning'/><para type='wa
TEST_XML(xpath_paths_w3c_27b, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -320,8 +264,6 @@ TEST_XML(xpath_paths_w3c_27b, "<node><para/><para type='warning'/><para type='wa
TEST_XML(xpath_paths_w3c_28, "<node><chapter><title>foo</title></chapter><chapter><title>Introduction</title></chapter><chapter><title>introduction</title></chapter><chapter/><chapter><title>Introduction</title><title>foo</title></chapter></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -331,8 +273,6 @@ TEST_XML(xpath_paths_w3c_28, "<node><chapter><title>foo</title></chapter><chapte
TEST_XML(xpath_paths_w3c_29, "<node><chapter><title>foo</title></chapter><chapter><title>Introduction</title></chapter><chapter><title>introduction</title></chapter><chapter/><chapter><title>Introduction</title><title>foo</title></chapter></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -342,8 +282,6 @@ TEST_XML(xpath_paths_w3c_29, "<node><chapter><title>foo</title></chapter><chapte
TEST_XML(xpath_paths_w3c_30, "<node><abstract/><chapter/><chapter/><references/><appendix/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -353,8 +291,6 @@ TEST_XML(xpath_paths_w3c_30, "<node><abstract/><chapter/><chapter/><references/>
TEST_XML(xpath_paths_w3c_31a, "<node><abstract/><chapter/><chapter/><references/><appendix/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));
@ -364,8 +300,6 @@ TEST_XML(xpath_paths_w3c_31a, "<node><abstract/><chapter/><chapter/><references/
TEST_XML(xpath_paths_w3c_31b, "<node><abstract/><chapter/><chapter/><references/><appendix/><chapter/></node>")
{
doc.precompute_document_order();
xml_node c;
xml_node n = doc.child(STR("node"));