[libxml2] 582906 XSD validating multiple imports of the same schema
- From: Daniel Veillard <veillard src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libxml2] 582906 XSD validating multiple imports of the same schema
- Date: Fri, 7 Aug 2009 18:32:33 +0000 (UTC)
commit edc68aadf84f6acc4acdb85f827a90132d7ab831
Author: Jason Childs <oblivian users sourceforge net>
Date: Fri Aug 7 20:29:33 2009 +0200
582906 XSD validating multiple imports of the same schema
* xmlschemas.c: When validating a schema that includes the same file
that has no targetNamespace defined an internal erro was thrown,
depending on the orig namespace that should be allowed though
* test/schemas/582906-* result/schemas/582906-*: 2 tests case, one
where this is allowed, and one where this is forbidden
result/schemas/582906-1_0_0 | 1 +
result/schemas/582906-2_0_0.err | 1 +
test/schemas/582906-1-common.xsd | 6 ++++++
test/schemas/582906-1-prog1.xsd | 11 +++++++++++
test/schemas/582906-1-prog2-include.xsd | 9 +++++++++
test/schemas/582906-1-prog2.xsd | 13 +++++++++++++
test/schemas/582906-1_0.xml | 5 +++++
test/schemas/582906-1_0.xsd | 20 ++++++++++++++++++++
test/schemas/582906-2-common.xsd | 7 +++++++
test/schemas/582906-2-prog1.xsd | 11 +++++++++++
test/schemas/582906-2-prog2-include.xsd | 9 +++++++++
test/schemas/582906-2-prog2.xsd | 13 +++++++++++++
test/schemas/582906-2_0.xml | 5 +++++
test/schemas/582906-2_0.xsd | 20 ++++++++++++++++++++
xmlschemas.c | 17 +++++++++--------
15 files changed, 140 insertions(+), 8 deletions(-)
---
diff --git a/result/schemas/582906-1_0_0 b/result/schemas/582906-1_0_0
new file mode 100644
index 0000000..e1abbf5
--- /dev/null
+++ b/result/schemas/582906-1_0_0
@@ -0,0 +1 @@
+./test/schemas/582906-1_0.xml validates
diff --git a/result/schemas/582906-1_0_0.err b/result/schemas/582906-1_0_0.err
new file mode 100644
index 0000000..e69de29
diff --git a/result/schemas/582906-2_0_0 b/result/schemas/582906-2_0_0
new file mode 100644
index 0000000..e69de29
diff --git a/result/schemas/582906-2_0_0.err b/result/schemas/582906-2_0_0.err
new file mode 100644
index 0000000..c1f8204
--- /dev/null
+++ b/result/schemas/582906-2_0_0.err
@@ -0,0 +1 @@
+test/schemas/582906-2-prog1.xsd:9: element include: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}include': The target namespace 'http://example.com/xml/Prog3' of the included/redefined schema 'test/schemas/582906-2-common.xsd' differs from 'http://example.com/xml/Prog1' of the including/redefining schema.
diff --git a/test/schemas/582906-1-common.xsd b/test/schemas/582906-1-common.xsd
new file mode 100644
index 0000000..aa7cbda
--- /dev/null
+++ b/test/schemas/582906-1-common.xsd
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+</xs:schema>
diff --git a/test/schemas/582906-1-prog1.xsd b/test/schemas/582906-1-prog1.xsd
new file mode 100644
index 0000000..33dde56
--- /dev/null
+++ b/test/schemas/582906-1-prog1.xsd
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns="http://example.com/xml/Prog1"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ targetNamespace="http://example.com/xml/Prog1">
+
+ <xs:include schemaLocation="582906-1-common.xsd"/>
+
+</xs:schema>
diff --git a/test/schemas/582906-1-prog2-include.xsd b/test/schemas/582906-1-prog2-include.xsd
new file mode 100644
index 0000000..8701cfc
--- /dev/null
+++ b/test/schemas/582906-1-prog2-include.xsd
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified" attributeFormDefault="unqualified"
+ xml:lang="en">
+
+ <xs:include schemaLocation="582906-1-common.xsd"/>
+
+</xs:schema>
diff --git a/test/schemas/582906-1-prog2.xsd b/test/schemas/582906-1-prog2.xsd
new file mode 100644
index 0000000..4528fff
--- /dev/null
+++ b/test/schemas/582906-1-prog2.xsd
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns="http://example.com/xml/Prog2"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ targetNamespace="http://example.com/xml/Prog2">
+
+ <xs:include schemaLocation="582906-1-common.xsd"/>
+
+ <xs:include schemaLocation="582906-1-prog2-include.xsd"/>
+
+</xs:schema>
diff --git a/test/schemas/582906-1_0.xml b/test/schemas/582906-1_0.xml
new file mode 100644
index 0000000..311d85f
--- /dev/null
+++ b/test/schemas/582906-1_0.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CollectedOutput xmlns="http://example.com/xml/Aggregator"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://example.com/xml/Aggregator
+ 582906-1.xsd">5.3</CollectedOutput>
diff --git a/test/schemas/582906-1_0.xsd b/test/schemas/582906-1_0.xsd
new file mode 100644
index 0000000..578f5a4
--- /dev/null
+++ b/test/schemas/582906-1_0.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns="http://example.com/xml/Aggregator"
+ xmlns:prog1="http://example.com/xml/Prog1"
+ xmlns:prog2="http://example.com/xml/Prog2"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ targetNamespace="http://example.com/xml/Aggregator">
+
+ <xs:import schemaLocation="582906-1-prog1.xsd"
+ namespace="http://example.com/xml/Prog1" />
+
+ <xs:import schemaLocation="582906-1-prog2.xsd"
+ namespace="http://example.com/xml/Prog2"
+ />
+
+ <xs:element name="CollectedOutput" type="xs:float"/>
+
+</xs:schema>
diff --git a/test/schemas/582906-2-common.xsd b/test/schemas/582906-2-common.xsd
new file mode 100644
index 0000000..c3b8c37
--- /dev/null
+++ b/test/schemas/582906-2-common.xsd
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ targetNamespace="http://example.com/xml/Prog3">
+</xs:schema>
diff --git a/test/schemas/582906-2-prog1.xsd b/test/schemas/582906-2-prog1.xsd
new file mode 100644
index 0000000..5cd2d41
--- /dev/null
+++ b/test/schemas/582906-2-prog1.xsd
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns="http://example.com/xml/Prog1"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ targetNamespace="http://example.com/xml/Prog1">
+
+ <xs:include schemaLocation="582906-2-common.xsd"/>
+
+</xs:schema>
diff --git a/test/schemas/582906-2-prog2-include.xsd b/test/schemas/582906-2-prog2-include.xsd
new file mode 100644
index 0000000..4985aa3
--- /dev/null
+++ b/test/schemas/582906-2-prog2-include.xsd
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified" attributeFormDefault="unqualified"
+ xml:lang="en">
+
+ <xs:include schemaLocation="582906-2-common.xsd"/>
+
+</xs:schema>
diff --git a/test/schemas/582906-2-prog2.xsd b/test/schemas/582906-2-prog2.xsd
new file mode 100644
index 0000000..9446f21
--- /dev/null
+++ b/test/schemas/582906-2-prog2.xsd
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns="http://example.com/xml/Prog2"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ targetNamespace="http://example.com/xml/Prog2">
+
+ <xs:include schemaLocation="582906-2-common.xsd"/>
+
+ <xs:include schemaLocation="582906-2-prog2-include.xsd"/>
+
+</xs:schema>
diff --git a/test/schemas/582906-2_0.xml b/test/schemas/582906-2_0.xml
new file mode 100644
index 0000000..e928957
--- /dev/null
+++ b/test/schemas/582906-2_0.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CollectedOutput xmlns="http://example.com/xml/Aggregator"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://example.com/xml/Aggregator
+ 582906-2-0.xsd">5.3</CollectedOutput>
diff --git a/test/schemas/582906-2_0.xsd b/test/schemas/582906-2_0.xsd
new file mode 100644
index 0000000..e62ebb8
--- /dev/null
+++ b/test/schemas/582906-2_0.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id$ -->
+<xs:schema xmlns="http://example.com/xml/Aggregator"
+ xmlns:prog1="http://example.com/xml/Prog1"
+ xmlns:prog2="http://example.com/xml/Prog2"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ targetNamespace="http://example.com/xml/Aggregator">
+
+ <xs:import schemaLocation="582906-2-prog1.xsd"
+ namespace="http://example.com/xml/Prog1" />
+
+ <xs:import schemaLocation="582906-2-prog2.xsd"
+ namespace="http://example.com/xml/Prog2"
+ />
+
+ <xs:element name="CollectedOutput" type="xs:float"/>
+
+</xs:schema>
diff --git a/xmlschemas.c b/xmlschemas.c
index e621120..70fe3eb 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -11039,14 +11039,15 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
*/
isChameleon = 1;
if (bucket->parsed &&
- (bucket->targetNamespace != pctxt->targetNamespace)) {
- /*
- * This is a sanity check, I dunno yet if this can happen.
- */
- PERROR_INT("xmlSchemaParseIncludeOrRedefine",
- "trying to use an already parsed schema for a "
- "different targetNamespace");
- return(-1);
+ bucket->origTargetNamespace != NULL) {
+ xmlSchemaCustomErr(ACTXT_CAST pctxt,
+ XML_SCHEMAP_SRC_INCLUDE,
+ node, NULL,
+ "The target namespace of the included/redefined schema "
+ "'%s' has to be absent or the same as the "
+ "including/redefining schema's target namespace",
+ schemaLocation, NULL);
+ goto exit_error;
}
bucket->targetNamespace = pctxt->targetNamespace;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]