MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlTextReaderGetAttributeNs

Function xmlTextReaderGetAttributeNs

ThirdParty/libxml2/vtklibxml2/xmlreader.c:2448–2487  ·  view source on GitHub ↗

* xmlTextReaderGetAttributeNs: * @reader: the xmlTextReaderPtr used * @localName: the local name of the attribute. * @namespaceURI: the namespace URI of the attribute. * * Provides the value of the specified attribute * * Returns a string containing the value of the specified attribute, or NULL * in case of error. The string must be deallocated by the caller. */

Source from the content-addressed store, hash-verified

2446 * in case of error. The string must be deallocated by the caller.
2447 */
2448xmlChar *
2449xmlTextReaderGetAttributeNs(xmlTextReaderPtr reader, const xmlChar *localName,
2450 const xmlChar *namespaceURI) {
2451 xmlChar *ret = NULL;
2452 xmlChar *prefix = NULL;
2453 xmlNsPtr ns;
2454 int result;
2455
2456 if ((reader == NULL) || (localName == NULL))
2457 return(NULL);
2458 if (reader->node == NULL)
2459 return(NULL);
2460 if (reader->curnode != NULL)
2461 return(NULL);
2462
2463 /* TODO: handle the xmlDecl */
2464 if (reader->node->type != XML_ELEMENT_NODE)
2465 return(NULL);
2466
2467 if (xmlStrEqual(namespaceURI, BAD_CAST "http://www.w3.org/2000/xmlns/")) {
2468 if (! xmlStrEqual(localName, BAD_CAST "xmlns")) {
2469 prefix = BAD_CAST localName;
2470 }
2471 ns = reader->node->nsDef;
2472 while (ns != NULL) {
2473 if ((prefix == NULL && ns->prefix == NULL) ||
2474 ((ns->prefix != NULL) && (xmlStrEqual(ns->prefix, localName)))) {
2475 return readerStrdup(reader, ns->href);
2476 }
2477 ns = ns->next;
2478 }
2479 return NULL;
2480 }
2481
2482 result = xmlNodeGetAttrValue(reader->node, localName, namespaceURI, &ret);
2483 if (result < 0)
2484 xmlTextReaderErrMemory(reader);
2485
2486 return(ret);
2487}
2488
2489/**
2490 * xmlTextReaderGetRemainder:

Callers

nothing calls this directly

Calls 4

xmlStrEqualFunction · 0.85
readerStrdupFunction · 0.85
xmlNodeGetAttrValueFunction · 0.85
xmlTextReaderErrMemoryFunction · 0.85

Tested by

no test coverage detected