more types, more coverage more problems fixed Daniel

* gentest.py testapi.c: more types, more coverage
* parser.c parserInternals.c relaxng.c valid.c xmlIO.c
  xmlschemastypes.c: more problems fixed
Daniel
diff --git a/relaxng.c b/relaxng.c
index 8bd4d23..af4de86 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -248,6 +248,7 @@
     xmlAutomataStatePtr state;  /* used to build the automata */
 
     int crng;			/* compact syntax and other flags */
+    int freedoc;		/* need to free the document */
 };
 
 #define FLAGS_IGNORABLE		1
@@ -6657,6 +6658,7 @@
     }
     memset(ret, 0, sizeof(xmlRelaxNGParserCtxt));
     ret->document = copy;
+    ret->freedoc = 1;
     ret->userData = xmlGenericErrorContext;
     return (ret);
 }
@@ -6693,6 +6695,8 @@
             xmlRelaxNGFreeDefine(ctxt->defTab[i]);
         xmlFree(ctxt->defTab);
     }
+    if ((ctxt->document != NULL) && (ctxt->freedoc))
+        xmlFreeDoc(ctxt->document);
     xmlFree(ctxt);
 }