summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2009-09-24 11:31:48 +0200
committerDaniel Veillard <veillard@redhat.com>2009-09-24 11:31:48 +0200
commitaa422d9254f373141428bf0879f08af7ad15f3bf (patch)
tree92c876b2c85ad43312bd327178c2c38e04cf766a
parent4dd115c197f4d1978014290f62f81467bf88e25f (diff)
downloadlibxml2-aa422d9254f373141428bf0879f08af7ad15f3bf.tar.gz
595792 fixing a RelaxNG bug introduced in 2.7.4
* relaxng.c: refs definitions added from inported schemas should not be processed as refs from the main schemas * test/relaxng/595792* result/relaxng/595792*: add the test to the regression suite
-rw-r--r--relaxng.c9
-rw-r--r--result/relaxng/595792-ext_err1
-rw-r--r--result/relaxng/595792-ext_valid0
-rw-r--r--result/relaxng/595792_00
-rw-r--r--result/relaxng/595792_0.err1
-rw-r--r--result/relaxng/595792_err1
-rw-r--r--result/relaxng/595792_valid0
-rw-r--r--test/relaxng/595792-ext.rng11
-rw-r--r--test/relaxng/595792.rng8
-rw-r--r--test/relaxng/595792_0.xml4
10 files changed, 35 insertions, 0 deletions
diff --git a/relaxng.c b/relaxng.c
index d124d72f..075fc4a2 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -149,6 +149,7 @@ typedef enum {
#define IS_PROCESSED (1 << 5)
#define IS_COMPILABLE (1 << 6)
#define IS_NOT_COMPILABLE (1 << 7)
+#define IS_EXTERNAL_REF (1 << 8)
struct _xmlRelaxNGDefine {
xmlRelaxNGType type; /* the type of definition */
@@ -4662,6 +4663,8 @@ xmlRelaxNGParseImportRef(void *payload, void *data, xmlChar *name) {
xmlRelaxNGDefinePtr def = (xmlRelaxNGDefinePtr) payload;
int tmp;
+ def->dflags |= IS_EXTERNAL_REF;
+
tmp = xmlHashAddEntry(ctxt->grammar->refs, name, def);
if (tmp < 0) {
xmlRelaxNGDefinePtr prev;
@@ -5668,6 +5671,12 @@ xmlRelaxNGCheckReference(xmlRelaxNGDefinePtr ref,
xmlRelaxNGGrammarPtr grammar;
xmlRelaxNGDefinePtr def, cur;
+ /*
+ * Those rules don't apply to imported ref from xmlRelaxNGParseImportRef
+ */
+ if (ref->dflags & IS_EXTERNAL_REF)
+ return;
+
grammar = ctxt->grammar;
if (grammar == NULL) {
xmlRngPErr(ctxt, ref->node, XML_ERR_INTERNAL_ERROR,
diff --git a/result/relaxng/595792-ext_err b/result/relaxng/595792-ext_err
new file mode 100644
index 00000000..092fdbd1
--- /dev/null
+++ b/result/relaxng/595792-ext_err
@@ -0,0 +1 @@
+./test/relaxng/595792-ext.rng validates
diff --git a/result/relaxng/595792-ext_valid b/result/relaxng/595792-ext_valid
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/result/relaxng/595792-ext_valid
diff --git a/result/relaxng/595792_0 b/result/relaxng/595792_0
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/result/relaxng/595792_0
diff --git a/result/relaxng/595792_0.err b/result/relaxng/595792_0.err
new file mode 100644
index 00000000..abd73cdc
--- /dev/null
+++ b/result/relaxng/595792_0.err
@@ -0,0 +1 @@
+./test/relaxng/595792_0.xml validates
diff --git a/result/relaxng/595792_err b/result/relaxng/595792_err
new file mode 100644
index 00000000..e9f3192e
--- /dev/null
+++ b/result/relaxng/595792_err
@@ -0,0 +1 @@
+./test/relaxng/595792.rng validates
diff --git a/result/relaxng/595792_valid b/result/relaxng/595792_valid
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/result/relaxng/595792_valid
diff --git a/test/relaxng/595792-ext.rng b/test/relaxng/595792-ext.rng
new file mode 100644
index 00000000..58990cbb
--- /dev/null
+++ b/test/relaxng/595792-ext.rng
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0">
+ <start>
+ <element name="t">
+ <ref name="tcont"/>
+ </element>
+ </start>
+ <define name="tcont">
+ <text/>
+ </define>
+</grammar>
diff --git a/test/relaxng/595792.rng b/test/relaxng/595792.rng
new file mode 100644
index 00000000..fb2eb933
--- /dev/null
+++ b/test/relaxng/595792.rng
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0">
+ <start>
+ <element name="root">
+ <externalRef href="595792-ext.rng"/>
+ </element>
+ </start>
+</grammar>
diff --git a/test/relaxng/595792_0.xml b/test/relaxng/595792_0.xml
new file mode 100644
index 00000000..546c5897
--- /dev/null
+++ b/test/relaxng/595792_0.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<root>
+ <t>foo</t>
+</root>