mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-15 23:24:06 +03:00
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
This commit is contained in:
parent
fc97906edf
commit
ebcdebd638
@ -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:
|
||||
|
1
result/schemas/ns1_0_0
Normal file
1
result/schemas/ns1_0_0
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/ns1_0.xml validates
|
0
result/schemas/ns1_0_0.err
Normal file
0
result/schemas/ns1_0_0.err
Normal file
1
result/schemas/ns2_0_0
Normal file
1
result/schemas/ns2_0_0
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/ns2_0.xml validates
|
0
result/schemas/ns2_0_0.err
Normal file
0
result/schemas/ns2_0_0.err
Normal file
2
test/schemas/ns1_0.xml
Normal file
2
test/schemas/ns1_0.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<my xmlns='http://my.ns/'
|
||||
>some</my>
|
3
test/schemas/ns1_0.xsd
Normal file
3
test/schemas/ns1_0.xsd
Normal file
@ -0,0 +1,3 @@
|
||||
<schema xmlns='http://www.w3.org/2001/XMLSchema' targetNamespace='http://my.ns/'>
|
||||
<element name='my' type='string'/>
|
||||
</schema>
|
1
test/schemas/ns2_0.xml
Normal file
1
test/schemas/ns2_0.xml
Normal file
@ -0,0 +1 @@
|
||||
<m:my xmlns:m='http://my.ns/' m:other='1'>content</m:my>
|
15
test/schemas/ns2_0.xsd
Normal file
15
test/schemas/ns2_0.xsd
Normal file
@ -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>
|
@ -17,7 +17,7 @@ Purchase order schema for Example.com.
|
||||
<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 @@ Purchase order schema for Example.com.
|
||||
<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>
|
||||
|
19
xmlschemas.c
19
xmlschemas.c
@ -1492,6 +1492,13 @@ xmlGetQNameProp(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
|
||||
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 @@ xmlSchemaParseAttribute(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
"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 @@ xmlSchemaParseAttribute(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
(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 @@ xmlSchemaParseAttributeGroup(xmlSchemaParserCtxtPtr ctxt,
|
||||
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 @@ xmlSchemaParseElement(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
"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 @@ xmlSchemaParseElement(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
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 @@ xmlSchemaParseList(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
|
||||
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")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user