[libxml2] Fix handling of XSD with empty namespace
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Fix handling of XSD with empty namespace
- Date: Thu, 3 Feb 2022 22:45:14 +0000 (UTC)
commit 1c7d91abe404333cb29f547ae7e844467befc53a
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Thu Feb 3 23:31:19 2022 +0100
Fix handling of XSD with empty namespace
An empty namespace means no default namespace.
Fixes #303.
result/schemas/issue303_0_0 | 1 +
test/schemas/issue303_0.xml | 1 +
test/schemas/issue303_0.xsd | 19 +++++++++++++++++++
xmlschemas.c | 2 +-
4 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/result/schemas/issue303_0_0 b/result/schemas/issue303_0_0
new file mode 100644
index 00000000..6deaf66f
--- /dev/null
+++ b/result/schemas/issue303_0_0
@@ -0,0 +1 @@
+./test/schemas/issue303_0.xml validates
diff --git a/test/schemas/issue303_0.xml b/test/schemas/issue303_0.xml
new file mode 100644
index 00000000..53bddb28
--- /dev/null
+++ b/test/schemas/issue303_0.xml
@@ -0,0 +1 @@
+<outer> <inner><a>1</a><b>2</b></inner> <c>3</c> </outer>
diff --git a/test/schemas/issue303_0.xsd b/test/schemas/issue303_0.xsd
new file mode 100644
index 00000000..d85efb86
--- /dev/null
+++ b/test/schemas/issue303_0.xsd
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<xs:schema id="foo" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="inner">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="a" type="xs:double" minOccurs="1" />
+ <xs:element name="b" type="xs:double" minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="outer">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="inner" minOccurs="0" maxOccurs="unbounded" />
+ <xs:element name="c" type="xs:double" minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
diff --git a/xmlschemas.c b/xmlschemas.c
index a8019bea..64fe146a 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -5899,7 +5899,7 @@ xmlSchemaPValAttrNodeQNameValue(xmlSchemaParserCtxtPtr ctxt,
if (!strchr((char *) value, ':')) {
ns = xmlSearchNs(attr->doc, attr->parent, NULL);
- if (ns)
+ if (ns && ns->href && ns->href[0])
*uri = xmlDictLookup(ctxt->dict, ns->href, -1);
else if (schema->flags & XML_SCHEMAS_INCLUDING_CONVERT_NS) {
/* TODO: move XML_SCHEMAS_INCLUDING_CONVERT_NS to the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]