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

Function xmlValidateOneElement

ThirdParty/libxml2/vtklibxml2/valid.c:5817–6126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5815 */
5816
5817int
5818xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
5819 xmlNodePtr elem) {
5820 xmlElementPtr elemDecl = NULL;
5821 xmlElementContentPtr cont;
5822 xmlAttributePtr attr;
5823 xmlNodePtr child;
5824 int ret = 1, tmp;
5825 const xmlChar *name;
5826 int extsubset = 0;
5827
5828 CHECK_DTD;
5829
5830 if (elem == NULL) return(0);
5831 switch (elem->type) {
5832 case XML_TEXT_NODE:
5833 case XML_CDATA_SECTION_NODE:
5834 case XML_ENTITY_REF_NODE:
5835 case XML_PI_NODE:
5836 case XML_COMMENT_NODE:
5837 case XML_XINCLUDE_START:
5838 case XML_XINCLUDE_END:
5839 return(1);
5840 case XML_ELEMENT_NODE:
5841 break;
5842 default:
5843 xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
5844 "unexpected element type\n", NULL, NULL ,NULL);
5845 return(0);
5846 }
5847
5848 /*
5849 * Fetch the declaration
5850 */
5851 elemDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset);
5852 if (elemDecl == NULL)
5853 return(0);
5854
5855 /*
5856 * If vstateNr is not zero that means continuous validation is
5857 * activated, do not try to check the content model at that level.
5858 */
5859 if (ctxt->vstateNr == 0) {
5860 /* Check that the element content matches the definition */
5861 switch (elemDecl->etype) {
5862 case XML_ELEMENT_TYPE_UNDEFINED:
5863 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ELEM,
5864 "No declaration for element %s\n",
5865 elem->name, NULL, NULL);
5866 return(0);
5867 case XML_ELEMENT_TYPE_EMPTY:
5868 if (elem->children != NULL) {
5869 xmlErrValidNode(ctxt, elem, XML_DTD_NOT_EMPTY,
5870 "Element %s was declared EMPTY this one has content\n",
5871 elem->name, NULL, NULL);
5872 ret = 0;
5873 }
5874 break;

Callers 4

xmlValidateElementFunction · 0.85
xmlValidGetValidElementsFunction · 0.85
xmlSAX2EndElementFunction · 0.85
xmlSAX2EndElementNsFunction · 0.85

Calls 6

xmlValidGetElemDeclFunction · 0.85
xmlBuildQNameFunction · 0.85
xmlVErrMemoryFunction · 0.85
xmlStrEqualFunction · 0.85

Tested by

no test coverage detected