Permalink
Browse files

Fix an unimplemented part in RNG value validation

Forgot to implement <optional> this was raised again
in https://bugzilla.redhat.com/show_bug.cgi?id=752393
as this make libxml2 fail to validate against ODF RNGs

Daniel
  • Loading branch information...
1 parent 1d4526f commit 7dd0d916c6a92ca4a398b8bc56fb0d7f98df00b6 @veillard veillard committed Nov 10, 2011
Showing with 29 additions and 0 deletions.
  1. +29 −0 relaxng.c
View
@@ -8884,6 +8884,11 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
case XML_RELAXNG_ZEROORMORE:{
xmlChar *cur, *temp;
+ if ((ctxt->state->value == NULL) ||
+ (*ctxt->state->value == 0)) {
+ ret = 0;
+ break;
+ }
oldflags = ctxt->flags;
ctxt->flags |= FLAGS_IGNORABLE;
cur = ctxt->state->value;
@@ -8905,6 +8910,30 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGPopErrors(ctxt, 0);
break;
}
+ case XML_RELAXNG_OPTIONAL:{
+ xmlChar *temp;
+
+ if ((ctxt->state->value == NULL) ||
+ (*ctxt->state->value == 0)) {
+ ret = 0;
+ break;
+ }
+ oldflags = ctxt->flags;
+ ctxt->flags |= FLAGS_IGNORABLE;
+ temp = ctxt->state->value;
+ ret = xmlRelaxNGValidateValue(ctxt, define->content);
+ ctxt->flags = oldflags;
+ if (ret != 0) {
+ ctxt->state->value = temp;
+ if (ctxt->errNr > 0)
+ xmlRelaxNGPopErrors(ctxt, 0);
+ ret = 0;
+ break;
+ }
+ if (ctxt->errNr > 0)
+ xmlRelaxNGPopErrors(ctxt, 0);
+ break;
+ }
case XML_RELAXNG_EXCEPT:{
xmlRelaxNGDefinePtr list;

0 comments on commit 7dd0d91

Please sign in to comment.