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

Function xmlValidateDocument

ThirdParty/libxml2/vtklibxml2/valid.c:6689–6748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6687 */
6688
6689int
6690xmlValidateDocument(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
6691 int ret;
6692 xmlNodePtr root;
6693
6694 if (doc == NULL)
6695 return(0);
6696 if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
6697 xmlErrValid(ctxt, XML_DTD_NO_DTD,
6698 "no DTD found!\n", NULL);
6699 return(0);
6700 }
6701 if ((doc->intSubset != NULL) && ((doc->intSubset->SystemID != NULL) ||
6702 (doc->intSubset->ExternalID != NULL)) && (doc->extSubset == NULL)) {
6703 xmlChar *sysID;
6704 if (doc->intSubset->SystemID != NULL) {
6705 sysID = xmlBuildURI(doc->intSubset->SystemID,
6706 doc->URL);
6707 if (sysID == NULL) {
6708 xmlErrValid(ctxt, XML_DTD_LOAD_ERROR,
6709 "Could not build URI for external subset \"%s\"\n",
6710 (const char *) doc->intSubset->SystemID);
6711 return 0;
6712 }
6713 } else
6714 sysID = NULL;
6715 doc->extSubset = xmlParseDTD(doc->intSubset->ExternalID,
6716 (const xmlChar *)sysID);
6717 if (sysID != NULL)
6718 xmlFree(sysID);
6719 if (doc->extSubset == NULL) {
6720 if (doc->intSubset->SystemID != NULL) {
6721 xmlErrValid(ctxt, XML_DTD_LOAD_ERROR,
6722 "Could not load the external subset \"%s\"\n",
6723 (const char *) doc->intSubset->SystemID);
6724 } else {
6725 xmlErrValid(ctxt, XML_DTD_LOAD_ERROR,
6726 "Could not load the external subset \"%s\"\n",
6727 (const char *) doc->intSubset->ExternalID);
6728 }
6729 return(0);
6730 }
6731 }
6732
6733 if (doc->ids != NULL) {
6734 xmlFreeIDTable(doc->ids);
6735 doc->ids = NULL;
6736 }
6737 if (doc->refs != NULL) {
6738 xmlFreeRefTable(doc->refs);
6739 doc->refs = NULL;
6740 }
6741 ret = xmlValidateDtdFinal(ctxt, doc);
6742 if (!xmlValidateRoot(ctxt, doc)) return(0);
6743
6744 root = xmlDocGetRootElement(doc);
6745 ret &= xmlValidateElement(ctxt, doc, root);
6746 ret &= xmlValidateDocumentFinal(ctxt, doc);

Callers 2

parseAndPrintFileFunction · 0.85
xmlShellValidateFunction · 0.85

Calls 9

xmlBuildURIFunction · 0.85
xmlParseDTDFunction · 0.85
xmlFreeIDTableFunction · 0.85
xmlFreeRefTableFunction · 0.85
xmlValidateDtdFinalFunction · 0.85
xmlValidateRootFunction · 0.85
xmlDocGetRootElementFunction · 0.85
xmlValidateElementFunction · 0.85
xmlValidateDocumentFinalFunction · 0.85

Tested by

no test coverage detected