1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00

Added interfaces with SAX callback block, and upgraded libtool, Daniel

This commit is contained in:
Daniel Veillard 1998-11-09 01:17:21 +00:00
parent e3bffb9934
commit 42dc9b30b9
4 changed files with 71 additions and 8 deletions

View File

@ -1,3 +1,8 @@
Sun Nov 8 13:11:07 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* parser.[ch]: Added interfaces allowing to specify a SAX
handler before parsing.
Sun Nov 8 09:39:17 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org> Sun Nov 8 09:39:17 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
* parser.c: redirrect all errors reporting through the SAX * parser.c: redirrect all errors reporting through the SAX

View File

@ -137,6 +137,9 @@ extern int xmlParseDocument(xmlParserCtxtPtr ctxt);
extern xmlDocPtr xmlParseDoc(CHAR *cur); extern xmlDocPtr xmlParseDoc(CHAR *cur);
extern xmlDocPtr xmlParseMemory(char *buffer, int size); extern xmlDocPtr xmlParseMemory(char *buffer, int size);
extern xmlDocPtr xmlParseFile(const char *filename); extern xmlDocPtr xmlParseFile(const char *filename);
extern xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur);
extern xmlDocPtr xmlSAXParseMemory(xmlSAXHandlerPtr sax, char *buffer, int size);
extern xmlDocPtr xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename);
extern CHAR *xmlStrdup(const CHAR *input); extern CHAR *xmlStrdup(const CHAR *input);
extern CHAR *xmlStrndup(const CHAR *input, int n); extern CHAR *xmlStrndup(const CHAR *input, int n);
extern CHAR *xmlStrchr(const CHAR *str, CHAR val); extern CHAR *xmlStrchr(const CHAR *str, CHAR val);

View File

@ -2394,7 +2394,8 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt) {
NEXT; NEXT;
entity = xmlGetDtdEntity(ctxt->doc, name); entity = xmlGetDtdEntity(ctxt->doc, name);
if (entity == NULL) { if (entity == NULL) {
xmlParserWarning(ctxt, if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
ctxt->sax->warning(ctxt,
"xmlParsePEReference: %%%s; not found\n"); "xmlParsePEReference: %%%s; not found\n");
} else { } else {
input = xmlNewEntityInputStream(ctxt, entity); input = xmlNewEntityInputStream(ctxt, entity);
@ -3438,15 +3439,18 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
} }
/** /**
* xmlParseDoc : * xmlSAXParseDoc :
* @sax: the SAX handler block
* @cur: a pointer to an array of CHAR * @cur: a pointer to an array of CHAR
* *
* parse an XML in-memory document and build a tree. * parse an XML in-memory document and build a tree.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
* *
* return values: the resulting document tree * return values: the resulting document tree
*/ */
xmlDocPtr xmlParseDoc(CHAR *cur) { xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur) {
xmlDocPtr ret; xmlDocPtr ret;
xmlParserCtxtPtr ctxt; xmlParserCtxtPtr ctxt;
xmlParserInputPtr input; xmlParserInputPtr input;
@ -3459,6 +3463,7 @@ xmlDocPtr xmlParseDoc(CHAR *cur) {
return(NULL); return(NULL);
} }
xmlInitParserCtxt(ctxt); xmlInitParserCtxt(ctxt);
if (sax != NULL) ctxt->sax == sax;
input = (xmlParserInputPtr) malloc(sizeof(xmlParserInput)); input = (xmlParserInputPtr) malloc(sizeof(xmlParserInput));
if (input == NULL) { if (input == NULL) {
perror("malloc"); perror("malloc");
@ -3488,16 +3493,32 @@ xmlDocPtr xmlParseDoc(CHAR *cur) {
} }
/** /**
* xmlParseFile : * xmlParseDoc :
* @cur: a pointer to an array of CHAR
*
* parse an XML in-memory document and build a tree.
*
* return values: the resulting document tree
*/
xmlDocPtr xmlParseDoc(CHAR *cur) {
return(xmlSAXParseDoc(NULL, cur));
}
/**
* xmlSAXParseFile :
* @sax: the SAX handler block
* @filename: the filename * @filename: the filename
* *
* parse an XML file and build a tree. Automatic support for ZLIB/Compress * parse an XML file and build a tree. Automatic support for ZLIB/Compress
* compressed document is provided by default if found at compile-time. * compressed document is provided by default if found at compile-time.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
* *
* return values: the resulting document tree * return values: the resulting document tree
*/ */
xmlDocPtr xmlParseFile(const char *filename) { xmlDocPtr xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename) {
xmlDocPtr ret; xmlDocPtr ret;
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
gzFile input; gzFile input;
@ -3577,6 +3598,7 @@ retry_bigger:
return(NULL); return(NULL);
} }
xmlInitParserCtxt(ctxt); xmlInitParserCtxt(ctxt);
if (sax != NULL) ctxt->sax == sax;
inputStream = (xmlParserInputPtr) malloc(sizeof(xmlParserInput)); inputStream = (xmlParserInputPtr) malloc(sizeof(xmlParserInput));
if (inputStream == NULL) { if (inputStream == NULL) {
perror("malloc"); perror("malloc");
@ -3610,20 +3632,36 @@ retry_bigger:
return(ret); return(ret);
} }
/**
* xmlParseFile :
* @filename: the filename
*
* parse an XML file and build a tree. Automatic support for ZLIB/Compress
* compressed document is provided by default if found at compile-time.
*
* return values: the resulting document tree
*/
xmlDocPtr xmlParseFile(const char *filename) {
return(xmlSAXParseFile(NULL, filename));
}
/** /**
* xmlParseMemory : * xmlSAXParseMemory :
* @sax: the SAX handler block
* @cur: an pointer to a char array * @cur: an pointer to a char array
* @size: the siwe of the array * @size: the siwe of the array
* *
* parse an XML in-memory block and build a tree. * parse an XML in-memory block and use the given SAX function block
* to handle the parsing callback. If sax is NULL, fallback to the default
* DOM tree building routines.
* *
* TODO : plug some encoding conversion routines here. !!! * TODO : plug some encoding conversion routines here. !!!
* *
* return values: the resulting document tree * return values: the resulting document tree
*/ */
xmlDocPtr xmlParseMemory(char *buffer, int size) { xmlDocPtr xmlSAXParseMemory(xmlSAXHandlerPtr sax, char *buffer, int size) {
xmlDocPtr ret; xmlDocPtr ret;
xmlParserCtxtPtr ctxt; xmlParserCtxtPtr ctxt;
xmlParserInputPtr input; xmlParserInputPtr input;
@ -3636,6 +3674,7 @@ xmlDocPtr xmlParseMemory(char *buffer, int size) {
return(NULL); return(NULL);
} }
xmlInitParserCtxt(ctxt); xmlInitParserCtxt(ctxt);
if (sax != NULL) ctxt->sax == sax;
input = (xmlParserInputPtr) malloc(sizeof(xmlParserInput)); input = (xmlParserInputPtr) malloc(sizeof(xmlParserInput));
if (input == NULL) { if (input == NULL) {
perror("malloc"); perror("malloc");
@ -3670,6 +3709,19 @@ xmlDocPtr xmlParseMemory(char *buffer, int size) {
return(ret); return(ret);
} }
/**
* xmlParseMemory :
* @cur: an pointer to a char array
* @size: the size of the array
*
* parse an XML in-memory block and build a tree.
*
* return values: the resulting document tree
*/
xmlDocPtr xmlParseMemory(char *buffer, int size) {
return(xmlSAXParseMemory(NULL, buffer, size));
}
/** /**
* xmlInitParserCtxt: * xmlInitParserCtxt:

View File

@ -137,6 +137,9 @@ extern int xmlParseDocument(xmlParserCtxtPtr ctxt);
extern xmlDocPtr xmlParseDoc(CHAR *cur); extern xmlDocPtr xmlParseDoc(CHAR *cur);
extern xmlDocPtr xmlParseMemory(char *buffer, int size); extern xmlDocPtr xmlParseMemory(char *buffer, int size);
extern xmlDocPtr xmlParseFile(const char *filename); extern xmlDocPtr xmlParseFile(const char *filename);
extern xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur);
extern xmlDocPtr xmlSAXParseMemory(xmlSAXHandlerPtr sax, char *buffer, int size);
extern xmlDocPtr xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename);
extern CHAR *xmlStrdup(const CHAR *input); extern CHAR *xmlStrdup(const CHAR *input);
extern CHAR *xmlStrndup(const CHAR *input, int n); extern CHAR *xmlStrndup(const CHAR *input, int n);
extern CHAR *xmlStrchr(const CHAR *str, CHAR val); extern CHAR *xmlStrchr(const CHAR *str, CHAR val);