| 4238 | */ |
| 4239 | |
| 4240 | int |
| 4241 | xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 4242 | xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value) |
| 4243 | { |
| 4244 | xmlAttributePtr attrDecl = NULL; |
| 4245 | const xmlChar *aprefix; |
| 4246 | int val; |
| 4247 | int ret = 1; |
| 4248 | |
| 4249 | CHECK_DTD; |
| 4250 | if ((elem == NULL) || (elem->name == NULL)) return(0); |
| 4251 | if ((attr == NULL) || (attr->name == NULL)) return(0); |
| 4252 | |
| 4253 | aprefix = (attr->ns != NULL) ? attr->ns->prefix : NULL; |
| 4254 | |
| 4255 | if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { |
| 4256 | xmlChar fn[50]; |
| 4257 | xmlChar *fullname; |
| 4258 | |
| 4259 | fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); |
| 4260 | if (fullname == NULL) { |
| 4261 | xmlVErrMemory(ctxt); |
| 4262 | return(0); |
| 4263 | } |
| 4264 | attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname, |
| 4265 | attr->name, aprefix); |
| 4266 | if ((attrDecl == NULL) && (doc->extSubset != NULL)) |
| 4267 | attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname, |
| 4268 | attr->name, aprefix); |
| 4269 | if ((fullname != fn) && (fullname != elem->name)) |
| 4270 | xmlFree(fullname); |
| 4271 | } |
| 4272 | if (attrDecl == NULL) { |
| 4273 | attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, elem->name, |
| 4274 | attr->name, aprefix); |
| 4275 | if ((attrDecl == NULL) && (doc->extSubset != NULL)) |
| 4276 | attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, elem->name, |
| 4277 | attr->name, aprefix); |
| 4278 | } |
| 4279 | |
| 4280 | |
| 4281 | /* Validity Constraint: Attribute Value Type */ |
| 4282 | if (attrDecl == NULL) { |
| 4283 | xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ATTRIBUTE, |
| 4284 | "No declaration for attribute %s of element %s\n", |
| 4285 | attr->name, elem->name, NULL); |
| 4286 | return(0); |
| 4287 | } |
| 4288 | if (attr->atype == XML_ATTRIBUTE_ID) |
| 4289 | xmlRemoveID(doc, attr); |
| 4290 | attr->atype = attrDecl->atype; |
| 4291 | |
| 4292 | val = xmlValidateAttributeValueInternal(doc, attrDecl->atype, value); |
| 4293 | if (val == 0) { |
| 4294 | xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE, |
| 4295 | "Syntax of value for attribute %s of %s is not valid\n", |
| 4296 | attr->name, elem->name, NULL); |
| 4297 | ret = 0; |
no test coverage detected