* xmlParseElementDecl: * @ctxt: an XML parser context * * DEPRECATED: Internal function, don't use. * * Parse an element declaration. Always consumes '<!'. * * [45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>' * * [ VC: Unique Element Type Declaration ] * No element type may be declared more than once * * Returns the type of the element, or -1 in case of error */
| 6879 | * Returns the type of the element, or -1 in case of error |
| 6880 | */ |
| 6881 | int |
| 6882 | xmlParseElementDecl(xmlParserCtxtPtr ctxt) { |
| 6883 | const xmlChar *name; |
| 6884 | int ret = -1; |
| 6885 | xmlElementContentPtr content = NULL; |
| 6886 | |
| 6887 | if ((CUR != '<') || (NXT(1) != '!')) |
| 6888 | return(ret); |
| 6889 | SKIP(2); |
| 6890 | |
| 6891 | /* GROW; done in the caller */ |
| 6892 | if (CMP7(CUR_PTR, 'E', 'L', 'E', 'M', 'E', 'N', 'T')) { |
| 6893 | int inputid = ctxt->input->id; |
| 6894 | |
| 6895 | SKIP(7); |
| 6896 | if (SKIP_BLANKS_PE == 0) { |
| 6897 | xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, |
| 6898 | "Space required after 'ELEMENT'\n"); |
| 6899 | return(-1); |
| 6900 | } |
| 6901 | name = xmlParseName(ctxt); |
| 6902 | if (name == NULL) { |
| 6903 | xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED, |
| 6904 | "xmlParseElementDecl: no name for Element\n"); |
| 6905 | return(-1); |
| 6906 | } |
| 6907 | if (SKIP_BLANKS_PE == 0) { |
| 6908 | xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, |
| 6909 | "Space required after the element name\n"); |
| 6910 | } |
| 6911 | if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) { |
| 6912 | SKIP(5); |
| 6913 | /* |
| 6914 | * Element must always be empty. |
| 6915 | */ |
| 6916 | ret = XML_ELEMENT_TYPE_EMPTY; |
| 6917 | } else if ((RAW == 'A') && (NXT(1) == 'N') && |
| 6918 | (NXT(2) == 'Y')) { |
| 6919 | SKIP(3); |
| 6920 | /* |
| 6921 | * Element is a generic container. |
| 6922 | */ |
| 6923 | ret = XML_ELEMENT_TYPE_ANY; |
| 6924 | } else if (RAW == '(') { |
| 6925 | ret = xmlParseElementContentDecl(ctxt, name, &content); |
| 6926 | } else { |
| 6927 | /* |
| 6928 | * [ WFC: PEs in Internal Subset ] error handling. |
| 6929 | */ |
| 6930 | xmlFatalErrMsg(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED, |
| 6931 | "xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n"); |
| 6932 | return(-1); |
| 6933 | } |
| 6934 | |
| 6935 | SKIP_BLANKS_PE; |
| 6936 | |
| 6937 | if (RAW != '>') { |
| 6938 | xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL); |
no test coverage detected