Enhanced xmlXPathRunStreamEval, fixed handling of depth/level for cases

* xpath.c, pattern.c: Enhanced xmlXPathRunStreamEval, fixed
  handling of depth/level for cases like union operator
  (bug #306348 reported by Bob Stayton).  Also enhanced
  several comments throughout pattern.c.
* doc/apibuild.py: fixed problem in handling of
  'signed' declaration.  Rebuilt the docs.
diff --git a/xpath.c b/xpath.c
index 862ff53..8ee0805 100644
--- a/xpath.c
+++ b/xpath.c
@@ -11080,6 +11080,12 @@
 	    }
 	    if ((cur->children == NULL) || (depth >= max_depth)) {
 		ret = xmlStreamPop(patstream);
+		while (cur->next != NULL) {
+		    cur = cur->next;
+		    if ((cur->type != XML_ENTITY_DECL) &&
+			(cur->type != XML_DTD_NODE))
+			goto next_node;
+		}
 	    }
 	}
         
@@ -11110,11 +11116,12 @@
 	}
 	
 	do {
-	    ret = xmlStreamPop(patstream);
 	    cur = cur->parent;
 	    depth--;
 	    if ((cur == NULL) || (cur == limit))
 	        goto done;
+	    if (cur->type == XML_ELEMENT_NODE)
+	        ret = xmlStreamPop(patstream);
 	    if (cur->next != NULL) {
 		cur = cur->next;
 		break;