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

Function xmlRelaxNGValidateCompiledContent

ThirdParty/libxml2/vtklibxml2/relaxng.c:7868–7943  ·  view source on GitHub ↗

* xmlRelaxNGValidateCompiledContent: * @ctxt: the RelaxNG validation context * @regexp: the regular expression as compiled * @content: list of children to test against the regexp * * Validate the content model of an element or start using the regexp * * Returns 0 in case of success, -1 in case of error. */

Source from the content-addressed store, hash-verified

7866 * Returns 0 in case of success, -1 in case of error.
7867 */
7868static int
7869xmlRelaxNGValidateCompiledContent(xmlRelaxNGValidCtxtPtr ctxt,
7870 xmlRegexpPtr regexp, xmlNodePtr content)
7871{
7872 xmlRegExecCtxtPtr exec;
7873 xmlNodePtr cur;
7874 int ret = 0;
7875 int oldperr;
7876
7877 if ((ctxt == NULL) || (regexp == NULL))
7878 return (-1);
7879 oldperr = ctxt->perr;
7880 exec = xmlRegNewExecCtxt(regexp,
7881 xmlRelaxNGValidateCompiledCallback, ctxt);
7882 ctxt->perr = 0;
7883 cur = content;
7884 while (cur != NULL) {
7885 ctxt->state->seq = cur;
7886 switch (cur->type) {
7887 case XML_TEXT_NODE:
7888 case XML_CDATA_SECTION_NODE:
7889 if (xmlIsBlankNode(cur))
7890 break;
7891 ret = xmlRegExecPushString(exec, BAD_CAST "#text", ctxt);
7892 if (ret < 0) {
7893 VALID_ERR2(XML_RELAXNG_ERR_TEXTWRONG,
7894 cur->parent->name);
7895 }
7896 break;
7897 case XML_ELEMENT_NODE:
7898 if (cur->ns != NULL) {
7899 ret = xmlRegExecPushString2(exec, cur->name,
7900 cur->ns->href, ctxt);
7901 } else {
7902 ret = xmlRegExecPushString(exec, cur->name, ctxt);
7903 }
7904 if (ret < 0) {
7905 VALID_ERR2(XML_RELAXNG_ERR_ELEMWRONG, cur->name);
7906 }
7907 break;
7908 default:
7909 break;
7910 }
7911 if (ret < 0)
7912 break;
7913 /*
7914 * Switch to next element
7915 */
7916 cur = cur->next;
7917 }
7918 ret = xmlRegExecPushString(exec, NULL, NULL);
7919 if (ret == 1) {
7920 ret = 0;
7921 ctxt->state->seq = NULL;
7922 } else if (ret == 0) {
7923 /*
7924 * TODO: get some of the names needed to exit the current state of exec
7925 */

Callers 1

xmlRelaxNGValidateStateFunction · 0.85

Calls 6

xmlRegNewExecCtxtFunction · 0.85
xmlIsBlankNodeFunction · 0.85
xmlRegExecPushStringFunction · 0.85
xmlRegExecPushString2Function · 0.85
xmlRelaxNGDumpValidErrorFunction · 0.85
xmlRegFreeExecCtxtFunction · 0.85

Tested by

no test coverage detected