MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlValidatePushElement

Function xmlValidatePushElement

ThirdParty/libxml2/vtklibxml2/valid.c:5576–5661  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

5574 * returns 1 if no validation problem was found or 0 otherwise
5575 */
5576int
5577xmlValidatePushElement(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:

Callers 1

Calls 5

xmlValidateCheckMixedFunction · 0.85
xmlRegExecPushStringFunction · 0.85
xmlVErrMemoryFunction · 0.85
xmlValidGetElemDeclFunction · 0.85
vstateVPushFunction · 0.85

Tested by

no test coverage detected