[libxml2] Look inside divs for starts and defines inside include



commit 4338c310eb5e9402d0d4bf1cdf6d60430ac8a9a8
Author: Nikolai Weibull <now disu se>
Date:   Fri Oct 12 22:30:26 2018 +0200

    Look inside divs for starts and defines inside include
    
    RELAX NG allows for div elements inside of include elements.  We need to look
    inside those div elements for start and define elements that may be redefining
    start and define elements in the included grammar.

 relaxng.c                     | 13 ++++++++++++-
 result/relaxng/include0_0     |  0
 result/relaxng/include0_0.err |  1 +
 result/relaxng/include0_err   |  1 +
 result/relaxng/include0_valid |  0
 test/relaxng/include0.inc     |  5 +++++
 test/relaxng/include0.rng     | 11 +++++++++++
 test/relaxng/include0_0.xml   |  1 +
 8 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/relaxng.c b/relaxng.c
index 4be131d7..a3088cbd 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -1739,7 +1739,18 @@ xmlRelaxNGLoadInclude(xmlRelaxNGParserCtxtPtr ctxt, const xmlChar * URL,
                 xmlFree(name);
             }
         }
-        cur = cur->next;
+        if (IS_RELAXNG(cur, "div") && cur->children != NULL) {
+            cur = cur->children;
+        } else {
+            if (cur->next != NULL) {
+                cur = cur->next;
+            } else {
+                while (cur->parent != node && cur->parent->next == NULL) {
+                    cur = cur->parent;
+                }
+                cur = cur->parent != node ? cur->parent->next : NULL;
+            }
+        }
     }
 
 
diff --git a/result/relaxng/include0_0 b/result/relaxng/include0_0
new file mode 100644
index 00000000..e69de29b
diff --git a/result/relaxng/include0_0.err b/result/relaxng/include0_0.err
new file mode 100644
index 00000000..24013bc5
--- /dev/null
+++ b/result/relaxng/include0_0.err
@@ -0,0 +1 @@
+./test/relaxng/include0_0.xml validates
diff --git a/result/relaxng/include0_err b/result/relaxng/include0_err
new file mode 100644
index 00000000..cd16cbe2
--- /dev/null
+++ b/result/relaxng/include0_err
@@ -0,0 +1 @@
+./test/relaxng/include0.rng validates
diff --git a/result/relaxng/include0_valid b/result/relaxng/include0_valid
new file mode 100644
index 00000000..e69de29b
diff --git a/test/relaxng/include0.inc b/test/relaxng/include0.inc
new file mode 100644
index 00000000..8636ee4e
--- /dev/null
+++ b/test/relaxng/include0.inc
@@ -0,0 +1,5 @@
+<grammar xmlns="http://relaxng.org/ns/structure/1.0";>
+  <start>
+    <notAllowed/>
+  </start>
+</grammar>
diff --git a/test/relaxng/include0.rng b/test/relaxng/include0.rng
new file mode 100644
index 00000000..e8edb92f
--- /dev/null
+++ b/test/relaxng/include0.rng
@@ -0,0 +1,11 @@
+<grammar xmlns="http://relaxng.org/ns/structure/1.0";>
+  <include href="include0.inc">
+    <div>
+      <start>
+        <element name="root">
+          <empty/>
+        </element>
+      </start>
+    </div>
+  </include>
+</grammar>
diff --git a/test/relaxng/include0_0.xml b/test/relaxng/include0_0.xml
new file mode 100644
index 00000000..f3f286ea
--- /dev/null
+++ b/test/relaxng/include0_0.xml
@@ -0,0 +1 @@
+<root/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]