* xmlRelaxNGValidatePushElement: * @ctxt: the validation context * @doc: a document instance * @elem: an element instance * * Push a new element start on the RelaxNG validation stack. * * returns 1 if no validation problem was found or 0 if validating the * element requires a full node, and -1 in case of error. */
| 8158 | * element requires a full node, and -1 in case of error. |
| 8159 | */ |
| 8160 | int |
| 8161 | xmlRelaxNGValidatePushElement(xmlRelaxNGValidCtxtPtr ctxt, |
| 8162 | xmlDocPtr doc ATTRIBUTE_UNUSED, |
| 8163 | xmlNodePtr elem) |
| 8164 | { |
| 8165 | int ret = 1; |
| 8166 | |
| 8167 | if ((ctxt == NULL) || (elem == NULL)) |
| 8168 | return (-1); |
| 8169 | |
| 8170 | if (ctxt->elem == 0) { |
| 8171 | xmlRelaxNGPtr schema; |
| 8172 | xmlRelaxNGGrammarPtr grammar; |
| 8173 | xmlRegExecCtxtPtr exec; |
| 8174 | xmlRelaxNGDefinePtr define; |
| 8175 | |
| 8176 | schema = ctxt->schema; |
| 8177 | if (schema == NULL) { |
| 8178 | VALID_ERR(XML_RELAXNG_ERR_NOGRAMMAR); |
| 8179 | return (-1); |
| 8180 | } |
| 8181 | grammar = schema->topgrammar; |
| 8182 | if ((grammar == NULL) || (grammar->start == NULL)) { |
| 8183 | VALID_ERR(XML_RELAXNG_ERR_NOGRAMMAR); |
| 8184 | return (-1); |
| 8185 | } |
| 8186 | define = grammar->start; |
| 8187 | if (define->contModel == NULL) { |
| 8188 | ctxt->pdef = define; |
| 8189 | return (0); |
| 8190 | } |
| 8191 | exec = xmlRegNewExecCtxt(define->contModel, |
| 8192 | xmlRelaxNGValidateProgressiveCallback, |
| 8193 | ctxt); |
| 8194 | if (exec == NULL) { |
| 8195 | return (-1); |
| 8196 | } |
| 8197 | xmlRelaxNGElemPush(ctxt, exec); |
| 8198 | } |
| 8199 | ctxt->pnode = elem; |
| 8200 | ctxt->pstate = 0; |
| 8201 | if (elem->ns != NULL) { |
| 8202 | ret = |
| 8203 | xmlRegExecPushString2(ctxt->elem, elem->name, elem->ns->href, |
| 8204 | ctxt); |
| 8205 | } else { |
| 8206 | ret = xmlRegExecPushString(ctxt->elem, elem->name, ctxt); |
| 8207 | } |
| 8208 | if (ret < 0) { |
| 8209 | VALID_ERR2(XML_RELAXNG_ERR_ELEMWRONG, elem->name); |
| 8210 | } else { |
| 8211 | if (ctxt->pstate == 0) |
| 8212 | ret = 0; |
| 8213 | else if (ctxt->pstate < 0) |
| 8214 | ret = -1; |
| 8215 | else |
| 8216 | ret = 1; |
| 8217 | } |
no test coverage detected