summaryrefslogtreecommitdiff
path: root/parserInternals.c
diff options
context:
space:
mode:
Diffstat (limited to 'parserInternals.c')
-rw-r--r--parserInternals.c222
1 files changed, 222 insertions, 0 deletions
diff --git a/parserInternals.c b/parserInternals.c
index 9eb226f1..4fa24c0c 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -176,6 +176,228 @@ xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
}
/**
+ * xmlFatalErr:
+ * @ctxt: an XML parser context
+ * @error: the error number
+ * @extra: extra information string
+ *
+ * Handle a fatal parser error, i.e. violating Well-Formedness constraints
+ */
+void
+xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
+{
+ const char *errmsg;
+
+ if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
+ (ctxt->instate == XML_PARSER_EOF))
+ return;
+ switch (error) {
+ case XML_ERR_INVALID_HEX_CHARREF:
+ errmsg = "CharRef: invalid hexadecimal value";
+ break;
+ case XML_ERR_INVALID_DEC_CHARREF:
+ errmsg = "CharRef: invalid decimal value";
+ break;
+ case XML_ERR_INVALID_CHARREF:
+ errmsg = "CharRef: invalid value";
+ break;
+ case XML_ERR_INTERNAL_ERROR:
+ errmsg = "internal error";
+ break;
+ case XML_ERR_PEREF_AT_EOF:
+ errmsg = "PEReference at end of document";
+ break;
+ case XML_ERR_PEREF_IN_PROLOG:
+ errmsg = "PEReference in prolog";
+ break;
+ case XML_ERR_PEREF_IN_EPILOG:
+ errmsg = "PEReference in epilog";
+ break;
+ case XML_ERR_PEREF_NO_NAME:
+ errmsg = "PEReference: no name";
+ break;
+ case XML_ERR_PEREF_SEMICOL_MISSING:
+ errmsg = "PEReference: expecting ';'";
+ break;
+ case XML_ERR_ENTITY_LOOP:
+ errmsg = "Detected an entity reference loop";
+ break;
+ case XML_ERR_ENTITY_NOT_STARTED:
+ errmsg = "EntityValue: \" or ' expected";
+ break;
+ case XML_ERR_ENTITY_PE_INTERNAL:
+ errmsg = "PEReferences forbidden in internal subset";
+ break;
+ case XML_ERR_ENTITY_NOT_FINISHED:
+ errmsg = "EntityValue: \" or ' expected";
+ break;
+ case XML_ERR_ATTRIBUTE_NOT_STARTED:
+ errmsg = "AttValue: \" or ' expected";
+ break;
+ case XML_ERR_LT_IN_ATTRIBUTE:
+ errmsg = "Unescaped '<' not allowed in attributes values";
+ break;
+ case XML_ERR_LITERAL_NOT_STARTED:
+ errmsg = "SystemLiteral \" or ' expected";
+ break;
+ case XML_ERR_LITERAL_NOT_FINISHED:
+ errmsg = "Unfinished System or Public ID \" or ' expected";
+ break;
+ case XML_ERR_MISPLACED_CDATA_END:
+ errmsg = "Sequence ']]>' not allowed in content";
+ break;
+ case XML_ERR_URI_REQUIRED:
+ errmsg = "SYSTEM or PUBLIC, the URI is missing";
+ break;
+ case XML_ERR_PUBID_REQUIRED:
+ errmsg = "PUBLIC, the Public Identifier is missing";
+ break;
+ case XML_ERR_HYPHEN_IN_COMMENT:
+ errmsg = "Comment must not contain '--' (double-hyphen)";
+ break;
+ case XML_ERR_PI_NOT_STARTED:
+ errmsg = "xmlParsePI : no target name";
+ break;
+ case XML_ERR_RESERVED_XML_NAME:
+ errmsg = "Invalid PI name";
+ break;
+ case XML_ERR_NOTATION_NOT_STARTED:
+ errmsg = "NOTATION: Name expected here";
+ break;
+ case XML_ERR_NOTATION_NOT_FINISHED:
+ errmsg = "'>' required to close NOTATION declaration";
+ break;
+ case XML_ERR_VALUE_REQUIRED:
+ errmsg = "Entity value required";
+ break;
+ case XML_ERR_URI_FRAGMENT:
+ errmsg = "Fragment not allowed";
+ break;
+ case XML_ERR_ATTLIST_NOT_STARTED:
+ errmsg = "'(' required to start ATTLIST enumeration";
+ break;
+ case XML_ERR_NMTOKEN_REQUIRED:
+ errmsg = "NmToken expected in ATTLIST enumeration";
+ break;
+ case XML_ERR_ATTLIST_NOT_FINISHED:
+ errmsg = "')' required to finish ATTLIST enumeration";
+ break;
+ case XML_ERR_MIXED_NOT_STARTED:
+ errmsg = "MixedContentDecl : '|' or ')*' expected";
+ break;
+ case XML_ERR_PCDATA_REQUIRED:
+ errmsg = "MixedContentDecl : '#PCDATA' expected";
+ break;
+ case XML_ERR_ELEMCONTENT_NOT_STARTED:
+ errmsg = "ContentDecl : Name or '(' expected";
+ break;
+ case XML_ERR_ELEMCONTENT_NOT_FINISHED:
+ errmsg = "ContentDecl : ',' '|' or ')' expected";
+ break;
+ case XML_ERR_PEREF_IN_INT_SUBSET:
+ errmsg =
+ "PEReference: forbidden within markup decl in internal subset";
+ break;
+ case XML_ERR_GT_REQUIRED:
+ errmsg = "expected '>'";
+ break;
+ case XML_ERR_CONDSEC_INVALID:
+ errmsg = "XML conditional section '[' expected";
+ break;
+ case XML_ERR_EXT_SUBSET_NOT_FINISHED:
+ errmsg = "Content error in the external subset";
+ break;
+ case XML_ERR_CONDSEC_INVALID_KEYWORD:
+ errmsg =
+ "conditional section INCLUDE or IGNORE keyword expected";
+ break;
+ case XML_ERR_CONDSEC_NOT_FINISHED:
+ errmsg = "XML conditional section not closed";
+ break;
+ case XML_ERR_XMLDECL_NOT_STARTED:
+ errmsg = "Text declaration '<?xml' required";
+ break;
+ case XML_ERR_XMLDECL_NOT_FINISHED:
+ errmsg = "parsing XML declaration: '?>' expected";
+ break;
+ case XML_ERR_EXT_ENTITY_STANDALONE:
+ errmsg = "external parsed entities cannot be standalone";
+ break;
+ case XML_ERR_ENTITYREF_SEMICOL_MISSING:
+ errmsg = "EntityRef: expecting ';'";
+ break;
+ case XML_ERR_DOCTYPE_NOT_FINISHED:
+ errmsg = "DOCTYPE improperly terminated";
+ break;
+ case XML_ERR_LTSLASH_REQUIRED:
+ errmsg = "EndTag: '</' not found";
+ break;
+ case XML_ERR_EQUAL_REQUIRED:
+ errmsg = "expected '='";
+ break;
+ case XML_ERR_STRING_NOT_CLOSED:
+ errmsg = "String not closed expecting \" or '";
+ break;
+ case XML_ERR_STRING_NOT_STARTED:
+ errmsg = "String not started expecting ' or \"";
+ break;
+ case XML_ERR_ENCODING_NAME:
+ errmsg = "Invalid XML encoding name";
+ break;
+ case XML_ERR_STANDALONE_VALUE:
+ errmsg = "standalone accepts only 'yes' or 'no'";
+ break;
+ case XML_ERR_DOCUMENT_EMPTY:
+ errmsg = "Document is empty";
+ break;
+ case XML_ERR_DOCUMENT_END:
+ errmsg = "Extra content at the end of the document";
+ break;
+ case XML_ERR_NOT_WELL_BALANCED:
+ errmsg = "chunk is not well balanced";
+ break;
+ case XML_ERR_EXTRA_CONTENT:
+ errmsg = "extra content at the end of well balanced chunk";
+ break;
+ case XML_ERR_VERSION_MISSING:
+ errmsg = "Malformed declaration expecting version";
+ break;
+ case XML_ERR_NAME_TOO_LONG:
+ errmsg = "Name too long";
+ break;
+ case XML_ERR_INVALID_ENCODING:
+ errmsg = "Invalid bytes in character encoding";
+ break;
+ case XML_IO_UNKNOWN:
+ errmsg = "I/O error";
+ break;
+#if 0
+ case:
+ errmsg = "";
+ break;
+#endif
+ default:
+ errmsg = "Unregistered error message";
+ }
+ if (ctxt != NULL)
+ ctxt->errNo = error;
+ if (info == NULL) {
+ __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
+ XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n",
+ errmsg);
+ } else {
+ __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
+ XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n",
+ errmsg, info);
+ }
+ if (ctxt != NULL) {
+ ctxt->wellFormed = 0;
+ if (ctxt->recovery == 0)
+ ctxt->disableSAX = 1;
+ }
+}
+
+/**
* xmlErrEncodingInt:
* @ctxt: an XML parser context
* @error: the error number