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

Function xmlTextReaderConstValue

ThirdParty/libxml2/vtklibxml2/xmlreader.c:3620–3675  ·  view source on GitHub ↗

* xmlTextReaderConstValue: * @reader: the xmlTextReaderPtr used * * Provides the text value of the node if present * * Returns the string or NULL if not available. The result will be * deallocated on the next Read() operation. */

Source from the content-addressed store, hash-verified

3618 * deallocated on the next Read() operation.
3619 */
3620const xmlChar *
3621xmlTextReaderConstValue(xmlTextReaderPtr reader) {
3622 xmlNodePtr node;
3623 if (reader == NULL)
3624 return(NULL);
3625 if (reader->node == NULL)
3626 return(NULL);
3627 if (reader->curnode != NULL)
3628 node = reader->curnode;
3629 else
3630 node = reader->node;
3631
3632 switch (node->type) {
3633 case XML_NAMESPACE_DECL:
3634 return(((xmlNsPtr) node)->href);
3635 case XML_ATTRIBUTE_NODE:{
3636 xmlAttrPtr attr = (xmlAttrPtr) node;
3637 const xmlChar *ret;
3638
3639 if ((attr->children != NULL) &&
3640 (attr->children->type == XML_TEXT_NODE) &&
3641 (attr->children->next == NULL))
3642 return(attr->children->content);
3643 else {
3644 if (reader->buffer == NULL) {
3645 reader->buffer = xmlBufCreateSize(100);
3646 if (reader->buffer == NULL)
3647 return (NULL);
3648 xmlBufSetAllocationScheme(reader->buffer,
3649 XML_BUFFER_ALLOC_DOUBLEIT);
3650 } else
3651 xmlBufEmpty(reader->buffer);
3652 xmlBufGetNodeContent(reader->buffer, node);
3653 ret = xmlBufContent(reader->buffer);
3654 if (ret == NULL) {
3655 xmlTextReaderErrMemory(reader);
3656 /* error on the buffer best to reallocate */
3657 xmlBufFree(reader->buffer);
3658 reader->buffer = xmlBufCreateSize(100);
3659 xmlBufSetAllocationScheme(reader->buffer,
3660 XML_BUFFER_ALLOC_DOUBLEIT);
3661 }
3662 return(ret);
3663 }
3664 break;
3665 }
3666 case XML_TEXT_NODE:
3667 case XML_CDATA_SECTION_NODE:
3668 case XML_PI_NODE:
3669 case XML_COMMENT_NODE:
3670 return(node->content);
3671 default:
3672 break;
3673 }
3674 return(NULL);
3675}
3676
3677/**

Callers 2

processNodeFunction · 0.85
processNodeFunction · 0.85

Calls 7

xmlBufCreateSizeFunction · 0.85
xmlBufEmptyFunction · 0.85
xmlBufGetNodeContentFunction · 0.85
xmlBufContentFunction · 0.85
xmlTextReaderErrMemoryFunction · 0.85
xmlBufFreeFunction · 0.85

Tested by 1

processNodeFunction · 0.68