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

Function xmlXPathNextChildElement

ThirdParty/libxml2/vtklibxml2/xpath.c:6648–6708  ·  view source on GitHub ↗

* xmlXPathNextChildElement: * @ctxt: the XPath Parser context * @cur: the current node in the traversal * * Traversal function for the "child" direction and nodes of type element. * The child axis contains the children of the context node in document order. * * Returns the next element following that axis */

Source from the content-addressed store, hash-verified

6646 * Returns the next element following that axis
6647 */
6648static xmlNodePtr
6649xmlXPathNextChildElement(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
6650 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
6651 if (cur == NULL) {
6652 cur = ctxt->context->node;
6653 if (cur == NULL) return(NULL);
6654 /*
6655 * Get the first element child.
6656 */
6657 switch (cur->type) {
6658 case XML_ELEMENT_NODE:
6659 case XML_DOCUMENT_FRAG_NODE:
6660 case XML_ENTITY_REF_NODE: /* URGENT TODO: entify-refs as well? */
6661 case XML_ENTITY_NODE:
6662 cur = cur->children;
6663 if (cur != NULL) {
6664 if (cur->type == XML_ELEMENT_NODE)
6665 return(cur);
6666 do {
6667 cur = cur->next;
6668 } while ((cur != NULL) &&
6669 (cur->type != XML_ELEMENT_NODE));
6670 return(cur);
6671 }
6672 return(NULL);
6673 case XML_DOCUMENT_NODE:
6674 case XML_HTML_DOCUMENT_NODE:
6675 return(xmlDocGetRootElement((xmlDocPtr) cur));
6676 default:
6677 return(NULL);
6678 }
6679 return(NULL);
6680 }
6681 /*
6682 * Get the next sibling element node.
6683 */
6684 switch (cur->type) {
6685 case XML_ELEMENT_NODE:
6686 case XML_TEXT_NODE:
6687 case XML_ENTITY_REF_NODE:
6688 case XML_ENTITY_NODE:
6689 case XML_CDATA_SECTION_NODE:
6690 case XML_PI_NODE:
6691 case XML_COMMENT_NODE:
6692 case XML_XINCLUDE_END:
6693 break;
6694 /* case XML_DTD_NODE: */ /* URGENT TODO: DTD-node as well? */
6695 default:
6696 return(NULL);
6697 }
6698 if (cur->next != NULL) {
6699 if (cur->next->type == XML_ELEMENT_NODE)
6700 return(cur->next);
6701 cur = cur->next;
6702 do {
6703 cur = cur->next;
6704 } while ((cur != NULL) && (cur->type != XML_ELEMENT_NODE));
6705 return(cur);

Callers

nothing calls this directly

Calls 1

xmlDocGetRootElementFunction · 0.85

Tested by

no test coverage detected