summaryrefslogtreecommitdiff
path: root/xpath.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2001-08-14 12:18:09 +0000
committerDaniel Veillard <veillard@src.gnome.org>2001-08-14 12:18:09 +0000
commitfe70332f7f29f146a364c73450729a8b3274daee (patch)
tree15c2812b07d703a6cdeff950f1933fa9c22549bd /xpath.c
parent70ac0e3e2e1dee65b7b6e7487ad6ae43bb79a4de (diff)
downloadlibxml2-fe70332f7f29f146a364c73450729a8b3274daee.tar.gz
count() was broken on Result Value Tree fixed file:/// accesses on _WIN32
* xpath.c: count() was broken on Result Value Tree * xmlIO.c: fixed file:/// accesses on _WIN32 Daniel
Diffstat (limited to 'xpath.c')
-rw-r--r--xpath.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/xpath.c b/xpath.c
index 1c8c1a85..2de4e1d5 100644
--- a/xpath.c
+++ b/xpath.c
@@ -5193,8 +5193,27 @@ xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) {
if ((cur == NULL) || (cur->nodesetval == NULL))
valuePush(ctxt, xmlXPathNewFloat((double) 0));
- else
+ else if (cur->type == XPATH_NODESET) {
valuePush(ctxt, xmlXPathNewFloat((double) cur->nodesetval->nodeNr));
+ } else {
+ if ((cur->nodesetval->nodeNr != 1) ||
+ (cur->nodesetval->nodeTab == NULL)) {
+ valuePush(ctxt, xmlXPathNewFloat((double) 0));
+ } else {
+ xmlNodePtr tmp;
+ int i = 0;
+
+ tmp = cur->nodesetval->nodeTab[0];
+ if (tmp != NULL) {
+ tmp = tmp->children;
+ while (tmp != NULL) {
+ tmp = tmp->next;
+ i++;
+ }
+ }
+ valuePush(ctxt, xmlXPathNewFloat((double) i));
+ }
+ }
xmlXPathFreeObject(cur);
}