fixed bug #120386 again a problem introduced when trying to reuse automata
* relaxng.c: fixed bug #120386 again a problem introduced when
trying to reuse automata for content validation. Fix a bug report
problem on zeroOrMore
* result/relaxng/tutor3_7_err: change slightly error reporting.
Daniel
diff --git a/relaxng.c b/relaxng.c
index cdcc079..28d1a60 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -365,6 +365,8 @@
int pstate; /* progressive state */
xmlNodePtr pnode; /* the current node */
xmlRelaxNGDefinePtr pdef; /* the non-streamable definition */
+ int perr; /* signal error in content model
+ outside the regexp */
};
/**
@@ -7690,6 +7692,8 @@
return;
}
ret = xmlRelaxNGValidateDefinition(ctxt, define);
+ if (ret != 0)
+ ctxt->perr = ret;
}
/**
@@ -7708,11 +7712,13 @@
xmlRegExecCtxtPtr exec;
xmlNodePtr cur;
int ret = 0;
+ int oldperr = ctxt->perr;
if ((ctxt == NULL) || (regexp == NULL))
return(-1);
exec = xmlRegNewExecCtxt(regexp,
xmlRelaxNGValidateCompiledCallback, ctxt);
+ ctxt->perr = 0;
cur = content;
while (cur != NULL) {
ctxt->state->seq = cur;
@@ -7762,6 +7768,14 @@
ret = -1;
}
xmlRegFreeExecCtxt(exec);
+ /*
+ * There might be content model errors outside of the pure
+ * regexp validation, e.g. for attribute values.
+ */
+ if ((ret == 0) && (ctxt->perr != 0)) {
+ ret = ctxt->perr;
+ }
+ ctxt->perr = oldperr;
return(ret);
}
@@ -9777,8 +9791,13 @@
}
ctxt->states = res;
ctxt->flags = oldflags;
+#if 0
+ /*
+ * errors may have to be propagated back...
+ */
if (ctxt->errNr > errNr)
xmlRelaxNGPopErrors(ctxt, errNr);
+#endif
ret = 0;
break;
}