summaryrefslogtreecommitdiff
path: root/valid.c
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2005-09-05 17:10:35 +0000
committerMike Hommey <glandium@debian.org>2005-09-05 17:10:35 +0000
commita464d9993e2acd5b8e1089b218ba74c6fcf215c5 (patch)
tree72fe00eb59147367a1d660b90d08172357e0dffc /valid.c
parent112cb5bb5475afec1c1cbf1d6728ce4880d0fee8 (diff)
downloadlibxml2-a464d9993e2acd5b8e1089b218ba74c6fcf215c5.tar.gz
Load /usr/tmp/tmp.CMoFff/libxml2-2.6.21 intoupstream/2.6.21
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'valid.c')
-rw-r--r--valid.c109
1 files changed, 53 insertions, 56 deletions
diff --git a/valid.c b/valid.c
index ed89c6c..3ee5630 100644
--- a/valid.c
+++ b/valid.c
@@ -453,14 +453,14 @@ nodeVPop(xmlValidCtxtPtr ctxt)
xmlNodePtr ret;
if (ctxt->nodeNr <= 0)
- return (0);
+ return (NULL);
ctxt->nodeNr--;
if (ctxt->nodeNr > 0)
ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
else
ctxt->node = NULL;
ret = ctxt->nodeTab[ctxt->nodeNr];
- ctxt->nodeTab[ctxt->nodeNr] = 0;
+ ctxt->nodeTab[ctxt->nodeNr] = NULL;
return (ret);
}
@@ -2703,8 +2703,12 @@ xmlFreeIDTable(xmlIDTablePtr table) {
*/
int
xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
+ if ((attr == NULL) || (attr->name == NULL)) return(0);
+ if ((attr->ns != NULL) && (attr->ns->prefix != NULL) &&
+ (!strcmp((char *) attr->name, "id")) &&
+ (!strcmp((char *) attr->ns->prefix, "xml")))
+ return(1);
if (doc == NULL) return(0);
- if (attr == NULL) return(0);
if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
return(0);
} else if (doc->type == XML_HTML_DOCUMENT_NODE) {
@@ -2713,32 +2717,35 @@ xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
((elem != NULL) && (!xmlStrEqual(elem->name, BAD_CAST "input"))))
return(1);
return(0);
+ } else if (elem == NULL) {
+ return(0);
} else {
- xmlAttributePtr attrDecl;
+ xmlAttributePtr attrDecl = NULL;
- if (elem == NULL) return(0);
- if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
- xmlChar fn[50];
- xmlChar *fullname;
-
- fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
- if (fullname == NULL)
- return(0);
- attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname,
- attr->name);
- if ((attrDecl == NULL) && (doc->extSubset != NULL))
- attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname,
- attr->name);
- if ((fullname != fn) && (fullname != elem->name))
- xmlFree(fullname);
- } else {
- attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name,
- attr->name);
+ xmlChar felem[50], fattr[50];
+ xmlChar *fullelemname, *fullattrname;
+
+ fullelemname = (elem->ns != NULL && elem->ns->prefix != NULL) ?
+ xmlBuildQName(elem->name, elem->ns->prefix, felem, 50) :
+ (xmlChar *)elem->name;
+
+ fullattrname = (attr->ns != NULL && attr->ns->prefix != NULL) ?
+ xmlBuildQName(attr->name, attr->ns->prefix, fattr, 50) :
+ (xmlChar *)attr->name;
+
+ if (fullelemname != NULL && fullattrname != NULL) {
+ attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullelemname,
+ fullattrname);
if ((attrDecl == NULL) && (doc->extSubset != NULL))
- attrDecl = xmlGetDtdAttrDesc(doc->extSubset, elem->name,
- attr->name);
+ attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullelemname,
+ fullattrname);
}
+ if ((fullattrname != fattr) && (fullattrname != attr->name))
+ xmlFree(fullattrname);
+ if ((fullelemname != felem) && (fullelemname != elem->name))
+ xmlFree(fullelemname);
+
if ((attrDecl != NULL) && (attrDecl->atype == XML_ATTRIBUTE_ID))
return(1);
}
@@ -3866,7 +3873,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
if (fullname == NULL)
- return(0);
+ return(NULL);
attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name);
if ((attrDecl == NULL) && (doc->extSubset != NULL)) {
attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name);
@@ -3951,7 +3958,7 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
if (fullname == NULL)
- return(0);
+ return(NULL);
attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name);
if ((attrDecl == NULL) && (doc->extSubset != NULL))
attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name);
@@ -5857,24 +5864,12 @@ xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
NULL,NULL,NULL);
return(0);
}
- if (elem->properties != NULL) {
- xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
- "Text element has attribute !\n",
- NULL,NULL,NULL);
- return(0);
- }
if (elem->ns != NULL) {
xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
"Text element has namespace !\n",
NULL,NULL,NULL);
return(0);
}
- if (elem->nsDef != NULL) {
- xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
- "Text element has namespace !\n",
- NULL,NULL,NULL);
- return(0);
- }
if (elem->content == NULL) {
xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
"Text element has no content !\n",
@@ -6299,23 +6294,25 @@ xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) {
}
ret &= xmlValidateOneElement(ctxt, doc, elem);
- attr = elem->properties;
- while (attr != NULL) {
- value = xmlNodeListGetString(doc, attr->children, 0);
- ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value);
- if (value != NULL)
- xmlFree((char *)value);
- attr= attr->next;
- }
- ns = elem->nsDef;
- while (ns != NULL) {
- if (elem->ns == NULL)
- ret &= xmlValidateOneNamespace(ctxt, doc, elem, NULL,
- ns, ns->href);
- else
- ret &= xmlValidateOneNamespace(ctxt, doc, elem, elem->ns->prefix,
- ns, ns->href);
- ns = ns->next;
+ if (elem->type == XML_ELEMENT_NODE) {
+ attr = elem->properties;
+ while (attr != NULL) {
+ value = xmlNodeListGetString(doc, attr->children, 0);
+ ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value);
+ if (value != NULL)
+ xmlFree((char *)value);
+ attr= attr->next;
+ }
+ ns = elem->nsDef;
+ while (ns != NULL) {
+ if (elem->ns == NULL)
+ ret &= xmlValidateOneNamespace(ctxt, doc, elem, NULL,
+ ns, ns->href);
+ else
+ ret &= xmlValidateOneNamespace(ctxt, doc, elem,
+ elem->ns->prefix, ns, ns->href);
+ ns = ns->next;
+ }
}
child = elem->children;
while (child != NULL) {
@@ -6808,7 +6805,7 @@ xmlValidGetPotentialChildren(xmlElementContent *ctree, const xmlChar **list,
/*
* Dummy function to suppress messages while we try out valid elements
*/
-static void xmlNoValidityErr(void *ctx ATTRIBUTE_UNUSED,
+static void XMLCDECL xmlNoValidityErr(void *ctx ATTRIBUTE_UNUSED,
const char *msg ATTRIBUTE_UNUSED, ...) {
return;
}