fix some recursion problems introduced in the last release. more debugging

* SAX.c parser.c: fix some recursion problems introduced in the
  last release.
* relaxng.c: more debugging of the RNG validation engine, still
  problems though.
Daniel
diff --git a/parser.c b/parser.c
index ba9327c..83db22b 100644
--- a/parser.c
+++ b/parser.c
@@ -5753,9 +5753,10 @@
 		if (ctxt->sax != NULL) {
 		    if (ctxt->sax->getEntity != NULL)
 			ent = ctxt->sax->getEntity(ctxt->userData, name);
-		    if (ent == NULL)
+		    if ((ctxt->wellFormed == 1 ) && (ent == NULL))
 		        ent = xmlGetPredefinedEntity(name);
-		    if ((ent == NULL) && (ctxt->userData==ctxt)) {
+		    if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
+			(ctxt->userData==ctxt)) {
 			ent = getEntity(ctxt, name);
 		    }
 		}