1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-11 21:41:53 +03:00

adding a new API for Christian Glahn: xmlParseBalancedChunkMemoryRecover

* parser.c include/libxml/parser.h: adding a new API for Christian
  Glahn: xmlParseBalancedChunkMemoryRecover
* valid.c: patch from Rick Jones for some grammar cleanup in
  validation messages
* result/VC/* result/valid/*: this slightly change some of the
  regression tests outputs
Daniel
This commit is contained in:
Daniel Veillard
2002-08-02 22:19:49 +00:00
parent 0bf2900b50
commit 58e44c9daf
14 changed files with 91 additions and 40 deletions

View File

@ -9712,6 +9712,38 @@ xmlParseExternalEntity(xmlDocPtr doc, xmlSAXHandlerPtr sax, void *user_data,
int
xmlParseBalancedChunkMemory(xmlDocPtr doc, xmlSAXHandlerPtr sax,
void *user_data, int depth, const xmlChar *string, xmlNodePtr *lst) {
return xmlParseBalancedChunkMemoryRecover( doc, sax, user_data,
depth, string, lst, 0 );
}
/**
* xmlParseBalancedChunkMemoryRecover:
* @doc: the document the chunk pertains to
* @sax: the SAX handler bloc (possibly NULL)
* @user_data: The user data returned on SAX callbacks (possibly NULL)
* @depth: Used for loop detection, use 0
* @string: the input string in UTF8 or ISO-Latin (zero terminated)
* @lst: the return value for the set of parsed nodes
* @recover: return nodes even if the data is broken (use 0)
*
*
* Parse a well-balanced chunk of an XML document
* called by the parser
* The allowed sequence for the Well Balanced Chunk is the one defined by
* the content production in the XML grammar:
*
* [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
*
* Returns 0 if the chunk is well balanced, -1 in case of args problem and
* the parser error code otherwise
*
* In case recover is set to 1, the nodelist will not be empty even if
* the parsed chunk is not well balanced.
*/
int
xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
void *user_data, int depth, const xmlChar *string, xmlNodePtr *lst,
int recover) {
xmlParserCtxtPtr ctxt;
xmlDocPtr newDoc;
xmlSAXHandlerPtr oldsax = NULL;
@ -9806,8 +9838,11 @@ xmlParseBalancedChunkMemory(xmlDocPtr doc, xmlSAXHandlerPtr sax,
else
ret = ctxt->errNo;
} else {
if (lst != NULL) {
xmlNodePtr cur;
ret = 0;
}
if (lst != NULL && (ret == 0 || recover == 1)) {
xmlNodePtr cur;
/*
* Return the newly created nodeset after unlinking it from
@ -9821,8 +9856,7 @@ xmlParseBalancedChunkMemory(xmlDocPtr doc, xmlSAXHandlerPtr sax,
}
newDoc->children->children = NULL;
}
ret = 0;
}
if (sax != NULL)
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);