diff --git a/ChangeLog b/ChangeLog
index 40f72f4a18a8265405837c3531a3651ff37d05dd_Q2hhbmdlTG9n..82beabea1f47478483ada91f95fd4d98e24a6f57_Q2hhbmdlTG9n 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Sep 29 15:42:33 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+	* libxslt/pattern.c: try to fix #153137 but without a test case
+	  it's shooting in the dark.
+
 Tue Sep 28 16:20:48 CEST 2004 Daniel Veillard <daniel@veillard.com>
 
 	* doc/tutorial2/libxslt_pipes.*: New tutorial from Panagiotis Louridas
diff --git a/libxslt/pattern.c b/libxslt/pattern.c
index 40f72f4a18a8265405837c3531a3651ff37d05dd_bGlieHNsdC9wYXR0ZXJuLmM=..82beabea1f47478483ada91f95fd4d98e24a6f57_bGlieHNsdC9wYXR0ZXJuLmM= 100644
--- a/libxslt/pattern.c
+++ b/libxslt/pattern.c
@@ -770,7 +770,9 @@
 			     * If the node is in a Value Tree we cannot
 			     * cache it !
 			     */
-			    if (node->doc != NULL) {
+			    if ((node->doc != NULL) &&
+			        (node->doc->name != NULL) &&
+				(node->doc->name[0] != ' ')) {
 				len = (int)
 				    XSLT_RUNTIME_EXTRA(ctxt, select->lenExtra);
 				XSLT_RUNTIME_EXTRA(ctxt,
@@ -875,7 +877,9 @@
 			     * If the node is in a Value Tree we cannot
 			     * cache it !
 			     */
-			    if (node->doc != NULL) {
+			    if ((node->doc != NULL) &&
+			        (node->doc->name != NULL) &&
+				(node->doc->name[0] != ' ')) {
 				len = (int)
 				    XSLT_RUNTIME_EXTRA(ctxt, select->lenExtra);
 				XSLT_RUNTIME_EXTRA(ctxt,