Commit e4301c8b authored by Daniel Veillard's avatar Daniel Veillard

fixing a comment fixing some troubles with validity check on namespaces

* include/libxml/entities.h: fixing a comment
* valid.c: fixing some troubles with validity check on namespaces
* result/VC/NS3 test/VC/NS3: added a specific regression test
Daniel
parent a6d05387
Wed Feb 13 14:30:49 CET 2002 Daniel Veillard <daniel@veillard.com>
* include/libxml/entities.h: fixing a comment
* valid.c: fixing some troubles with validity check on namespaces
* result/VC/NS3 test/VC/NS3: added a specific regression test
Wed Feb 13 14:05:24 CET 2002 Daniel Veillard <daniel@veillard.com>
* tree.c: Fixing #71342 serializing '\n' in attribute values
......
......@@ -35,7 +35,7 @@ typedef enum {
struct _xmlEntity {
void *_private; /* application data */
xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
const xmlChar *name; /* Attribute name */
const xmlChar *name; /* Entity name */
struct _xmlNode *children; /* First child link */
struct _xmlNode *last; /* Last child link */
struct _xmlDtd *parent; /* -> DTD */
......
./test/VC/NS3:9: validity error: Element foo namespace name for default namespace does not match the DTD
mlns="http://example.com/foo" xmlns:foo="http://example.com/fo" foo:info="toto"
^
<?xml version="1.0" ?>
<!DOCTYPE foo [
<!ELEMENT foo EMPTY>
<!ATTLIST foo
xmlns CDATA #FIXED "http://example.com/fooo"
xmlns:foo CDATA #REQUIRED
foo:info CDATA #IMPLIED>
]>
<foo xmlns="http://example.com/foo" xmlns:foo="http://example.com/fo" foo:info="toto"/>
......@@ -4369,42 +4369,64 @@ child_ok:
attr = elemDecl->attributes;
while (attr != NULL) {
if (attr->def == XML_ATTRIBUTE_REQUIRED) {
xmlAttrPtr attrib;
int qualified = -1;
attrib = elem->properties;
while (attrib != NULL) {
if (xmlStrEqual(attrib->name, attr->name)) {
if (attr->prefix != NULL) {
xmlNsPtr nameSpace = attrib->ns;
if (nameSpace == NULL)
nameSpace = elem->ns;
/*
* qualified names handling is problematic, having a
* different prefix should be possible but DTDs don't
* allow to define the URI instead of the prefix :-(
*/
if (nameSpace == NULL) {
if (qualified < 0)
qualified = 0;
} else if (!xmlStrEqual(nameSpace->prefix,
attr->prefix)) {
if (qualified < 1)
qualified = 1;
} else
goto found;
} else {
/*
* We should allow applications to define namespaces
* for their application even if the DTD doesn't
* carry one, otherwise, basically we would always
* break.
*/
if ((attr->prefix == NULL) &&
(xmlStrEqual(attr->name, BAD_CAST "xmlns"))) {
xmlNsPtr ns;
ns = elem->nsDef;
while (ns != NULL) {
if (ns->prefix == NULL)
goto found;
ns = ns->next;
}
} else if (xmlStrEqual(attr->prefix, BAD_CAST "xmlns")) {
xmlNsPtr ns;
ns = elem->nsDef;
while (ns != NULL) {
if (xmlStrEqual(attr->name, ns->prefix))
goto found;
ns = ns->next;
}
} else {
xmlAttrPtr attrib;
attrib = elem->properties;
while (attrib != NULL) {
if (xmlStrEqual(attrib->name, attr->name)) {
if (attr->prefix != NULL) {
xmlNsPtr nameSpace = attrib->ns;
if (nameSpace == NULL)
nameSpace = elem->ns;
/*
* qualified names handling is problematic, having a
* different prefix should be possible but DTDs don't
* allow to define the URI instead of the prefix :-(
*/
if (nameSpace == NULL) {
if (qualified < 0)
qualified = 0;
} else if (!xmlStrEqual(nameSpace->prefix,
attr->prefix)) {
if (qualified < 1)
qualified = 1;
} else
goto found;
} else {
/*
* We should allow applications to define namespaces
* for their application even if the DTD doesn't
* carry one, otherwise, basically we would always
* break.
*/
goto found;
}
}
attrib = attrib->next;
}
attrib = attrib->next;
}
if (qualified == -1) {
if (attr->prefix == NULL) {
......@@ -4427,6 +4449,44 @@ child_ok:
"Element %s required attribute %s:%s has different prefix\n",
elem->name, attr->prefix,attr->name);
}
} else if (attr->def == XML_ATTRIBUTE_FIXED) {
/*
* Special tests checking #FIXED namespace declarations
* have the right value since this is not done as an
* attribute checking
*/
if ((attr->prefix == NULL) &&
(xmlStrEqual(attr->name, BAD_CAST "xmlns"))) {
xmlNsPtr ns;
ns = elem->nsDef;
while (ns != NULL) {
if (ns->prefix == NULL) {
if (!xmlStrEqual(attr->defaultValue, ns->href)) {
VERROR(ctxt->userData,
"Element %s namespace name for default namespace does not match the DTD\n",
elem->name);
}
goto found;
}
ns = ns->next;
}
} else if (xmlStrEqual(attr->prefix, BAD_CAST "xmlns")) {
xmlNsPtr ns;
ns = elem->nsDef;
while (ns != NULL) {
if (xmlStrEqual(attr->name, ns->prefix)) {
if (!xmlStrEqual(attr->defaultValue, ns->href)) {
VERROR(ctxt->userData,
"Element %s namespace name for %s doesn't match the DTD\n",
elem->name, ns->prefix);
}
goto found;
}
ns = ns->next;
}
}
}
found:
attr = attr->nexth;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment