QName handling fixes for the XML Schemas support from Adam Dickmeiss also
* xmlschemas.c: QName handling fixes for the XML Schemas
support from Adam Dickmeiss
* test/schemas/po1_0.xsd: also fix the schemas
* test/schemas/ns[12]* result/schemas/ns[12]*: added the specific
regression tests
Daniel
diff --git a/ChangeLog b/ChangeLog
index 3e1dfb4..04b51af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Mar 5 01:13:22 CET 2004 Daniel Veillard <daniel@veillard.com>
+
+ * xmlschemas.c: QName handling fixes for the XML Schemas
+ support from Adam Dickmeiss
+ * test/schemas/po1_0.xsd: also fix the schemas
+ * test/schemas/ns[12]* result/schemas/ns[12]*: added the specific
+ regression tests
+
Thu Mar 4 23:03:02 CET 2004 Daniel Veillard <daniel@veillard.com>
* configure.in doc/Makefile.am include/libxml/Makefile.am:
diff --git a/result/schemas/ns1_0_0 b/result/schemas/ns1_0_0
new file mode 100644
index 0000000..ffcfb6c
--- /dev/null
+++ b/result/schemas/ns1_0_0
@@ -0,0 +1 @@
+./test/schemas/ns1_0.xml validates
diff --git a/result/schemas/ns1_0_0.err b/result/schemas/ns1_0_0.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/result/schemas/ns1_0_0.err
diff --git a/result/schemas/ns2_0_0 b/result/schemas/ns2_0_0
new file mode 100644
index 0000000..b2c181e
--- /dev/null
+++ b/result/schemas/ns2_0_0
@@ -0,0 +1 @@
+./test/schemas/ns2_0.xml validates
diff --git a/result/schemas/ns2_0_0.err b/result/schemas/ns2_0_0.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/result/schemas/ns2_0_0.err
diff --git a/test/schemas/ns1_0.xml b/test/schemas/ns1_0.xml
new file mode 100644
index 0000000..410ed26
--- /dev/null
+++ b/test/schemas/ns1_0.xml
@@ -0,0 +1,2 @@
+<my xmlns='http://my.ns/'
+>some</my>
diff --git a/test/schemas/ns1_0.xsd b/test/schemas/ns1_0.xsd
new file mode 100644
index 0000000..a77ec57
--- /dev/null
+++ b/test/schemas/ns1_0.xsd
@@ -0,0 +1,3 @@
+<schema xmlns='http://www.w3.org/2001/XMLSchema' targetNamespace='http://my.ns/'>
+ <element name='my' type='string'/>
+</schema>
diff --git a/test/schemas/ns2_0.xml b/test/schemas/ns2_0.xml
new file mode 100644
index 0000000..c3bb126
--- /dev/null
+++ b/test/schemas/ns2_0.xml
@@ -0,0 +1 @@
+<m:my xmlns:m='http://my.ns/' m:other='1'>content</m:my>
diff --git a/test/schemas/ns2_0.xsd b/test/schemas/ns2_0.xsd
new file mode 100644
index 0000000..9393beb
--- /dev/null
+++ b/test/schemas/ns2_0.xsd
@@ -0,0 +1,15 @@
+<schema xmlns:my='http://my.ns/'
+ xmlns='http://www.w3.org/2001/XMLSchema'
+ targetNamespace='http://my.ns/'
+ >
+ <attribute name='other' type='string'/>
+ <element name='my'>
+ <complexType>
+ <simpleContent>
+ <extension base='string'>
+ <attribute ref='my:other'/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+</schema>
diff --git a/test/schemas/po1_0.xsd b/test/schemas/po1_0.xsd
index 81ffd44..84f45a7 100644
--- a/test/schemas/po1_0.xsd
+++ b/test/schemas/po1_0.xsd
@@ -17,7 +17,7 @@
<xsd:element name="shipTo" type="po:USAddress"/>
<xsd:element name="billTo" type="po:USAddress"/>
<xsd:element ref="comment" minOccurs="0"/>
- <xsd:element name="items" type="Items"/>
+ <xsd:element name="items" type="po:Items"/>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
@@ -48,7 +48,7 @@
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
</xsd:sequence>
- <xsd:attribute name="partNum" type="SKU" use="required"/>
+ <xsd:attribute name="partNum" type="po:SKU" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
diff --git a/xmlschemas.c b/xmlschemas.c
index 2266f49..3a3602f 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -1492,6 +1492,13 @@
if (val == NULL)
return (NULL);
+ if (!strchr(val, ':')) {
+ ns = xmlSearchNs(node->doc, node, 0);
+ if (ns) {
+ *namespace = xmlDictLookup(ctxt->dict, ns->href, -1);
+ return (val);
+ }
+ }
ret = xmlSplitQName3(val, &len);
if (ret == NULL) {
return (val);
@@ -2006,8 +2013,6 @@
"Attribute has no name nor ref\n", NULL, NULL);
return (NULL);
}
- if (refNs == NULL)
- refNs = schema->targetNamespace;
snprintf(buf, 99, "anonattr %d", ctxt->counter++ + 1);
name = (const xmlChar *) buf;
ret = xmlSchemaAddAttribute(ctxt, schema, name, NULL);
@@ -2027,8 +2032,6 @@
(xmlStrEqual(ret->targetNamespace, schema->targetNamespace)))
ret->flags |= XML_SCHEMAS_ATTR_NSDEFAULT;
ret->typeName = xmlGetQNameProp(ctxt, node, "type", &(ret->typeNs));
- if ((ret->typeName != NULL) && (ret->typeNs == NULL))
- ret->typeNs = schema->targetNamespace;
ret->node = node;
child = node->children;
if (IS_SCHEMA(child, "annotation")) {
@@ -2084,8 +2087,6 @@
NULL);
return (NULL);
}
- if (refNs == NULL)
- refNs = schema->targetNamespace;
snprintf(buf, 99, "anonattrgroup %d", ctxt->counter++ + 1);
name = (const xmlChar *) buf;
if (name == NULL) {
@@ -2177,8 +2178,6 @@
"Element has no name nor ref\n", NULL, NULL);
return (NULL);
}
- if (refNs == NULL)
- refNs = schema->targetNamespace;
snprintf(buf, 99, "anonelem %d", ctxt->counter++ + 1);
name = (const xmlChar *) buf;
ret = xmlSchemaAddElement(ctxt, schema, name, NULL);
@@ -2209,8 +2208,6 @@
ret->id = xmlSchemaGetProp(ctxt, node, "id");
ret->namedType =
xmlGetQNameProp(ctxt, node, "type", &(ret->namedTypeNs));
- if ((ret->namedType != NULL) && (ret->namedTypeNs == NULL))
- ret->namedTypeNs = schema->targetNamespace;
ret->substGroup =
xmlGetQNameProp(ctxt, node, "substitutionGroup",
&(ret->substGroupNs));
@@ -2345,8 +2342,6 @@
type->type = XML_SCHEMA_TYPE_LIST;
type->id = xmlSchemaGetProp(ctxt, node, "id");
type->ref = xmlGetQNameProp(ctxt, node, "ref", &(type->refNs));
- if ((type->ref != NULL) && (type->refNs == NULL))
- type->refNs = schema->targetNamespace;
child = node->children;
if (IS_SCHEMA(child, "annotation")) {