* xmlValidatePushElement: * @ctxt: the validation context * @doc: a document instance * @elem: an element instance * @qname: the qualified name as appearing in the serialization * * DEPRECATED: Internal function, don't use. * * Push a new element start on the validation stack. * * returns 1 if no validation problem was found or 0 otherwise */
| 5574 | * returns 1 if no validation problem was found or 0 otherwise |
| 5575 | */ |
| 5576 | int |
| 5577 | xmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 5578 | xmlNodePtr elem, const xmlChar *qname) { |
| 5579 | int ret = 1; |
| 5580 | xmlElementPtr eDecl; |
| 5581 | int extsubset = 0; |
| 5582 | |
| 5583 | if (ctxt == NULL) |
| 5584 | return(0); |
| 5585 | /* printf("PushElem %s\n", qname); */ |
| 5586 | if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) { |
| 5587 | xmlValidStatePtr state = ctxt->vstate; |
| 5588 | xmlElementPtr elemDecl; |
| 5589 | |
| 5590 | /* |
| 5591 | * Check the new element against the content model of the new elem. |
| 5592 | */ |
| 5593 | if (state->elemDecl != NULL) { |
| 5594 | elemDecl = state->elemDecl; |
| 5595 | |
| 5596 | switch(elemDecl->etype) { |
| 5597 | case XML_ELEMENT_TYPE_UNDEFINED: |
| 5598 | ret = 0; |
| 5599 | break; |
| 5600 | case XML_ELEMENT_TYPE_EMPTY: |
| 5601 | xmlErrValidNode(ctxt, state->node, |
| 5602 | XML_DTD_NOT_EMPTY, |
| 5603 | "Element %s was declared EMPTY this one has content\n", |
| 5604 | state->node->name, NULL, NULL); |
| 5605 | ret = 0; |
| 5606 | break; |
| 5607 | case XML_ELEMENT_TYPE_ANY: |
| 5608 | /* I don't think anything is required then */ |
| 5609 | break; |
| 5610 | case XML_ELEMENT_TYPE_MIXED: |
| 5611 | /* simple case of declared as #PCDATA */ |
| 5612 | if ((elemDecl->content != NULL) && |
| 5613 | (elemDecl->content->type == |
| 5614 | XML_ELEMENT_CONTENT_PCDATA)) { |
| 5615 | xmlErrValidNode(ctxt, state->node, |
| 5616 | XML_DTD_NOT_PCDATA, |
| 5617 | "Element %s was declared #PCDATA but contains non text nodes\n", |
| 5618 | state->node->name, NULL, NULL); |
| 5619 | ret = 0; |
| 5620 | } else { |
| 5621 | ret = xmlValidateCheckMixed(ctxt, elemDecl->content, |
| 5622 | qname); |
| 5623 | if (ret != 1) { |
| 5624 | xmlErrValidNode(ctxt, state->node, |
| 5625 | XML_DTD_INVALID_CHILD, |
| 5626 | "Element %s is not declared in %s list of possible children\n", |
| 5627 | qname, state->node->name, NULL); |
| 5628 | } |
| 5629 | } |
| 5630 | break; |
| 5631 | case XML_ELEMENT_TYPE_ELEMENT: |
| 5632 | /* |
| 5633 | * TODO: |
no test coverage detected