| 6526 | #endif /* LIBXML_TREE_ENABLED */ |
| 6527 | |
| 6528 | static xmlAttrPtr |
| 6529 | xmlGetPropNodeInternal(const xmlNode *node, const xmlChar *name, |
| 6530 | const xmlChar *nsName, int useDTD) |
| 6531 | { |
| 6532 | xmlAttrPtr prop; |
| 6533 | |
| 6534 | /* Avoid unused variable warning if features are disabled. */ |
| 6535 | (void) useDTD; |
| 6536 | |
| 6537 | if ((node == NULL) || (node->type != XML_ELEMENT_NODE) || (name == NULL)) |
| 6538 | return(NULL); |
| 6539 | |
| 6540 | if (node->properties != NULL) { |
| 6541 | prop = node->properties; |
| 6542 | if (nsName == NULL) { |
| 6543 | /* |
| 6544 | * We want the attr to be in no namespace. |
| 6545 | */ |
| 6546 | do { |
| 6547 | if ((prop->ns == NULL) && xmlStrEqual(prop->name, name)) { |
| 6548 | return(prop); |
| 6549 | } |
| 6550 | prop = prop->next; |
| 6551 | } while (prop != NULL); |
| 6552 | } else { |
| 6553 | /* |
| 6554 | * We want the attr to be in the specified namespace. |
| 6555 | */ |
| 6556 | do { |
| 6557 | if ((prop->ns != NULL) && xmlStrEqual(prop->name, name) && |
| 6558 | ((prop->ns->href == nsName) || |
| 6559 | xmlStrEqual(prop->ns->href, nsName))) |
| 6560 | { |
| 6561 | return(prop); |
| 6562 | } |
| 6563 | prop = prop->next; |
| 6564 | } while (prop != NULL); |
| 6565 | } |
| 6566 | } |
| 6567 | |
| 6568 | #ifdef LIBXML_TREE_ENABLED |
| 6569 | if (! useDTD) |
| 6570 | return(NULL); |
| 6571 | /* |
| 6572 | * Check if there is a default/fixed attribute declaration in |
| 6573 | * the internal or external subset. |
| 6574 | */ |
| 6575 | if ((node->doc != NULL) && (node->doc->intSubset != NULL)) { |
| 6576 | xmlDocPtr doc = node->doc; |
| 6577 | xmlAttributePtr attrDecl = NULL; |
| 6578 | xmlChar *elemQName, *tmpstr = NULL; |
| 6579 | |
| 6580 | /* |
| 6581 | * We need the QName of the element for the DTD-lookup. |
| 6582 | */ |
| 6583 | if ((node->ns != NULL) && (node->ns->prefix != NULL)) { |
| 6584 | tmpstr = xmlStrdup(node->ns->prefix); |
| 6585 | if (tmpstr == NULL) |
no test coverage detected