@@ -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