fixed an erroneous validation bug when PE refs occurs in external parsed

* parser.c: fixed an erroneous validation bug when PE refs
  occurs in external parsed entities referenced from the
  internals subset
* test/valid/index.xml test/valid/dtds/nitf-2-5.dtd
  test/valid/dtds/NewsMLv1.0.dtd result/valid/index.xml*:
  added the associated testcase, it's a nice one.
* HTMLparser.c: generate the DTD node as HTML still ...
* HTMLtree.c: fixed errors in Set/GetMetaEncoding
Daniel
diff --git a/HTMLtree.c b/HTMLtree.c
index 7041dbe..cd9417c 100644
--- a/HTMLtree.c
+++ b/HTMLtree.c
@@ -54,7 +54,7 @@
      * Search the html
      */
     while (cur != NULL) {
-	if (cur->name != NULL) {
+	if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) {
 	    if (xmlStrEqual(cur->name, BAD_CAST"html"))
 		break;
 	    if (xmlStrEqual(cur->name, BAD_CAST"head"))
@@ -72,7 +72,7 @@
      * Search the head
      */
     while (cur != NULL) {
-	if (cur->name != NULL) {
+	if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) {
 	    if (xmlStrEqual(cur->name, BAD_CAST"head"))
 		break;
 	    if (xmlStrEqual(cur->name, BAD_CAST"meta"))
@@ -90,7 +90,7 @@
      */
 found_meta:
     while (cur != NULL) {
-	if (cur->name != NULL) {
+	if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) {
 	    if (xmlStrEqual(cur->name, BAD_CAST"meta")) {
 		xmlAttrPtr attr = cur->properties;
 		int http;
@@ -180,7 +180,7 @@
      * Search the html
      */
     while (cur != NULL) {
-	if (cur->name != NULL) {
+	if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) {
 	    if (xmlStrcasecmp(cur->name, BAD_CAST"html") == 0)
 		break;
 	    if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
@@ -198,7 +198,7 @@
      * Search the head
      */
     while (cur != NULL) {
-	if (cur->name != NULL) {
+	if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) {
 	    if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
 		break;
 	    if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0)
@@ -237,7 +237,7 @@
      * encoding informations
      */
     while (cur != NULL) {
-	if (cur->name != NULL) {
+	if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) {
 	    if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) {
 		xmlAttrPtr attr = cur->properties;
 		int http;