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

Function patternNode

ThirdParty/libxml2/vtklibxml2/runtest.c:3641–3697  ·  view source on GitHub ↗

* * * Patterns tests * * * ************************************************************************/

Source from the content-addressed store, hash-verified

3639 * *
3640 ************************************************************************/
3641static void patternNode(FILE *out, xmlTextReaderPtr reader,
3642 const char *pattern, xmlPatternPtr patternc,
3643 xmlStreamCtxtPtr patstream) {
3644 xmlChar *path = NULL;
3645 int match = -1;
3646 int type, empty;
3647
3648 type = xmlTextReaderNodeType(reader);
3649 empty = xmlTextReaderIsEmptyElement(reader);
3650
3651 if (type == XML_READER_TYPE_ELEMENT) {
3652 /* do the check only on element start */
3653 match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
3654
3655 if (match) {
3656 path = xmlGetNodePath(xmlTextReaderCurrentNode(reader));
3657 fprintf(out, "Node %s matches pattern %s\n", path, pattern);
3658 }
3659 }
3660 if (patstream != NULL) {
3661 int ret;
3662
3663 if (type == XML_READER_TYPE_ELEMENT) {
3664 ret = xmlStreamPush(patstream,
3665 xmlTextReaderConstLocalName(reader),
3666 xmlTextReaderConstNamespaceUri(reader));
3667 if (ret < 0) {
3668 fprintf(out, "xmlStreamPush() failure\n");
3669 xmlFreeStreamCtxt(patstream);
3670 patstream = NULL;
3671 } else if (ret != match) {
3672 if (path == NULL) {
3673 path = xmlGetNodePath(
3674 xmlTextReaderCurrentNode(reader));
3675 }
3676 fprintf(out,
3677 "xmlPatternMatch and xmlStreamPush disagree\n");
3678 fprintf(out,
3679 " pattern %s node %s\n",
3680 pattern, path);
3681 }
3682
3683
3684 }
3685 if ((type == XML_READER_TYPE_END_ELEMENT) ||
3686 ((type == XML_READER_TYPE_ELEMENT) && (empty))) {
3687 ret = xmlStreamPop(patstream);
3688 if (ret < 0) {
3689 fprintf(out, "xmlStreamPop() failure\n");
3690 xmlFreeStreamCtxt(patstream);
3691 patstream = NULL;
3692 }
3693 }
3694 }
3695 if (path != NULL)
3696 xmlFree(path);
3697}
3698

Callers 1

patternTestFunction · 0.85

Calls 11

xmlTextReaderNodeTypeFunction · 0.85
xmlPatternMatchFunction · 0.85
xmlTextReaderCurrentNodeFunction · 0.85
xmlGetNodePathFunction · 0.85
fprintfFunction · 0.85
xmlStreamPushFunction · 0.85
xmlFreeStreamCtxtFunction · 0.85
xmlStreamPopFunction · 0.85

Tested by

no test coverage detected