* xmlRelaxNGValidateDefinition: * @ctxt: a Relax-NG validation context * @define: the definition to verify * * Validate the current node lists against the definition * * Returns 0 if the validation succeeded or an error code. */
| 10380 | * Returns 0 if the validation succeeded or an error code. |
| 10381 | */ |
| 10382 | static int |
| 10383 | xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt, |
| 10384 | xmlRelaxNGDefinePtr define) |
| 10385 | { |
| 10386 | xmlRelaxNGStatesPtr states, res; |
| 10387 | int i, j, k, ret, oldflags; |
| 10388 | |
| 10389 | /* |
| 10390 | * We should NOT have both ctxt->state and ctxt->states |
| 10391 | */ |
| 10392 | if ((ctxt->state != NULL) && (ctxt->states != NULL)) { |
| 10393 | /* TODO */ |
| 10394 | xmlRelaxNGFreeValidState(ctxt, ctxt->state); |
| 10395 | ctxt->state = NULL; |
| 10396 | } |
| 10397 | |
| 10398 | if ((ctxt->states == NULL) || (ctxt->states->nbState == 1)) { |
| 10399 | if (ctxt->states != NULL) { |
| 10400 | ctxt->state = ctxt->states->tabState[0]; |
| 10401 | xmlRelaxNGFreeStates(ctxt, ctxt->states); |
| 10402 | ctxt->states = NULL; |
| 10403 | } |
| 10404 | ret = xmlRelaxNGValidateState(ctxt, define); |
| 10405 | if ((ctxt->state != NULL) && (ctxt->states != NULL)) { |
| 10406 | /* TODO */ |
| 10407 | xmlRelaxNGFreeValidState(ctxt, ctxt->state); |
| 10408 | ctxt->state = NULL; |
| 10409 | } |
| 10410 | if ((ctxt->states != NULL) && (ctxt->states->nbState == 1)) { |
| 10411 | ctxt->state = ctxt->states->tabState[0]; |
| 10412 | xmlRelaxNGFreeStates(ctxt, ctxt->states); |
| 10413 | ctxt->states = NULL; |
| 10414 | } |
| 10415 | return (ret); |
| 10416 | } |
| 10417 | |
| 10418 | states = ctxt->states; |
| 10419 | ctxt->states = NULL; |
| 10420 | res = NULL; |
| 10421 | j = 0; |
| 10422 | oldflags = ctxt->flags; |
| 10423 | ctxt->flags |= FLAGS_IGNORABLE; |
| 10424 | for (i = 0; i < states->nbState; i++) { |
| 10425 | ctxt->state = states->tabState[i]; |
| 10426 | ctxt->states = NULL; |
| 10427 | ret = xmlRelaxNGValidateState(ctxt, define); |
| 10428 | /* |
| 10429 | * We should NOT have both ctxt->state and ctxt->states |
| 10430 | */ |
| 10431 | if ((ctxt->state != NULL) && (ctxt->states != NULL)) { |
| 10432 | /* TODO */ |
| 10433 | xmlRelaxNGFreeValidState(ctxt, ctxt->state); |
| 10434 | ctxt->state = NULL; |
| 10435 | } |
| 10436 | if (ret == 0) { |
| 10437 | if (ctxt->states == NULL) { |
| 10438 | if (res != NULL) { |
| 10439 | /* add the state to the container */ |
no test coverage detected