* xmlParseElementStart: * @ctxt: an XML parser context * * Parse the start of an XML element. Returns -1 in case of error, 0 if an * opening tag was parsed, 1 if an empty element was parsed. * * Always consumes '<'. */
| 9908 | * Always consumes '<'. |
| 9909 | */ |
| 9910 | static int |
| 9911 | xmlParseElementStart(xmlParserCtxtPtr ctxt) { |
| 9912 | int maxDepth = (ctxt->options & XML_PARSE_HUGE) ? 2048 : 256; |
| 9913 | const xmlChar *name; |
| 9914 | const xmlChar *prefix = NULL; |
| 9915 | const xmlChar *URI = NULL; |
| 9916 | xmlParserNodeInfo node_info; |
| 9917 | int line; |
| 9918 | xmlNodePtr cur; |
| 9919 | int nbNs = 0; |
| 9920 | |
| 9921 | if (ctxt->nameNr > maxDepth) { |
| 9922 | xmlFatalErrMsgInt(ctxt, XML_ERR_RESOURCE_LIMIT, |
| 9923 | "Excessive depth in document: %d use XML_PARSE_HUGE option\n", |
| 9924 | ctxt->nameNr); |
| 9925 | xmlHaltParser(ctxt); |
| 9926 | return(-1); |
| 9927 | } |
| 9928 | |
| 9929 | /* Capture start position */ |
| 9930 | if (ctxt->record_info) { |
| 9931 | node_info.begin_pos = ctxt->input->consumed + |
| 9932 | (CUR_PTR - ctxt->input->base); |
| 9933 | node_info.begin_line = ctxt->input->line; |
| 9934 | } |
| 9935 | |
| 9936 | if (ctxt->spaceNr == 0) |
| 9937 | spacePush(ctxt, -1); |
| 9938 | else if (*ctxt->space == -2) |
| 9939 | spacePush(ctxt, -1); |
| 9940 | else |
| 9941 | spacePush(ctxt, *ctxt->space); |
| 9942 | |
| 9943 | line = ctxt->input->line; |
| 9944 | #ifdef LIBXML_SAX1_ENABLED |
| 9945 | if (ctxt->sax2) |
| 9946 | #endif /* LIBXML_SAX1_ENABLED */ |
| 9947 | name = xmlParseStartTag2(ctxt, &prefix, &URI, &nbNs); |
| 9948 | #ifdef LIBXML_SAX1_ENABLED |
| 9949 | else |
| 9950 | name = xmlParseStartTag(ctxt); |
| 9951 | #endif /* LIBXML_SAX1_ENABLED */ |
| 9952 | if (name == NULL) { |
| 9953 | spacePop(ctxt); |
| 9954 | return(-1); |
| 9955 | } |
| 9956 | nameNsPush(ctxt, name, prefix, URI, line, nbNs); |
| 9957 | cur = ctxt->node; |
| 9958 | |
| 9959 | #ifdef LIBXML_VALID_ENABLED |
| 9960 | /* |
| 9961 | * [ VC: Root Element Type ] |
| 9962 | * The Name in the document type declaration must match the element |
| 9963 | * type of the root element. |
| 9964 | */ |
| 9965 | if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc && |
| 9966 | ctxt->node && (ctxt->node == ctxt->myDoc->children)) |
| 9967 | ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc); |
no test coverage detected