Lines Matching full:ctxt
56 * @ctxt: an XML validation parser context
60 xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
64 if (ctxt != NULL) {
65 ctxt->errNo = XML_ERR_NO_MEMORY;
66 if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
67 schannel = ctxt->sax->serror;
69 ctxt->vctxt.error, ctxt->vctxt.userData,
70 ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY,
74 ctxt->errNo = XML_ERR_NO_MEMORY;
75 ctxt->instate = XML_PARSER_EOF;
76 ctxt->disableSAX = 1;
80 ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY,
89 * @ctxt: an XML validation parser context
98 xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error,
103 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
104 (ctxt->instate == XML_PARSER_EOF))
106 if (ctxt != NULL) {
107 ctxt->errNo = error;
108 if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
109 schannel = ctxt->sax->serror;
111 ctxt->vctxt.error, ctxt->vctxt.userData,
112 ctxt, NULL, XML_FROM_DTD, error,
116 ctxt->valid = 0;
120 ctxt, NULL, XML_FROM_DTD, error,
129 * @ctxt: an XML parser context
138 xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
141 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
142 (ctxt->instate == XML_PARSER_EOF))
144 if (ctxt != NULL)
145 ctxt->errNo = error;
146 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
150 if (ctxt != NULL) {
151 ctxt->wellFormed = 0;
152 ctxt->valid = 0;
153 if (ctxt->recovery == 0)
154 ctxt->disableSAX = 1;
160 * @ctxt: an XML parser context
169 xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
172 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
173 (ctxt->instate == XML_PARSER_EOF))
175 if (ctxt != NULL)
176 ctxt->errNo = error;
177 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
185 * @ctxt: an XML parser context
194 xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
197 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
198 (ctxt->instate == XML_PARSER_EOF))
200 if (ctxt != NULL)
201 ctxt->errNo = error;
202 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
210 * @ctxt: an XML parser context
218 xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
221 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
222 (ctxt->instate == XML_PARSER_EOF))
224 if (ctxt != NULL)
225 ctxt->errNo = error;
226 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
243 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
259 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
260 if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);
261 return((const xmlChar *) ctxt->input->filename);
275 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
276 if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
277 return(ctxt->input->line);
291 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
292 if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
293 return(ctxt->input->col);
307 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
308 if ((ctx == NULL) || (ctxt->myDoc == NULL)) return(0);
309 return(ctxt->myDoc->standalone == 1);
323 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
324 if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0);
325 return(ctxt->myDoc->intSubset != NULL);
339 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
340 if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0);
341 return(ctxt->myDoc->extSubset != NULL);
357 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
366 if (ctxt->myDoc == NULL)
368 dtd = xmlGetIntSubset(ctxt->myDoc);
370 if (ctxt->html)
374 ctxt->myDoc->intSubset = NULL;
376 ctxt->myDoc->intSubset =
377 xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
378 if (ctxt->myDoc->intSubset == NULL)
379 xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset");
395 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
403 (((ctxt->validate) || (ctxt->loadsubset != 0)) &&
404 (ctxt->wellFormed && ctxt->myDoc))) {
420 if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL))
421 input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID,
427 xmlNewDtd(ctxt->myDoc, name, ExternalID, SystemID);
432 oldinput = ctxt->input;
433 oldinputNr = ctxt->inputNr;
434 oldinputMax = ctxt->inputMax;
435 oldinputTab = ctxt->inputTab;
436 oldcharset = ctxt->charset;
437 oldencoding = ctxt->encoding;
438 ctxt->encoding = NULL;
440 ctxt->inputTab = (xmlParserInputPtr *)
442 if (ctxt->inputTab == NULL) {
443 xmlSAX2ErrMemory(ctxt, "xmlSAX2ExternalSubset");
444 ctxt->input = oldinput;
445 ctxt->inputNr = oldinputNr;
446 ctxt->inputMax = oldinputMax;
447 ctxt->inputTab = oldinputTab;
448 ctxt->charset = oldcharset;
449 ctxt->encoding = oldencoding;
452 ctxt->inputNr = 0;
453 ctxt->inputMax = 5;
454 ctxt->input = NULL;
455 xmlPushInput(ctxt, input);
460 if (ctxt->input->length >= 4) {
461 enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
462 xmlSwitchEncoding(ctxt, enc);
469 input->base = ctxt->input->cur;
470 input->cur = ctxt->input->cur;
476 xmlParseExternalSubset(ctxt, ExternalID, SystemID);
482 while (ctxt->inputNr > 1)
483 xmlPopInput(ctxt);
484 xmlFreeInputStream(ctxt->input);
485 xmlFree(ctxt->inputTab);
490 ctxt->input = oldinput;
491 ctxt->inputNr = oldinputNr;
492 ctxt->inputMax = oldinputMax;
493 ctxt->inputTab = oldinputTab;
494 ctxt->charset = oldcharset;
495 if ((ctxt->encoding != NULL) &&
496 ((ctxt->dict == NULL) ||
497 (!xmlDictOwns(ctxt->dict, ctxt->encoding))))
498 xmlFree((xmlChar *) ctxt->encoding);
499 ctxt->encoding = oldencoding;
500 /* ctxt->wellFormed = oldwellFormed; */
521 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
527 if (ctxt->input != NULL)
528 base = ctxt->input->filename;
530 base = ctxt->directory;
540 (const char *) publicId, ctxt);
558 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
567 if (ctxt->inSubset == 0) {
572 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->standalone == 1)) {
573 if (ctxt->inSubset == 2) {
574 ctxt->myDoc->standalone = 0;
575 ret = xmlGetDocEntity(ctxt->myDoc, name);
576 ctxt->myDoc->standalone = 1;
578 ret = xmlGetDocEntity(ctxt->myDoc, name);
580 ctxt->myDoc->standalone = 0;
581 ret = xmlGetDocEntity(ctxt->myDoc, name);
583 xmlFatalErrMsg(ctxt, XML_ERR_NOT_STANDALONE,
587 ctxt->myDoc->standalone = 1;
591 ret = xmlGetDocEntity(ctxt->myDoc, name);
594 ((ctxt->validate) || (ctxt->replaceEntities)) &&
604 unsigned long oldnbent = ctxt->nbentities;
606 val = xmlParseCtxtExternalEntity(ctxt, ret->URI,
611 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
613 ctxt->validate = 0;
618 ret->checked = (ctxt->nbentities - oldnbent + 1) * 2;
638 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
647 ret = xmlGetParameterEntity(ctxt->myDoc, name);
668 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
676 if (ctxt->inSubset == 1) {
677 ent = xmlAddDocEntity(ctxt->myDoc, name, type, publicId,
679 if ((ent == NULL) && (ctxt->pedantic))
680 xmlWarnMsg(ctxt, XML_WAR_ENTITY_REDEFINED,
687 if (ctxt->input != NULL)
688 base = ctxt->input->filename;
690 base = ctxt->directory;
695 } else if (ctxt->inSubset == 2) {
696 ent = xmlAddDtdEntity(ctxt->myDoc, name, type, publicId,
698 if ((ent == NULL) && (ctxt->pedantic) &&
699 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
700 ctxt->sax->warning(ctxt->userData,
706 if (ctxt->input != NULL)
707 base = ctxt->input->filename;
709 base = ctxt->directory;
715 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
738 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
742 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
755 int tmp = ctxt->valid;
756 xmlErrValid(ctxt, XML_DTD_XMLID_TYPE,
758 ctxt->valid = tmp;
761 name = xmlSplitQName(ctxt, fullname, &prefix);
762 ctxt->vctxt.valid = 1;
763 if (ctxt->inSubset == 1)
764 attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem,
767 else if (ctxt->inSubset == 2)
768 attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, elem,
772 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
779 if (ctxt->vctxt.valid == 0)
780 ctxt->valid = 0;
781 if ((attr != NULL) && (ctxt->validate) && (ctxt->wellFormed) &&
782 (ctxt->myDoc->intSubset != NULL))
783 ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc,
805 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
808 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
816 if (ctxt->inSubset == 1)
817 elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset,
819 else if (ctxt->inSubset == 2)
820 elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->extSubset,
823 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
830 ctxt->valid = 0;
831 if (ctxt->validate && ctxt->wellFormed &&
832 ctxt->myDoc && ctxt->myDoc->intSubset)
833 ctxt->valid &=
834 xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem);
851 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
854 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
863 xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
867 } else if (ctxt->inSubset == 1)
868 nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name,
870 else if (ctxt->inSubset == 2)
871 nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, name,
874 xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
880 if (nota == NULL) ctxt->valid = 0;
881 if ((ctxt->validate) && (ctxt->wellFormed) &&
882 (ctxt->myDoc->intSubset != NULL))
883 ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc,
904 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
911 if (ctxt->inSubset == 1) {
912 ent = xmlAddDocEntity(ctxt->myDoc, name,
915 if ((ent == NULL) && (ctxt->pedantic) &&
916 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
917 ctxt->sax->warning(ctxt->userData,
923 if (ctxt->input != NULL)
924 base = ctxt->input->filename;
926 base = ctxt->directory;
931 } else if (ctxt->inSubset == 2) {
932 ent = xmlAddDtdEntity(ctxt->myDoc, name,
935 if ((ent == NULL) && (ctxt->pedantic) &&
936 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
937 ctxt->sax->warning(ctxt->userData,
943 if (ctxt->input != NULL)
944 base = ctxt->input->filename;
946 base = ctxt->directory;
952 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
969 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
985 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
994 if (ctxt->html) {
996 if (ctxt->myDoc == NULL)
997 ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
998 if (ctxt->myDoc == NULL) {
999 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
1002 ctxt->myDoc->properties = XML_DOC_HTML;
1003 ctxt->myDoc->parseFlags = ctxt->options;
1007 ctxt->errNo = XML_ERR_INTERNAL_ERROR;
1008 ctxt->instate = XML_PARSER_EOF;
1009 ctxt->disableSAX = 1;
1013 doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
1016 if (ctxt->options & XML_PARSE_OLD10)
1018 doc->parseFlags = ctxt->options;
1019 if (ctxt->encoding != NULL)
1020 doc->encoding = xmlStrdup(ctxt->encoding);
1023 doc->standalone = ctxt->standalone;
1025 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
1028 if ((ctxt->dictNames) && (doc != NULL)) {
1029 doc->dict = ctxt->dict;
1033 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) &&
1034 (ctxt->input != NULL) && (ctxt->input->filename != NULL)) {
1035 ctxt->myDoc->URL = xmlPathToURI((const xmlChar *)ctxt->input->filename);
1036 if (ctxt->myDoc->URL == NULL)
1037 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
1050 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1057 if (ctxt->validate && ctxt->wellFormed &&
1058 ctxt->myDoc && ctxt->myDoc->intSubset)
1059 ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc);
1065 if ((ctxt->encoding != NULL) && (ctxt->myDoc != NULL) &&
1066 (ctxt->myDoc->encoding == NULL)) {
1067 ctxt->myDoc->encoding = ctxt->encoding;
1068 ctxt->encoding = NULL;
1070 if ((ctxt->inputTab != NULL) &&
1071 (ctxt->inputNr > 0) && (ctxt->inputTab[0] != NULL) &&
1072 (ctxt->inputTab[0]->encoding != NULL) && (ctxt->myDoc != NULL) &&
1073 (ctxt->myDoc->encoding == NULL)) {
1074 ctxt->myDoc->encoding = xmlStrdup(ctxt->inputTab[0]->encoding);
1076 if ((ctxt->charset != XML_CHAR_ENCODING_NONE) && (ctxt->myDoc != NULL) &&
1077 (ctxt->myDoc->charset == XML_CHAR_ENCODING_NONE)) {
1078 ctxt->myDoc->charset = ctxt->charset;
1099 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1106 if (ctxt->html) {
1114 name = xmlSplitQName(ctxt, fullname, &ns);
1117 xmlNsErrMsg(ctxt, XML_ERR_NS_DECL_ERROR,
1121 xmlNsWarnMsg(ctxt, XML_WAR_NS_COLUMN,
1133 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
1140 if ((ctxt->html) &&
1153 ctxt->vctxt.valid = 1;
1154 ctxt->vctxt,
1155 ctxt->myDoc, ctxt->node,
1157 if (ctxt->vctxt.valid != 1) {
1158 ctxt->valid = 0;
1170 if ((!ctxt->html) && (ns == NULL) &&
1176 if (!ctxt->replaceEntities) {
1177 ctxt->depth++;
1178 val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
1180 ctxt->depth--;
1182 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
1198 if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
1199 ctxt->sax->warning(ctxt->userData,
1203 if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
1204 ctxt->sax->warning(ctxt->userData,
1212 nsret = xmlNewNs(ctxt->node, val, NULL);
1219 if (nsret != NULL && ctxt->validate && ctxt->wellFormed &&
1220 ctxt->myDoc && ctxt->myDoc->intSubset)
1221 ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
1222 ctxt->node, prefix, nsret, val);
1232 if ((!ctxt->html) &&
1238 if (!ctxt->replaceEntities) {
1239 ctxt->depth++;
1240 val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
1242 ctxt->depth--;
1244 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
1257 xmlNsErrMsg(ctxt, XML_NS_ERR_EMPTY,
1260 if ((ctxt->pedantic != 0) && (val[0] != 0)) {
1265 xmlNsWarnMsg(ctxt, XML_WAR_NS_URI,
1269 xmlNsWarnMsg(ctxt, XML_WAR_NS_URI_RELATIVE,
1277 nsret = xmlNewNs(ctxt->node, val, name);
1284 if (nsret != NULL && ctxt->validate && ctxt->wellFormed &&
1285 ctxt->myDoc && ctxt->myDoc->intSubset)
1286 ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
1287 ctxt->node, prefix, nsret, value);
1299 namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, ns);
1302 xmlNsErrMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
1308 prop = ctxt->node->properties;
1314 xmlNsErrMsg(ctxt, XML_ERR_ATTRIBUTE_REDEFINED,
1317 ctxt->wellFormed = 0;
1318 if (ctxt->recovery == 0) ctxt->disableSAX = 1;
1332 ret = xmlNewNsPropEatName(ctxt->node, namespace, name, NULL);
1335 if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
1338 ret->children = xmlStringGetNodeList(ctxt->myDoc, value);
1347 ret->children = xmlNewDocText(ctxt->myDoc, value);
1355 if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
1356 ctxt->myDoc && ctxt->myDoc->intSubset) {
1362 if (!ctxt->replaceEntities) {
1365 ctxt->depth++;
1366 val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
1368 ctxt->depth--;
1371 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
1372 ctxt->myDoc, ctxt->node, ret, value);
1381 nvalnorm = xmlValidNormalizeAttributeValue(ctxt->myDoc,
1382 ctxt->node, fullname, val);
1388 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
1389 ctxt->myDoc, ctxt->node, ret, val);
1393 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc,
1394 ctxt->node, ret, value);
1398 if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
1399 (((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
1400 ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) {
1412 xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
1416 xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
1417 } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret))
1418 xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
1419 else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
1420 xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret);
1436 xmlCheckDefaultedAttributes(xmlParserCtxtPtr ctxt, const xmlChar *name,
1443 elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->intSubset, name, prefix);
1445 elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->extSubset, name, prefix);
1457 if ((ctxt->myDoc->standalone == 1) &&
1458 (ctxt->myDoc->extSubset != NULL) &&
1459 (ctxt->validate)) {
1462 (xmlGetDtdQAttrDesc(ctxt->myDoc->extSubset,
1465 (xmlGetDtdQAttrDesc(ctxt->myDoc->intSubset,
1478 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
1498 xmlErrValid(ctxt, XML_DTD_STANDALONE_DEFAULTED,
1532 (ctxt->loadsubset & XML_COMPLETE_ATTRS)) {
1535 tst = xmlGetDtdQAttrDesc(ctxt->myDoc->intSubset,
1544 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
1564 xmlSAX2AttributeInternal(ctxt, fulln,
1575 elemDecl = xmlGetDtdQElementDesc(ctxt->myDoc->extSubset,
1594 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1604 if ((ctx == NULL) || (fullname == NULL) || (ctxt->myDoc == NULL)) return;
1605 parent = ctxt->node;
1614 if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
1615 ((ctxt->myDoc->intSubset == NULL) ||
1616 ((ctxt->myDoc->intSubset->notations == NULL) &&
1617 (ctxt->myDoc->intSubset->elements == NULL) &&
1618 (ctxt->myDoc->intSubset->attributes == NULL) &&
1619 (ctxt->myDoc->intSubset->entities == NULL)))) {
1620 xmlErrValid(ctxt, XML_ERR_NO_DTD,
1622 ctxt->validate = 0;
1629 name = xmlSplitQName(ctxt, fullname, &prefix);
1637 ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL, name, NULL);
1641 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
1644 if (ctxt->myDoc->children == NULL) {
1648 xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
1650 parent = ctxt->myDoc->children;
1652 ctxt->nodemem = -1;
1653 if (ctxt->linenumbers) {
1654 if (ctxt->input != NULL) {
1655 if (ctxt->input->line < 65535)
1656 ret->line = (short) ctxt->input->line;
1668 nodePush(ctxt, ret);
1693 if ((!ctxt->html) &&
1694 ((ctxt->myDoc->intSubset != NULL) ||
1695 (ctxt->myDoc->extSubset != NULL))) {
1696 xmlCheckDefaultedAttributes(ctxt, name, prefix, atts);
1706 if (!ctxt->html) {
1710 xmlSAX2AttributeInternal(ctxt, att, value, prefix);
1722 ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
1724 ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
1727 xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
1747 if (ctxt->html) {
1749 xmlSAX2AttributeInternal(ctxt, att, value, NULL);
1757 xmlSAX2AttributeInternal(ctxt, att, value, NULL);
1773 if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
1776 chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
1778 ctxt->valid = 0;
1780 ctxt->wellFormed = 0;
1781 ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
1782 ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
1801 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1805 cur = ctxt->node;
1814 if (cur != NULL && ctxt->record_info) {
1815 ctxt->nodeInfo->end_pos = ctxt->input->cur - ctxt->input->base;
1816 ctxt->nodeInfo->end_line = ctxt->input->line;
1817 ctxt->nodeInfo->node = cur;
1818 xmlParserAddNodeInfo(ctxt, ctxt->nodeInfo);
1820 ctxt->nodemem = -1;
1823 if (ctxt->validate && ctxt->wellFormed &&
1824 ctxt->myDoc && ctxt->myDoc->intSubset)
1825 ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc,
1836 nodePop(ctxt);
1842 * @ctxt: the parser context
1851 xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
1858 if (ctxt->freeElems != NULL) {
1859 ret = ctxt->freeElems;
1860 ctxt->freeElems = ret->next;
1861 ctxt->freeElemsNr--;
1866 xmlErrMemory(ctxt, "xmlSAX2Characters");
1874 if (ctxt->dictNames) {
1878 (ctxt->options & XML_PARSE_COMPACT)) {
1886 intern = xmlDictLookup(ctxt->dict, str, len);
1894 intern = xmlDictLookup(ctxt->dict, str, len);
1904 xmlSAX2ErrMemory(ctxt, "xmlSAX2TextNode");
1911 if (ctxt->linenumbers) {
1912 if (ctxt->input != NULL) {
1913 if (ctxt->input->line < 65535)
1914 ret->line = (short) ctxt->input->line;
1917 if (ctxt->options & XML_PARSE_BIG_LINES)
1918 ret->psvi = (void *) (ptrdiff_t) ctxt->input->line;
1931 * @ctxt: the parser context
1940 xmlSAX2DecodeAttrEntities(xmlParserCtxtPtr ctxt, const xmlChar *str,
1951 ctxt->depth++;
1952 ret = xmlStringLenDecodeEntities(ctxt, str, end - str,
1954 ctxt->depth--;
1974 xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
1988 namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, prefix);
1993 if (ctxt->freeAttrs != NULL) {
1994 ret = ctxt->freeAttrs;
1995 ctxt->freeAttrs = ret->next;
1996 ctxt->freeAttrsNr--;
2000 ret->parent = ctxt->node;
2001 ret->doc = ctxt->myDoc;
2004 if (ctxt->dictNames)
2010 if (ctxt->node->properties == NULL) {
2011 ctxt->node->properties = ret;
2013 xmlAttrPtr prev = ctxt->node->properties;
2023 if (ctxt->dictNames)
2024 ret = xmlNewNsPropEatName(ctxt->node, namespace,
2027 ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL);
2029 xmlErrMemory(ctxt, "xmlSAX2AttributeNs");
2034 if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
2043 tmp = xmlSAX2TextNode(ctxt, value, valueend - value);
2051 ret->children = xmlStringLenGetNodeList(ctxt->myDoc, value,
2065 tmp = xmlSAX2TextNode(ctxt, value, valueend - value);
2075 if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
2076 ctxt->myDoc && ctxt->myDoc->intSubset) {
2081 if (!ctxt->replaceEntities) {
2082 dup = xmlSAX2DecodeAttrEntities(ctxt, value, valueend);
2085 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
2086 ctxt->myDoc, ctxt->node, ret, value);
2095 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
2096 ctxt->myDoc, ctxt->node, ret, dup);
2106 if (ctxt->attsSpecial != NULL) {
2113 ctxt->vctxt.valid = 1;
2115 &ctxt->vctxt, ctxt->myDoc,
2116 ctxt->node, fullname, dup);
2117 if (ctxt->vctxt.valid != 1)
2118 ctxt->valid = 0;
2129 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
2130 ctxt->myDoc, ctxt->node, ret, dup);
2139 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
2140 ctxt->myDoc, ctxt->node, ret, dup);
2144 if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
2145 (((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
2146 ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) {
2151 if ((prefix == ctxt->str_xml) &&
2164 xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
2170 xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
2171 } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
2175 xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
2176 } else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) {
2179 xmlAddRef(&ctxt->vctxt, ctxt->myDoc, dup, ret);
2214 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2223 parent = ctxt->node;
2227 if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
2228 ((ctxt->myDoc->intSubset == NULL) ||
2229 ((ctxt->myDoc->intSubset->notations == NULL) &&
2230 (ctxt->myDoc->intSubset->elements == NULL) &&
2231 (ctxt->myDoc->intSubset->attributes == NULL) &&
2232 (ctxt->myDoc->intSubset->entities == NULL)))) {
2233 xmlErrValid(ctxt, XML_DTD_NO_DTD,
2235 ctxt->validate = 0;
2242 if (ctxt->dictNames) {
2245 fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
2255 if (ctxt->freeElems != NULL) {
2256 ret = ctxt->freeElems;
2257 ctxt->freeElems = ret->next;
2258 ctxt->freeElemsNr--;
2262 if (ctxt->dictNames)
2270 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2277 if (ctxt->dictNames)
2278 ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
2281 ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
2283 ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
2286 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2290 if (ctxt->linenumbers) {
2291 if (ctxt->input != NULL) {
2292 if (ctxt->input->line < 65535)
2293 ret->line = (short) ctxt->input->line;
2300 xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
2327 if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
2328 ctxt->myDoc && ctxt->myDoc->intSubset) {
2329 ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
2334 ctxt->nodemem = -1;
2339 nodePush(ctxt, ret);
2356 ((ctxt->loadsubset & XML_COMPLETE_ATTRS) == 0))
2364 ret->ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
2366 ret->ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
2372 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2376 xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
2380 xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
2395 if (ctxt->dictNames) {
2398 fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
2401 xmlSAX2AttributeNs(ctxt, fullname, NULL,
2409 xmlSAX2AttributeNs(ctxt, lname, NULL,
2416 xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
2426 if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
2429 chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
2431 ctxt->valid = 0;
2433 ctxt->wellFormed = 0;
2434 ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
2435 ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
2456 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2461 cur = ctxt->node;
2463 if ((ctxt->record_info) && (cur != NULL)) {
2464 node_info.end_pos = ctxt->input->cur - ctxt->input->base;
2465 node_info.end_line = ctxt->input->line;
2467 xmlParserAddNodeInfo(ctxt, &node_info);
2469 ctxt->nodemem = -1;
2472 if (ctxt->validate && ctxt->wellFormed &&
2473 ctxt->myDoc && ctxt->myDoc->intSubset)
2474 ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc, cur);
2480 nodePop(ctxt);
2493 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2502 ret = xmlNewCharRef(ctxt->myDoc, name);
2504 ret = xmlNewReference(ctxt->myDoc, name);
2507 "add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
2509 if (xmlAddChild(ctxt->node, ret) == NULL) {
2525 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2539 if (ctxt->node == NULL) {
2542 "add chars: ctxt->node == NULL !\n");
2546 lastChild = ctxt->node->last;
2549 "add chars to %s \n", ctxt->node->name);
2557 lastChild = xmlSAX2TextNode(ctxt, ch, len);
2559 ctxt->node->children = lastChild;
2560 ctxt->node->last = lastChild;
2561 lastChild->parent = ctxt->node;
2562 lastChild->doc = ctxt->node->doc;
2563 ctxt->nodelen = len;
2564 ctxt->nodemem = len + 1;
2566 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2573 if ((coalesceText) && (ctxt->nodemem != 0)) {
2584 } else if ((ctxt->nodemem == ctxt->nodelen + 1) &&
2585 (xmlDictOwns(ctxt->dict, lastChild->content))) {
2589 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
2592 if (((size_t)ctxt->nodelen + (size_t)len > XML_MAX_TEXT_LENGTH) &&
2593 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
2594 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
2597 if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len ||
2598 (size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) {
2599 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
2602 if (ctxt->nodelen + len >= ctxt->nodemem) {
2606 size = ctxt->nodemem + len;
2610 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2613 ctxt->nodemem = size;
2616 memcpy(&lastChild->content[ctxt->nodelen], ch, len);
2617 ctxt->nodelen += len;
2618 lastChild->content[ctxt->nodelen] = 0;
2621 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2623 if (ctxt->node->children != NULL) {
2624 ctxt->nodelen = xmlStrlen(lastChild->content);
2625 ctxt->nodemem = ctxt->nodelen + 1;
2629 lastChild = xmlSAX2TextNode(ctxt, ch, len);
2631 xmlAddChild(ctxt->node, lastChild);
2632 if (ctxt->node->children != NULL) {
2633 ctxt->nodelen = len;
2634 ctxt->nodemem = len + 1;
2653 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
2672 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2677 parent = ctxt->node;
2683 ret = xmlNewDocPI(ctxt->myDoc, target, data);
2686 if (ctxt->linenumbers) {
2687 if (ctxt->input != NULL) {
2688 if (ctxt->input->line < 65535)
2689 ret->line = (short) ctxt->input->line;
2694 if (ctxt->inSubset == 1) {
2695 xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret);
2697 } else if (ctxt->inSubset == 2) {
2698 xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
2706 xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
2735 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2740 parent = ctxt->node;
2744 ret = xmlNewDocComment(ctxt->myDoc, value);
2746 if (ctxt->linenumbers) {
2747 if (ctxt->input != NULL) {
2748 if (ctxt->input->line < 65535)
2749 ret->line = (short) ctxt->input->line;
2755 if (ctxt->inSubset == 1) {
2756 xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret);
2758 } else if (ctxt->inSubset == 2) {
2759 xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
2767 xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
2797 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2805 lastChild = xmlGetLastChild(ctxt->node);
2808 "add chars to %s \n", ctxt->node->name);
2814 ret = xmlNewCDataBlock(ctxt->myDoc, value, len);
2815 if (xmlAddChild(ctxt->node, ret) == NULL)