summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-05-29 20:11:36 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-05-29 20:11:36 +0000
commit1c567deccacf26e93927878b8c294377c4d5a9cf (patch)
tree64bcba48cea43b0e6f21688583107fe558e2b38f
parentd1b41ba17825911ed37d7fb9bd1a9464ca7ce073 (diff)
Fixed following:: and preceding:: axes for attribute nodes
git-svn-id: http://pugixml.googlecode.com/svn/trunk@466 99668b35-9821-0410-8761-19e4c4f06640
-rw-r--r--src/pugixpath.cpp41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/pugixpath.cpp b/src/pugixpath.cpp
index 2296814..94498bc 100644
--- a/src/pugixpath.cpp
+++ b/src/pugixpath.cpp
@@ -1725,7 +1725,7 @@ namespace pugi
}
}
- template <class T> void step_fill(xpath_node_set& ns, const xml_attribute& a, const xml_node& p, T)
+ template <class T> void step_fill(xpath_node_set& ns, const xml_attribute& a, const xml_node& p, T v)
{
const axis_t axis = T::axis;
@@ -1750,6 +1750,39 @@ namespace pugi
break;
}
+
+ case axis_following:
+ {
+ ns.m_type = ns.empty() ? xpath_node_set::type_sorted : xpath_node_set::type_unsorted;
+
+ xml_node cur = p;
+
+ for (;;)
+ {
+ 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;
+ }
+
+ step_push(ns, cur);
+ }
+
+ break;
+ }
+
+ case axis_preceding:
+ {
+ // preceding:: axis does not include attribute nodes and attribute ancestors (they are the same as parent's ancestors), so we can reuse node preceding
+ step_fill(ns, p, v);
+ break;
+ }
default:
assert(!"Unimplemented axis");
@@ -1760,6 +1793,8 @@ namespace pugi
{
const axis_t axis = T::axis;
+ assert(ns.empty());
+
switch (axis)
{
case axis_parent:
@@ -1823,6 +1858,8 @@ namespace pugi
case axis_ancestor:
case axis_ancestor_or_self:
+ case axis_following:
+ case axis_preceding:
if (m_left)
{
xpath_node_set s = m_left->eval_node_set(c);
@@ -1849,9 +1886,7 @@ namespace pugi
break;
- case axis_following:
case axis_following_sibling:
- case axis_preceding:
case axis_preceding_sibling:
case axis_attribute:
case axis_child: