Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit f345296

Browse files
committed
Revert "valid: Remove duplicate error messages when streaming"
This reverts commit cd220b9. This commit broke the xmstarlet tests.
1 parent 0e145ae commit f345296

9 files changed

Lines changed: 61 additions & 6 deletions

File tree

python/tests/reader2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"""{0}/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got
4343
<a/>
4444
^
45+
{0}/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more children
46+
47+
^
4548
""".format(dir_prefix),
4649
'cond_sect2':
4750
"""{0}/dtds/cond_sect2.dtd:15: parser error : All markup of the conditional section is not in the same entity

result/VC/ElementValid2.rdr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
./test/VC/ElementValid2:4: element p: validity error : No declaration for element p
22
<doc><p/></doc>
33
^
4+
./test/VC/ElementValid2:5: element p: validity error : No declaration for element p
5+
6+
^

result/VC/ElementValid3.rdr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
./test/VC/ElementValid3:4: element doc: validity error : Element doc was declared EMPTY this one has content
22
<doc>Oops, this element was declared EMPTY</doc>
33
^
4+
./test/VC/ElementValid3:5: element doc: validity error : Element doc was declared EMPTY this one has content
5+
6+
^

result/VC/ElementValid4.rdr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
./test/VC/ElementValid4:7: element doc: validity error : Element c is not declared in doc list of possible children
22
<doc> This <b>seems</b> Ok <a/> but this <c>was not declared</c></doc>
33
^
4+
./test/VC/ElementValid4:8: element doc: validity error : Element c is not declared in doc list of possible children
5+
6+
^

result/VC/ElementValid5.rdr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
./test/VC/ElementValid5:7: element doc: validity error : Element doc content does not follow the DTD, expecting (a , b* , c+), got (a b c b)
22
<doc><a/><b> but this</b><c>was not declared</c><b>seems</b></doc>
33
^
4+
./test/VC/ElementValid5:8: element doc: validity error : Element doc content does not follow the DTD, Misplaced b
5+
6+
^
7+
./test/VC/ElementValid5:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
8+
9+
^

result/VC/ElementValid6.rdr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
./test/VC/ElementValid6:7: element doc: validity error : Element doc content does not follow the DTD, expecting (a , b? , c+)?, got (a b)
22
<doc><a/><b>lacks c</b></doc>
33
^
4+
./test/VC/ElementValid6:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
5+
6+
^

result/VC/ElementValid7.rdr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
./test/VC/ElementValid7:7: element doc: validity error : Element doc content does not follow the DTD, expecting ((a | b)* , c+ , a , b? , c , a?), got (a b a c c a)
22
<doc><a/><b/><a/><c/><c/><a/></doc>
33
^
4+
./test/VC/ElementValid7:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
5+
6+
^

result/valid/781333.xml.err.rdr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
./test/valid/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got
22
<a/>
33
^
4+
./test/valid/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more children
5+
6+
^

valid.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5554,6 +5554,12 @@ xmlValidGetElemDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
55545554
*extsubset = 1;
55555555
}
55565556
}
5557+
if (elemDecl == NULL) {
5558+
xmlErrValidNode(ctxt, elem,
5559+
XML_DTD_UNKNOWN_ELEM,
5560+
"No declaration for element %s\n",
5561+
elem->name, NULL, NULL);
5562+
}
55575563
return(elemDecl);
55585564
}
55595565

@@ -5596,6 +5602,10 @@ xmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
55965602
ret = 0;
55975603
break;
55985604
case XML_ELEMENT_TYPE_EMPTY:
5605+
xmlErrValidNode(ctxt, state->node,
5606+
XML_DTD_NOT_EMPTY,
5607+
"Element %s was declared EMPTY this one has content\n",
5608+
state->node->name, NULL, NULL);
55995609
ret = 0;
56005610
break;
56015611
case XML_ELEMENT_TYPE_ANY:
@@ -5606,10 +5616,20 @@ xmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
56065616
if ((elemDecl->content != NULL) &&
56075617
(elemDecl->content->type ==
56085618
XML_ELEMENT_CONTENT_PCDATA)) {
5619+
xmlErrValidNode(ctxt, state->node,
5620+
XML_DTD_NOT_PCDATA,
5621+
"Element %s was declared #PCDATA but contains non text nodes\n",
5622+
state->node->name, NULL, NULL);
56095623
ret = 0;
56105624
} else {
56115625
ret = xmlValidateCheckMixed(ctxt, elemDecl->content,
56125626
qname);
5627+
if (ret != 1) {
5628+
xmlErrValidNode(ctxt, state->node,
5629+
XML_DTD_INVALID_CHILD,
5630+
"Element %s is not declared in %s list of possible children\n",
5631+
qname, state->node->name, NULL);
5632+
}
56135633
}
56145634
break;
56155635
case XML_ELEMENT_TYPE_ELEMENT:
@@ -5626,6 +5646,10 @@ xmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
56265646
return(0);
56275647
}
56285648
if (ret < 0) {
5649+
xmlErrValidNode(ctxt, state->node,
5650+
XML_DTD_CONTENT_MODEL,
5651+
"Element %s content does not follow the DTD, Misplaced %s\n",
5652+
state->node->name, qname, NULL);
56295653
ret = 0;
56305654
} else {
56315655
ret = 1;
@@ -5675,6 +5699,10 @@ xmlValidatePushCData(xmlValidCtxtPtr ctxt, const xmlChar *data, int len) {
56755699
ret = 0;
56765700
break;
56775701
case XML_ELEMENT_TYPE_EMPTY:
5702+
xmlErrValidNode(ctxt, state->node,
5703+
XML_DTD_NOT_EMPTY,
5704+
"Element %s was declared EMPTY this one has content\n",
5705+
state->node->name, NULL, NULL);
56785706
ret = 0;
56795707
break;
56805708
case XML_ELEMENT_TYPE_ANY:
@@ -5747,6 +5775,11 @@ xmlValidatePopElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED,
57475775
if (ret <= 0) {
57485776
if (ret == XML_REGEXP_OUT_OF_MEMORY)
57495777
xmlVErrMemory(ctxt);
5778+
else
5779+
xmlErrValidNode(ctxt, state->node,
5780+
XML_DTD_CONTENT_MODEL,
5781+
"Element %s content does not follow the DTD, Expecting more children\n",
5782+
state->node->name, NULL,NULL);
57505783
ret = 0;
57515784
} else {
57525785
/*
@@ -5819,13 +5852,8 @@ xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
58195852
* Fetch the declaration
58205853
*/
58215854
elemDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset);
5822-
if (elemDecl == NULL) {
5823-
xmlErrValidNode(ctxt, elem,
5824-
XML_DTD_UNKNOWN_ELEM,
5825-
"No declaration for element %s\n",
5826-
elem->name, NULL, NULL);
5855+
if (elemDecl == NULL)
58275856
return(0);
5828-
}
58295857

58305858
/*
58315859
* If vstateNr is not zero that means continuous validation is

0 commit comments

Comments
 (0)