Added in Expat 1.95.3.
*/
XMLPARSEAPI(int)
-XML_ParserReset(XML_Parser parser, const XML_Char *encodingName);
+XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
/* atts is array of name/value pairs, terminated by 0;
names and values are 0 terminated.
const XML_Char *systemId,
const XML_Char *publicId);
+/* This is called in two situations:
+ 1) An entity reference is encountered for which no declaration
+ has been read *and* this is not an error.
+ 2) An internal entity reference is read, but not expanded, because
+ XML_SetDefaultHandler has been called.
+*/
+typedef void (*XML_SkippedEntityHandler)(void *userData,
+ const XML_Char *entityName,
+ int is_parameter_entity);
+
/* This structure is filled in by the XML_UnknownEncodingHandler to
provide information to the parser about encodings that are unknown
to the parser.
XML_EndCdataSectionHandler end);
/* This sets the default handler and also inhibits expansion of
- internal entities. The entity reference will be passed to the
- default handler.
+ internal entities. These entity references will be passed to the
+ default handler, or to the skipped entity handler, if one is set.
*/
XMLPARSEAPI(void)
XML_SetDefaultHandler(XML_Parser parser,
XMLPARSEAPI(void)
XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
+XMLPARSEAPI(void)
+XML_SetSkippedEntityHandler(XML_Parser parser,
+ XML_SkippedEntityHandler handler);
+
XMLPARSEAPI(void)
XML_SetUnknownEncodingHandler(XML_Parser parser,
XML_UnknownEncodingHandler handler,
XML_NotStandaloneHandler m_notStandaloneHandler;
XML_ExternalEntityRefHandler m_externalEntityRefHandler;
void *m_externalEntityRefHandlerArg;
+ XML_SkippedEntityHandler m_skippedEntityHandler;
XML_UnknownEncodingHandler m_unknownEncodingHandler;
XML_ElementDeclHandler m_elementDeclHandler;
XML_AttlistDeclHandler m_attlistDeclHandler;
#define externalEntityRefHandler (((Parser *)parser)->m_externalEntityRefHandler)
#define externalEntityRefHandlerArg (((Parser *)parser)->m_externalEntityRefHandlerArg)
#define internalEntityRefHandler (((Parser *)parser)->m_internalEntityRefHandler)
+#define skippedEntityHandler (((Parser *)parser)->m_skippedEntityHandler)
#define unknownEncodingHandler (((Parser *)parser)->m_unknownEncodingHandler)
#define elementDeclHandler (((Parser *)parser)->m_elementDeclHandler)
#define attlistDeclHandler (((Parser *)parser)->m_attlistDeclHandler)
notStandaloneHandler = NULL;
externalEntityRefHandler = NULL;
externalEntityRefHandlerArg = parser;
+ skippedEntityHandler = NULL;
unknownEncodingHandler = NULL;
elementDeclHandler = NULL;
attlistDeclHandler = NULL;
XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler = endNamespaceDeclHandler;
XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler;
XML_ExternalEntityRefHandler oldExternalEntityRefHandler = externalEntityRefHandler;
+ XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler;
XML_UnknownEncodingHandler oldUnknownEncodingHandler = unknownEncodingHandler;
XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler;
XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler;
endNamespaceDeclHandler = oldEndNamespaceDeclHandler;
notStandaloneHandler = oldNotStandaloneHandler;
externalEntityRefHandler = oldExternalEntityRefHandler;
+ skippedEntityHandler = oldSkippedEntityHandler;
unknownEncodingHandler = oldUnknownEncodingHandler;
elementDeclHandler = oldElementDeclHandler;
attlistDeclHandler = oldAttlistDeclHandler;
externalEntityRefHandlerArg = parser;
}
+void XML_SetSkippedEntityHandler(XML_Parser parser,
+ XML_SkippedEntityHandler handler)
+{
+ skippedEntityHandler = handler;
+}
+
void XML_SetUnknownEncodingHandler(XML_Parser parser,
XML_UnknownEncodingHandler handler,
void *data)
XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc,
s + enc->minBytesPerChar,
next - enc->minBytesPerChar);
- if (ch) {
+ if (ch) {
if (characterDataHandler)
characterDataHandler(handlerArg, &ch, 1);
else if (defaultHandler)
poolDiscard(&dtd.pool);
if (!entity) {
if (!hadExternalDoctype || dtd.standalone)
- return XML_ERROR_UNDEFINED_ENTITY;
- if (defaultHandler)
- reportDefault(parser, enc, s, next);
+ return XML_ERROR_UNDEFINED_ENTITY;
+ if (skippedEntityHandler)
+ skippedEntityHandler(handlerArg, name, 0);
+ else if (defaultHandler)
+ reportDefault(parser, enc, s, next);
break;
}
if (entity->open)
if (entity->textPtr) {
enum XML_Error result;
OPEN_INTERNAL_ENTITY openEntity;
- if (defaultHandler && !defaultExpandInternalEntities) {
- reportDefault(parser, enc, s, next);
+ if (!defaultExpandInternalEntities) {
+ if (skippedEntityHandler)
+ skippedEntityHandler(handlerArg, entity->name, 0);
+ else if (defaultHandler)
+ reportDefault(parser, enc, s, next);
break;
}
entity->open = 1;
openEntity.entity = entity;
openEntity.internalEventPtr = NULL;
openEntity.internalEventEndPtr = NULL;
- result = doContent(parser,
+ result = doContent(parser,
tagLevel,
internalEncoding,
(char *)entity->textPtr,
if (!entity) {
if (!hadExternalDoctype || dtd.standalone)
return XML_ERROR_UNDEFINED_ENTITY;
+ if (skippedEntityHandler)
+ skippedEntityHandler(handlerArg, name, 1);
break;
}
if (entity->open)
eventPtr = ptr;
return XML_ERROR_UNDEFINED_ENTITY;
}
+ if (skippedEntityHandler)
+ skippedEntityHandler(handlerArg, name, 0);
}
else if (entity->open) {
if (enc == encoding)
/* in the internal subset, PE references are
not allowed within markup declarations */
eventPtr = entityTextPtr;
- result = XML_ERROR_SYNTAX;
+ if (prologState.documentEntity)
+ result = XML_ERROR_PARAM_ENTITY_REF;
+ else
+ result = XML_ERROR_SYNTAX;
goto endEntityValue;
case XML_TOK_NONE:
result = XML_ERROR_NONE;