diff --git a/ChangeLog b/ChangeLog
index cfcdb3d6d14c86b63fda2d1ba52f9b1d62a1aee9_Q2hhbmdlTG9n..aa487b7539b1843080419c41de088ba869e96880_Q2hhbmdlTG9n 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Feb 23 19:25:13 HKT 2005 William Brack <wbrack@mmm.com.hk>
+
+	* libxslt/pattern.c: fixed a problem with '//' and
+	  namespaces (bug 168208)
+
 Mon Feb 14 23:10:21 HKT 2005 William Brack <wbrack@mmm.com.hk>
 
 	* libxslt/namespaces.c: fixed a problem with
diff --git a/libxslt/pattern.c b/libxslt/pattern.c
index cfcdb3d6d14c86b63fda2d1ba52f9b1d62a1aee9_bGlieHNsdC9wYXR0ZXJuLmM=..aa487b7539b1843080419c41de088ba869e96880_bGlieHNsdC9wYXR0ZXJuLmM= 100644
--- a/libxslt/pattern.c
+++ b/libxslt/pattern.c
@@ -522,7 +522,6 @@
             case XSLT_OP_ANCESTOR:
 		/* TODO: implement coalescing of ANCESTOR/NODE ops */
 		if (step->value == NULL) {
-		    i++;
-		    step = &comp->steps[i];
+		    step = &comp->steps[i+1];
 		    if (step->op == XSLT_OP_ROOT)
 			return(1);
@@ -527,4 +526,9 @@
 		    if (step->op == XSLT_OP_ROOT)
 			return(1);
-		    if ((step->op != XSLT_OP_ELEM) && (step->op != XSLT_OP_ALL))
+		    /* added NS, ID and KEY as a result of bug 168208 */
+		    if ((step->op != XSLT_OP_ELEM) && 
+				(step->op != XSLT_OP_ALL) && 
+				(step->op != XSLT_OP_NS) &&
+				(step->op != XSLT_OP_ID) &&
+				(step->op != XSLT_OP_KEY))
 			return(0);
@@ -530,6 +534,4 @@
 			return(0);
-		    if ((step->value == NULL) && (step->op != XSLT_OP_ALL))
-			return(-1);
 		}
 		if (node == NULL)
 		    return(0);
@@ -541,6 +543,9 @@
 		    (node->type == XML_NAMESPACE_DECL))
 		    return(0);
 		node = node->parent;
+		if ((step->op != XSLT_OP_ELEM) && step->op != XSLT_OP_ALL)
+			continue;
+		i++;
 		if (step->value == NULL)
 		    continue;
 		while (node != NULL) {