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

Function xmlXPathCompNodeTest

ThirdParty/libxml2/vtklibxml2/xpath.c:10022–10133  ·  view source on GitHub ↗

* xmlXPathCompNodeTest: * @ctxt: the XPath Parser context * @test: pointer to a xmlXPathTestVal * @type: pointer to a xmlXPathTypeVal * @prefix: placeholder for a possible name prefix * * [7] NodeTest ::= NameTest * | NodeType '(' ')' * | 'processing-instruction' '(' Literal ')' * * [37] NameTest ::= '*' * | NCName ':' '*' * | QName * [38] NodeType ::= 'comm

Source from the content-addressed store, hash-verified

10020 * Returns the name found and updates @test, @type and @prefix appropriately
10021 */
10022static xmlChar *
10023xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
10024 xmlXPathTypeVal *type, xmlChar **prefix,
10025 xmlChar *name) {
10026 int blanks;
10027
10028 if ((test == NULL) || (type == NULL) || (prefix == NULL)) {
10029 return(NULL);
10030 }
10031 *type = (xmlXPathTypeVal) 0;
10032 *test = (xmlXPathTestVal) 0;
10033 *prefix = NULL;
10034 SKIP_BLANKS;
10035
10036 if ((name == NULL) && (CUR == '*')) {
10037 /*
10038 * All elements
10039 */
10040 NEXT;
10041 *test = NODE_TEST_ALL;
10042 return(NULL);
10043 }
10044
10045 if (name == NULL)
10046 name = xmlXPathParseNCName(ctxt);
10047 if (name == NULL) {
10048 XP_ERRORNULL(XPATH_EXPR_ERROR);
10049 }
10050
10051 blanks = IS_BLANK_CH(CUR);
10052 SKIP_BLANKS;
10053 if (CUR == '(') {
10054 NEXT;
10055 /*
10056 * NodeType or PI search
10057 */
10058 if (xmlStrEqual(name, BAD_CAST "comment"))
10059 *type = NODE_TYPE_COMMENT;
10060 else if (xmlStrEqual(name, BAD_CAST "node"))
10061 *type = NODE_TYPE_NODE;
10062 else if (xmlStrEqual(name, BAD_CAST "processing-instruction"))
10063 *type = NODE_TYPE_PI;
10064 else if (xmlStrEqual(name, BAD_CAST "text"))
10065 *type = NODE_TYPE_TEXT;
10066 else {
10067 if (name != NULL)
10068 xmlFree(name);
10069 XP_ERRORNULL(XPATH_EXPR_ERROR);
10070 }
10071
10072 *test = NODE_TEST_TYPE;
10073
10074 SKIP_BLANKS;
10075 if (*type == NODE_TYPE_PI) {
10076 /*
10077 * Specific case: search a PI by name.
10078 */
10079 if (name != NULL)

Callers 1

xmlXPathCompStepFunction · 0.85

Calls 4

xmlXPathParseNCNameFunction · 0.85
xmlStrEqualFunction · 0.85
xmlXPathParseLiteralFunction · 0.85
xmlXPathNsLookupFunction · 0.85

Tested by

no test coverage detected