From 46da8fc5290ed3243d0c137d712a1ed05c489f5f Mon Sep 17 00:00:00 2001 From: Nikolai Weibull Date: Fri, 12 Oct 2018 23:46:24 +0200 Subject: Allow choice within choice in nameClass in RELAX NG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pattern nameClass allows for nested choice elements, for example a b c which is semantically equivalent to a b c The old code didn’t handle this correctly, as it never expected a choice inside another choice. This patch fixes this by flattening any nested choices. This pattern of nested choice elements comes up in RELAX NG simplification, where all choice elements are rewritten in this nested manner, see section 4.12 of the RELAX NG specification. --- relaxng.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'relaxng.c') diff --git a/relaxng.c b/relaxng.c index a3088cbd..8725444b 100644 --- a/relaxng.c +++ b/relaxng.c @@ -5363,11 +5363,15 @@ xmlRelaxNGParseNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, xmlNodePtr child; xmlRelaxNGDefinePtr last = NULL; - ret = xmlRelaxNGNewDefine(ctxt, node); - if (ret == NULL) - return (NULL); - ret->parent = def; - ret->type = XML_RELAXNG_CHOICE; + if (def->type == XML_RELAXNG_CHOICE) { + ret = def; + } else { + ret = xmlRelaxNGNewDefine(ctxt, node); + if (ret == NULL) + return (NULL); + ret->parent = def; + ret->type = XML_RELAXNG_CHOICE; + } if (node->children == NULL) { xmlRngPErr(ctxt, node, XML_RNGP_CHOICE_EMPTY, @@ -5379,7 +5383,7 @@ xmlRelaxNGParseNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, tmp = xmlRelaxNGParseNameClass(ctxt, child, ret); if (tmp != NULL) { if (last == NULL) { - last = ret->nameClass = tmp; + last = tmp; } else { last->next = tmp; last = tmp; -- cgit v1.2.1