* xmlTextReaderMoveToAttribute: * @reader: the xmlTextReaderPtr used * @name: the qualified name of the attribute. * * Moves the position of the current instance to the attribute with * the specified qualified name. * * Returns 1 in case of success, -1 in case of error, 0 if not found */
| 2629 | * Returns 1 in case of success, -1 in case of error, 0 if not found |
| 2630 | */ |
| 2631 | int |
| 2632 | xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, const xmlChar *name) { |
| 2633 | xmlChar *prefix = NULL; |
| 2634 | const xmlChar *localname; |
| 2635 | xmlNsPtr ns; |
| 2636 | xmlAttrPtr prop; |
| 2637 | |
| 2638 | if ((reader == NULL) || (name == NULL)) |
| 2639 | return(-1); |
| 2640 | if (reader->node == NULL) |
| 2641 | return(-1); |
| 2642 | |
| 2643 | /* TODO: handle the xmlDecl */ |
| 2644 | if (reader->node->type != XML_ELEMENT_NODE) |
| 2645 | return(0); |
| 2646 | |
| 2647 | localname = xmlSplitQName4(name, &prefix); |
| 2648 | if (localname == NULL) { |
| 2649 | xmlTextReaderErrMemory(reader); |
| 2650 | return(-1); |
| 2651 | } |
| 2652 | if (prefix == NULL) { |
| 2653 | /* |
| 2654 | * Namespace default decl |
| 2655 | */ |
| 2656 | if (xmlStrEqual(name, BAD_CAST "xmlns")) { |
| 2657 | ns = reader->node->nsDef; |
| 2658 | while (ns != NULL) { |
| 2659 | if (ns->prefix == NULL) { |
| 2660 | reader->curnode = (xmlNodePtr) ns; |
| 2661 | return(1); |
| 2662 | } |
| 2663 | ns = ns->next; |
| 2664 | } |
| 2665 | return(0); |
| 2666 | } |
| 2667 | |
| 2668 | prop = reader->node->properties; |
| 2669 | while (prop != NULL) { |
| 2670 | /* |
| 2671 | * One need to have |
| 2672 | * - same attribute names |
| 2673 | * - and the attribute carrying that namespace |
| 2674 | */ |
| 2675 | if ((xmlStrEqual(prop->name, name)) && |
| 2676 | ((prop->ns == NULL) || (prop->ns->prefix == NULL))) { |
| 2677 | reader->curnode = (xmlNodePtr) prop; |
| 2678 | return(1); |
| 2679 | } |
| 2680 | prop = prop->next; |
| 2681 | } |
| 2682 | return(0); |
| 2683 | } |
| 2684 | |
| 2685 | /* |
| 2686 | * Namespace default decl |
| 2687 | */ |
| 2688 | if (xmlStrEqual(prefix, BAD_CAST "xmlns")) { |
nothing calls this directly
no test coverage detected