* xmlCompileAttributeTest: * @ctxt: the compilation context * * Compile an attribute test. */
| 896 | * Compile an attribute test. |
| 897 | */ |
| 898 | static void |
| 899 | xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) { |
| 900 | xmlChar *token = NULL; |
| 901 | xmlChar *name = NULL; |
| 902 | xmlChar *URL = NULL; |
| 903 | |
| 904 | SKIP_BLANKS; |
| 905 | name = xmlPatScanNCName(ctxt); |
| 906 | if (ctxt->error < 0) |
| 907 | return; |
| 908 | if (name == NULL) { |
| 909 | if (CUR == '*') { |
| 910 | PUSH(XML_OP_ATTR, NULL, NULL); |
| 911 | NEXT; |
| 912 | } else { |
| 913 | ERROR(NULL, NULL, NULL, |
| 914 | "xmlCompileAttributeTest : Name expected\n"); |
| 915 | ctxt->error = 1; |
| 916 | } |
| 917 | return; |
| 918 | } |
| 919 | if (CUR == ':') { |
| 920 | int i; |
| 921 | xmlChar *prefix = name; |
| 922 | |
| 923 | NEXT; |
| 924 | |
| 925 | if (IS_BLANK_CH(CUR)) { |
| 926 | ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL); |
| 927 | ctxt->error = 1; |
| 928 | goto error; |
| 929 | } |
| 930 | /* |
| 931 | * This is a namespace match |
| 932 | */ |
| 933 | token = xmlPatScanName(ctxt); |
| 934 | if ((prefix[0] == 'x') && |
| 935 | (prefix[1] == 'm') && |
| 936 | (prefix[2] == 'l') && |
| 937 | (prefix[3] == 0)) |
| 938 | { |
| 939 | XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE); |
| 940 | } else { |
| 941 | for (i = 0;i < ctxt->nb_namespaces;i++) { |
| 942 | if (xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) { |
| 943 | XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i]) |
| 944 | break; |
| 945 | } |
| 946 | } |
| 947 | if (i >= ctxt->nb_namespaces) { |
| 948 | ERROR5(NULL, NULL, NULL, |
| 949 | "xmlCompileAttributeTest : no namespace bound to prefix %s\n", |
| 950 | prefix); |
| 951 | ctxt->error = 1; |
| 952 | goto error; |
| 953 | } |
| 954 | } |
| 955 | XML_PAT_FREE_STRING(ctxt, name); |
no test coverage detected