blob: 67111f8dbb8bf12a73945239ad433512cf09dde0 [file] [log] [blame]
Daniel Veillard260a68f1998-08-13 03:39:55 +00001/*
2 * SAX.c : Default SAX handler to build a tree.
Daniel Veillard97b58771998-10-20 06:14:16 +00003 *
Daniel Veillard39a1f9a1999-01-17 19:11:59 +00004 * See Copyright for the status of this software.
5 *
Daniel Veillard97b58771998-10-20 06:14:16 +00006 * Daniel Veillard <Daniel.Veillard@w3.org>
Daniel Veillard260a68f1998-08-13 03:39:55 +00007 */
8
9#include <stdio.h>
Seth Alvese7f12e61998-10-01 20:51:15 +000010#include <stdlib.h>
Daniel Veillard260a68f1998-08-13 03:39:55 +000011#include "tree.h"
12#include "parser.h"
Daniel Veillard517752b1999-04-05 12:20:10 +000013#include "parserInternals.h"
14#include "valid.h"
Daniel Veillardccb09631998-10-27 06:21:04 +000015#include "entities.h"
Daniel Veillardd109e371999-03-05 06:26:45 +000016#include "xml-error.h"
Daniel Veillard260a68f1998-08-13 03:39:55 +000017
18/* #define DEBUG_SAX */
19
Daniel Veillard97b58771998-10-20 06:14:16 +000020/**
21 * getPublicId:
Daniel Veillard011b63c1999-06-02 17:44:04 +000022 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +000023 *
Daniel Veillard260a68f1998-08-13 03:39:55 +000024 * Return the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"
Daniel Veillard97b58771998-10-20 06:14:16 +000025 *
Daniel Veillard1e346af1999-02-22 10:33:01 +000026 * Returns a CHAR *
Daniel Veillard260a68f1998-08-13 03:39:55 +000027 */
Daniel Veillard97b58771998-10-20 06:14:16 +000028const CHAR *
Daniel Veillard27d88741999-05-29 11:51:49 +000029getPublicId(void *ctx)
Daniel Veillard97b58771998-10-20 06:14:16 +000030{
Daniel Veillard27d88741999-05-29 11:51:49 +000031 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
Daniel Veillard260a68f1998-08-13 03:39:55 +000032 return(NULL);
33}
34
Daniel Veillard97b58771998-10-20 06:14:16 +000035/**
36 * getSystemId:
Daniel Veillard011b63c1999-06-02 17:44:04 +000037 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +000038 *
Daniel Veillard011b63c1999-06-02 17:44:04 +000039 * Return the system ID, basically URL or filename e.g.
Daniel Veillard97b58771998-10-20 06:14:16 +000040 * http://www.sgmlsource.com/dtds/memo.dtd
41 *
Daniel Veillard1e346af1999-02-22 10:33:01 +000042 * Returns a CHAR *
Daniel Veillard260a68f1998-08-13 03:39:55 +000043 */
Daniel Veillard97b58771998-10-20 06:14:16 +000044const CHAR *
Daniel Veillard27d88741999-05-29 11:51:49 +000045getSystemId(void *ctx)
Daniel Veillard97b58771998-10-20 06:14:16 +000046{
Daniel Veillard27d88741999-05-29 11:51:49 +000047 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard260a68f1998-08-13 03:39:55 +000048 return(ctxt->input->filename);
49}
50
Daniel Veillard97b58771998-10-20 06:14:16 +000051/**
52 * getLineNumber:
Daniel Veillard011b63c1999-06-02 17:44:04 +000053 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +000054 *
Daniel Veillard260a68f1998-08-13 03:39:55 +000055 * Return the line number of the current parsing point.
Daniel Veillard97b58771998-10-20 06:14:16 +000056 *
Daniel Veillard1e346af1999-02-22 10:33:01 +000057 * Returns an int
Daniel Veillard260a68f1998-08-13 03:39:55 +000058 */
Daniel Veillard97b58771998-10-20 06:14:16 +000059int
Daniel Veillard27d88741999-05-29 11:51:49 +000060getLineNumber(void *ctx)
Daniel Veillard97b58771998-10-20 06:14:16 +000061{
Daniel Veillard27d88741999-05-29 11:51:49 +000062 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard260a68f1998-08-13 03:39:55 +000063 return(ctxt->input->line);
64}
Daniel Veillard97b58771998-10-20 06:14:16 +000065
66/**
67 * getColumnNumber:
Daniel Veillard011b63c1999-06-02 17:44:04 +000068 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +000069 *
Daniel Veillard260a68f1998-08-13 03:39:55 +000070 * Return the column number of the current parsing point.
Daniel Veillard97b58771998-10-20 06:14:16 +000071 *
Daniel Veillard1e346af1999-02-22 10:33:01 +000072 * Returns an int
Daniel Veillard260a68f1998-08-13 03:39:55 +000073 */
Daniel Veillard97b58771998-10-20 06:14:16 +000074int
Daniel Veillard27d88741999-05-29 11:51:49 +000075getColumnNumber(void *ctx)
Daniel Veillard97b58771998-10-20 06:14:16 +000076{
Daniel Veillard27d88741999-05-29 11:51:49 +000077 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard260a68f1998-08-13 03:39:55 +000078 return(ctxt->input->col);
79}
80
81/*
82 * The default SAX Locator.
83 */
84
85xmlSAXLocator xmlDefaultSAXLocator = {
86 getPublicId, getSystemId, getLineNumber, getColumnNumber
87};
88
Daniel Veillard97b58771998-10-20 06:14:16 +000089/**
Daniel Veillard517752b1999-04-05 12:20:10 +000090 * isStandalone:
Daniel Veillard011b63c1999-06-02 17:44:04 +000091 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +000092 *
93 * Is this document tagged standalone ?
94 *
95 * Returns 1 if true
96 */
97int
Daniel Veillard27d88741999-05-29 11:51:49 +000098isStandalone(void *ctx)
Daniel Veillard517752b1999-04-05 12:20:10 +000099{
Daniel Veillard27d88741999-05-29 11:51:49 +0000100 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000101 return(ctxt->myDoc->standalone == 1);
102}
103
104/**
105 * hasInternalSubset:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000106 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000107 *
108 * Does this document has an internal subset
109 *
110 * Returns 1 if true
111 */
112int
Daniel Veillard27d88741999-05-29 11:51:49 +0000113hasInternalSubset(void *ctx)
Daniel Veillard517752b1999-04-05 12:20:10 +0000114{
Daniel Veillard27d88741999-05-29 11:51:49 +0000115 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000116 return(ctxt->myDoc->intSubset != NULL);
117}
118
119/**
120 * hasExternalSubset:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000121 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000122 *
123 * Does this document has an external subset
124 *
125 * Returns 1 if true
126 */
127int
Daniel Veillard27d88741999-05-29 11:51:49 +0000128hasExternalSubset(void *ctx)
Daniel Veillard517752b1999-04-05 12:20:10 +0000129{
Daniel Veillard27d88741999-05-29 11:51:49 +0000130 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000131 return(ctxt->myDoc->extSubset != NULL);
132}
133
134/**
135 * hasInternalSubset:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000136 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000137 *
138 * Does this document has an internal subset
139 */
140void
Daniel Veillard27d88741999-05-29 11:51:49 +0000141internalSubset(void *ctx, const CHAR *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000142 const CHAR *ExternalID, const CHAR *SystemID)
143{
Daniel Veillard011b63c1999-06-02 17:44:04 +0000144 xmlDtdPtr externalSubset;
Daniel Veillard27d88741999-05-29 11:51:49 +0000145 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000146#ifdef DEBUG_SAX
147 fprintf(stderr, "SAX.internalSubset(%s, %s, %s)\n",
148 name, ExternalID, SystemID);
149#endif
150 xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
Daniel Veillard011b63c1999-06-02 17:44:04 +0000151 if ((ExternalID != NULL) || (SystemID != NULL)) {
152 externalSubset = xmlParseDTD(ExternalID, SystemID);
153 }
Daniel Veillard517752b1999-04-05 12:20:10 +0000154}
155
156/**
Daniel Veillard97b58771998-10-20 06:14:16 +0000157 * resolveEntity:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000158 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000159 * @publicId: The public ID of the entity
160 * @systemId: The system ID of the entity
161 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000162 * Special entity resolver, better left to the parser, it has
163 * more context than the application layer.
Daniel Veillardccb09631998-10-27 06:21:04 +0000164 * The default behaviour is to NOT resolve the entities, in that case
165 * the ENTITY_REF nodes are built in the structure (and the parameter
166 * values).
Daniel Veillard97b58771998-10-20 06:14:16 +0000167 *
Daniel Veillard1e346af1999-02-22 10:33:01 +0000168 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000169 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000170xmlParserInputPtr
Daniel Veillard27d88741999-05-29 11:51:49 +0000171resolveEntity(void *ctx, const CHAR *publicId, const CHAR *systemId)
Daniel Veillard97b58771998-10-20 06:14:16 +0000172{
Daniel Veillard011b63c1999-06-02 17:44:04 +0000173 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000174
175#ifdef DEBUG_SAX
176 fprintf(stderr, "SAX.resolveEntity(%s, %s)\n", publicId, systemId);
177#endif
Daniel Veillardccb09631998-10-27 06:21:04 +0000178
Daniel Veillard517752b1999-04-05 12:20:10 +0000179 /*
180 * TODO : not 100% sure that the appropriate handling in that case.
181 */
Daniel Veillard011b63c1999-06-02 17:44:04 +0000182 if (systemId != NULL) {
183 return(xmlNewInputFromFile(ctxt, systemId));
184 }
Daniel Veillard260a68f1998-08-13 03:39:55 +0000185 return(NULL);
186}
187
Daniel Veillard97b58771998-10-20 06:14:16 +0000188/**
Daniel Veillard517752b1999-04-05 12:20:10 +0000189 * getEntity:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000190 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000191 * @name: The entity name
192 *
193 * Get an entity by name
194 *
Daniel Veillard011b63c1999-06-02 17:44:04 +0000195 * Returns the xmlEntityPtr if found.
Daniel Veillard517752b1999-04-05 12:20:10 +0000196 */
197xmlEntityPtr
Daniel Veillard27d88741999-05-29 11:51:49 +0000198getEntity(void *ctx, const CHAR *name)
Daniel Veillard517752b1999-04-05 12:20:10 +0000199{
Daniel Veillard27d88741999-05-29 11:51:49 +0000200 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000201 xmlEntityPtr ret;
202
203#ifdef DEBUG_SAX
204 fprintf(stderr, "SAX.getEntity(%s)\n", name);
205#endif
206
207 ret = xmlGetDocEntity(ctxt->myDoc, name);
208 return(ret);
209}
210
211
212/**
213 * entityDecl:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000214 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000215 * @name: the entity name
216 * @type: the entity type
217 * @publicId: The public ID of the entity
218 * @systemId: The system ID of the entity
219 * @content: the entity value (without processing).
220 *
221 * An entity definition has been parsed
222 */
223void
Daniel Veillard27d88741999-05-29 11:51:49 +0000224entityDecl(void *ctx, const CHAR *name, int type,
Daniel Veillard517752b1999-04-05 12:20:10 +0000225 const CHAR *publicId, const CHAR *systemId, CHAR *content)
226{
Daniel Veillard27d88741999-05-29 11:51:49 +0000227 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000228
229#ifdef DEBUG_SAX
230 fprintf(stderr, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
231 name, type, publicId, systemId, content);
232#endif
233 xmlAddDocEntity(ctxt->myDoc, name, type, publicId, systemId, content);
234}
235
236/**
237 * attributeDecl:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000238 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000239 * @name: the attribute name
240 * @type: the attribute type
241 * @publicId: The public ID of the attribute
242 * @systemId: The system ID of the attribute
243 * @content: the attribute value (without processing).
244 *
245 * An attribute definition has been parsed
246 */
247void
Daniel Veillard27d88741999-05-29 11:51:49 +0000248attributeDecl(void *ctx, const CHAR *elem, const CHAR *name,
Daniel Veillard517752b1999-04-05 12:20:10 +0000249 int type, int def, const CHAR *defaultValue,
250 xmlEnumerationPtr tree)
251{
Daniel Veillard27d88741999-05-29 11:51:49 +0000252 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000253
254#ifdef DEBUG_SAX
255 fprintf(stderr, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
256 elem, name, type, def, defaultValue);
257#endif
258 xmlAddAttributeDecl(ctxt->myDoc->intSubset, elem, name, type, def,
259 defaultValue, tree);
260}
261
262/**
263 * elementDecl:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000264 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000265 * @name: the element name
266 * @type: the element type
267 * @publicId: The public ID of the element
268 * @systemId: The system ID of the element
269 * @content: the element value (without processing).
270 *
271 * An element definition has been parsed
272 */
273void
Daniel Veillard27d88741999-05-29 11:51:49 +0000274elementDecl(void *ctx, const CHAR *name, int type,
Daniel Veillard517752b1999-04-05 12:20:10 +0000275 xmlElementContentPtr content)
276{
Daniel Veillard27d88741999-05-29 11:51:49 +0000277 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000278
279#ifdef DEBUG_SAX
280 fprintf(stderr, "SAX.elementDecl(%s, %d, ...)\n",
281 name, type);
282#endif
283 xmlAddElementDecl(ctxt->myDoc->intSubset, name, type, content);
284}
285
286/**
Daniel Veillard97b58771998-10-20 06:14:16 +0000287 * notationDecl:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000288 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000289 * @name: The name of the notation
290 * @publicId: The public ID of the entity
291 * @systemId: The system ID of the entity
292 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000293 * What to do when a notation declaration has been parsed.
294 * TODO Not handled currently.
295 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000296void
Daniel Veillard27d88741999-05-29 11:51:49 +0000297notationDecl(void *ctx, const CHAR *name,
Daniel Veillard97b58771998-10-20 06:14:16 +0000298 const CHAR *publicId, const CHAR *systemId)
299{
Daniel Veillard27d88741999-05-29 11:51:49 +0000300 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000301#ifdef DEBUG_SAX
302 fprintf(stderr, "SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId);
303#endif
Daniel Veillard517752b1999-04-05 12:20:10 +0000304 xmlAddNotationDecl(ctxt->myDoc->intSubset, name, publicId, systemId);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000305}
306
Daniel Veillard97b58771998-10-20 06:14:16 +0000307/**
308 * unparsedEntityDecl:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000309 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000310 * @name: The name of the entity
311 * @publicId: The public ID of the entity
312 * @systemId: The system ID of the entity
313 * @notationName: the name of the notation
314 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000315 * What to do when an unparsed entity declaration is parsed
316 * TODO Create an Entity node.
317 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000318void
Daniel Veillard27d88741999-05-29 11:51:49 +0000319unparsedEntityDecl(void *ctx, const CHAR *name,
Daniel Veillard97b58771998-10-20 06:14:16 +0000320 const CHAR *publicId, const CHAR *systemId,
321 const CHAR *notationName)
322{
Daniel Veillard27d88741999-05-29 11:51:49 +0000323 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000324#ifdef DEBUG_SAX
325 fprintf(stderr, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
326 name, publicId, systemId, notationName);
327#endif
328}
329
Daniel Veillard97b58771998-10-20 06:14:16 +0000330/**
331 * setDocumentLocator:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000332 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000333 * @loc: A SAX Locator
334 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000335 * Receive the document locator at startup, actually xmlDefaultSAXLocator
336 * Everything is available on the context, so this is useless in our case.
337 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000338void
Daniel Veillard27d88741999-05-29 11:51:49 +0000339setDocumentLocator(void *ctx, xmlSAXLocatorPtr loc)
Daniel Veillard97b58771998-10-20 06:14:16 +0000340{
Daniel Veillard27d88741999-05-29 11:51:49 +0000341 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000342#ifdef DEBUG_SAX
343 fprintf(stderr, "SAX.setDocumentLocator()\n");
344#endif
345}
346
Daniel Veillard97b58771998-10-20 06:14:16 +0000347/**
348 * startDocument:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000349 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000350 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000351 * called when the document start being processed.
352 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000353void
Daniel Veillard27d88741999-05-29 11:51:49 +0000354startDocument(void *ctx)
Daniel Veillard97b58771998-10-20 06:14:16 +0000355{
Daniel Veillard27d88741999-05-29 11:51:49 +0000356 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000357 xmlDocPtr doc;
358
Daniel Veillard260a68f1998-08-13 03:39:55 +0000359#ifdef DEBUG_SAX
360 fprintf(stderr, "SAX.startDocument()\n");
361#endif
Daniel Veillard517752b1999-04-05 12:20:10 +0000362 doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
363 if (doc != NULL) {
364 if (ctxt->encoding != NULL)
365 doc->encoding = xmlStrdup(ctxt->encoding);
366 else
367 doc->encoding = NULL;
368 doc->standalone = ctxt->standalone;
369 }
Daniel Veillard260a68f1998-08-13 03:39:55 +0000370}
371
Daniel Veillard97b58771998-10-20 06:14:16 +0000372/**
373 * endDocument:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000374 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000375 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000376 * called when the document end has been detected.
377 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000378void
Daniel Veillard27d88741999-05-29 11:51:49 +0000379endDocument(void *ctx)
Daniel Veillard97b58771998-10-20 06:14:16 +0000380{
Daniel Veillard27d88741999-05-29 11:51:49 +0000381 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000382#ifdef DEBUG_SAX
383 fprintf(stderr, "SAX.endDocument()\n");
384#endif
385}
386
Daniel Veillard97b58771998-10-20 06:14:16 +0000387/**
Daniel Veillard517752b1999-04-05 12:20:10 +0000388 * attribute:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000389 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000390 * @name: The attribute name
391 * @value: The attribute value
392 *
393 * Handle an attribute that has been read by the parser.
394 * The default handling is to convert the attribute into an
395 * DOM subtree and past it in a new xmlAttr element added to
396 * the element.
397 */
398void
Daniel Veillard27d88741999-05-29 11:51:49 +0000399attribute(void *ctx, const CHAR *fullname, const CHAR *value)
Daniel Veillard517752b1999-04-05 12:20:10 +0000400{
Daniel Veillard27d88741999-05-29 11:51:49 +0000401 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000402 xmlAttrPtr ret;
403 CHAR *name;
404 CHAR *ns;
405
406/****************
407#ifdef DEBUG_SAX
408 fprintf(stderr, "SAX.attribute(%s, %s)\n", fullname, value);
409#endif
410 ****************/
411 /*
412 * Split the full name into a namespace prefix and the tag name
413 */
414 name = xmlSplitQName(fullname, &ns);
415
416 /*
417 * Check whether it's a namespace definition
418 */
419 if ((ns == NULL) &&
420 (name[0] == 'x') && (name[1] == 'm') && (name[2] == 'l') &&
421 (name[3] == 'n') && (name[4] == 's') && (name[5] == 0)) {
422 /* a default namespace definition */
423 xmlNewNs(ctxt->node, value, NULL);
424 if (name != NULL)
425 free(name);
426 return;
427 }
428 if ((ns != NULL) && (ns[0] == 'x') && (ns[1] == 'm') && (ns[2] == 'l') &&
429 (ns[3] == 'n') && (ns[4] == 's') && (ns[5] == 0)) {
430 /* a standard namespace definition */
431 xmlNewNs(ctxt->node, value, name);
432 free(ns);
433 if (name != NULL)
434 free(name);
435 return;
436 }
437
438 ret = xmlNewProp(ctxt->node, name, NULL);
Daniel Veillard011b63c1999-06-02 17:44:04 +0000439 if ((ret != NULL) && (ctxt->replaceEntities == 0))
Daniel Veillard517752b1999-04-05 12:20:10 +0000440 ret->val = xmlStringGetNodeList(ctxt->myDoc, value);
441 if (name != NULL)
442 free(name);
443 if (ns != NULL)
444 free(ns);
445}
446
447/**
Daniel Veillard97b58771998-10-20 06:14:16 +0000448 * startElement:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000449 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000450 * @name: The element name
Daniel Veillard517752b1999-04-05 12:20:10 +0000451 * @atts: An array of name/value attributes pairs, NULL terminated
Daniel Veillard97b58771998-10-20 06:14:16 +0000452 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000453 * called when an opening tag has been processed.
454 * TODO We currently have a small pblm with the arguments ...
455 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000456void
Daniel Veillard27d88741999-05-29 11:51:49 +0000457startElement(void *ctx, const CHAR *fullname, const CHAR **atts)
Daniel Veillard97b58771998-10-20 06:14:16 +0000458{
Daniel Veillard27d88741999-05-29 11:51:49 +0000459 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000460 xmlNodePtr ret;
461 xmlNodePtr parent = ctxt->node;
462 xmlNsPtr ns;
463 CHAR *name;
464 CHAR *prefix;
465 const CHAR *att;
466 const CHAR *value;
467
468 int i;
469
Daniel Veillard260a68f1998-08-13 03:39:55 +0000470#ifdef DEBUG_SAX
Daniel Veillard517752b1999-04-05 12:20:10 +0000471 fprintf(stderr, "SAX.startElement(%s)\n", fullname);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000472#endif
Daniel Veillard517752b1999-04-05 12:20:10 +0000473 /*
474 * Split the full name into a namespace prefix and the tag name
475 */
476 name = xmlSplitQName(fullname, &prefix);
477
478
479 /*
480 * Note : the namespace resolution is deferred until the end of the
481 * attributes parsing, since local namespace can be defined as
482 * an attribute at this level.
483 */
484 ret = xmlNewDocNode(ctxt->myDoc, NULL, name, NULL);
485 if (ret == NULL) return;
486 if (ctxt->myDoc->root == NULL)
487 ctxt->myDoc->root = ret;
488
489 /*
490 * We are parsing a new node.
491 */
492 nodePush(ctxt, ret);
493
494 /*
495 * Link the child element
496 */
497 if (parent != NULL)
498 xmlAddChild(parent, ctxt->node);
499
500 /*
501 * process all the attributes.
502 */
503 if (atts != NULL) {
504 i = 0;
505 att = atts[i++];
506 value = atts[i++];
507 while ((att != NULL) && (value != NULL)) {
508 /*
509 * Handle one pair of attribute/value
510 */
511 attribute(ctxt, att, value);
512
513 /*
514 * Next ones
515 */
516 att = atts[i++];
517 value = atts[i++];
518 }
519 }
520
521 /*
522 * Search the namespace, note that since the attributes have been
523 * processed, the local namespaces are available.
524 */
525 ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
526 if ((ns == NULL) && (parent != NULL))
527 ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
528 xmlSetNs(ret, ns);
529
530 if (prefix != NULL)
531 free(prefix);
532 if (name != NULL)
533 free(name);
534
Daniel Veillard260a68f1998-08-13 03:39:55 +0000535}
536
Daniel Veillard97b58771998-10-20 06:14:16 +0000537/**
538 * endElement:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000539 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000540 * @name: The element name
541 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000542 * called when the end of an element has been detected.
543 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000544void
Daniel Veillard27d88741999-05-29 11:51:49 +0000545endElement(void *ctx, const CHAR *name)
Daniel Veillard97b58771998-10-20 06:14:16 +0000546{
Daniel Veillard27d88741999-05-29 11:51:49 +0000547 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000548 xmlParserNodeInfo node_info;
549 xmlNodePtr cur = ctxt->node;
550
Daniel Veillard260a68f1998-08-13 03:39:55 +0000551#ifdef DEBUG_SAX
Daniel Veillard517752b1999-04-05 12:20:10 +0000552 if (name == NULL)
553 fprintf(stderr, "SAX.endElement(NULL)\n");
554 else
555 fprintf(stderr, "SAX.endElement(%s)\n", name);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000556#endif
Daniel Veillard517752b1999-04-05 12:20:10 +0000557
558 /* Capture end position and add node */
559 if (cur != NULL && ctxt->record_info) {
560 node_info.end_pos = ctxt->input->cur - ctxt->input->base;
561 node_info.end_line = ctxt->input->line;
562 node_info.node = cur;
563 xmlParserAddNodeInfo(ctxt, &node_info);
564 }
565
566 /*
567 * end of parsing of this node.
568 */
569 nodePop(ctxt);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000570}
571
Daniel Veillard97b58771998-10-20 06:14:16 +0000572/**
Daniel Veillard517752b1999-04-05 12:20:10 +0000573 * reference:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000574 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000575 * @name: The entity name
Daniel Veillard11e00581998-10-24 18:27:49 +0000576 *
Daniel Veillard517752b1999-04-05 12:20:10 +0000577 * called when an entity reference is detected.
Daniel Veillard11e00581998-10-24 18:27:49 +0000578 */
579void
Daniel Veillard27d88741999-05-29 11:51:49 +0000580reference(void *ctx, const CHAR *name)
Daniel Veillard11e00581998-10-24 18:27:49 +0000581{
Daniel Veillard27d88741999-05-29 11:51:49 +0000582 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000583 xmlNodePtr ret;
584
Daniel Veillard11e00581998-10-24 18:27:49 +0000585#ifdef DEBUG_SAX
Daniel Veillard517752b1999-04-05 12:20:10 +0000586 fprintf(stderr, "SAX.reference(%s)\n", name);
Daniel Veillard11e00581998-10-24 18:27:49 +0000587#endif
Daniel Veillard517752b1999-04-05 12:20:10 +0000588 ret = xmlNewReference(ctxt->myDoc, name);
589 xmlAddChild(ctxt->node, ret);
Daniel Veillard11e00581998-10-24 18:27:49 +0000590}
591
592/**
Daniel Veillard97b58771998-10-20 06:14:16 +0000593 * characters:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000594 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000595 * @ch: a CHAR string
Daniel Veillard97b58771998-10-20 06:14:16 +0000596 * @len: the number of CHAR
597 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000598 * receiving some chars from the parser.
599 * Question: how much at a time ???
600 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000601void
Daniel Veillard27d88741999-05-29 11:51:49 +0000602characters(void *ctx, const CHAR *ch, int len)
Daniel Veillard97b58771998-10-20 06:14:16 +0000603{
Daniel Veillard27d88741999-05-29 11:51:49 +0000604 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000605 xmlNodePtr lastChild;
606
607#ifdef DEBUG_SAX
Daniel Veillard517752b1999-04-05 12:20:10 +0000608 fprintf(stderr, "SAX.characters(%.30s, %d)\n", ch, len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000609#endif
610 /*
611 * Handle the data if any. If there is no child
612 * add it as content, otherwise if the last child is text,
613 * concatenate it, else create a new node of type text.
614 */
615
616 lastChild = xmlGetLastChild(ctxt->node);
617 if (lastChild == NULL)
Daniel Veillard517752b1999-04-05 12:20:10 +0000618 xmlNodeAddContentLen(ctxt->node, ch, len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000619 else {
620 if (xmlNodeIsText(lastChild))
Daniel Veillard517752b1999-04-05 12:20:10 +0000621 xmlTextConcat(lastChild, ch, len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000622 else {
Daniel Veillard517752b1999-04-05 12:20:10 +0000623 lastChild = xmlNewTextLen(ch, len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000624 xmlAddChild(ctxt->node, lastChild);
625 }
626 }
627}
628
Daniel Veillard97b58771998-10-20 06:14:16 +0000629/**
630 * ignorableWhitespace:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000631 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000632 * @ch: a CHAR string
Daniel Veillard97b58771998-10-20 06:14:16 +0000633 * @len: the number of CHAR
634 *
Daniel Veillard260a68f1998-08-13 03:39:55 +0000635 * receiving some ignorable whitespaces from the parser.
636 * Question: how much at a time ???
637 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000638void
Daniel Veillard27d88741999-05-29 11:51:49 +0000639ignorableWhitespace(void *ctx, const CHAR *ch, int len)
Daniel Veillard97b58771998-10-20 06:14:16 +0000640{
Daniel Veillard27d88741999-05-29 11:51:49 +0000641 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000642#ifdef DEBUG_SAX
Daniel Veillard517752b1999-04-05 12:20:10 +0000643 fprintf(stderr, "SAX.ignorableWhitespace(%.30s, %d)\n", ch, len);
Daniel Veillard260a68f1998-08-13 03:39:55 +0000644#endif
645}
646
Daniel Veillard97b58771998-10-20 06:14:16 +0000647/**
648 * processingInstruction:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000649 * @ctx: the user data (XML parser context)
Daniel Veillard97b58771998-10-20 06:14:16 +0000650 * @target: the target name
651 * @data: the PI data's
652 * @len: the number of CHAR
653 *
654 * A processing instruction has been parsed.
Daniel Veillard260a68f1998-08-13 03:39:55 +0000655 */
Daniel Veillard97b58771998-10-20 06:14:16 +0000656void
Daniel Veillard27d88741999-05-29 11:51:49 +0000657processingInstruction(void *ctx, const CHAR *target,
Daniel Veillard97b58771998-10-20 06:14:16 +0000658 const CHAR *data)
659{
Daniel Veillard27d88741999-05-29 11:51:49 +0000660 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000661#ifdef DEBUG_SAX
662 fprintf(stderr, "SAX.processingInstruction(%s, %s)\n", target, data);
663#endif
664}
665
Daniel Veillard517752b1999-04-05 12:20:10 +0000666/**
667 * globalNamespace:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000668 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000669 * @href: the namespace associated URN
670 * @prefix: the namespace prefix
671 *
672 * An old global namespace has been parsed.
673 */
674void
Daniel Veillard27d88741999-05-29 11:51:49 +0000675globalNamespace(void *ctx, const CHAR *href, const CHAR *prefix)
Daniel Veillard517752b1999-04-05 12:20:10 +0000676{
Daniel Veillard27d88741999-05-29 11:51:49 +0000677 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000678#ifdef DEBUG_SAX
679 fprintf(stderr, "SAX.globalNamespace(%s, %s)\n", href, prefix);
680#endif
681 xmlNewGlobalNs(ctxt->myDoc, href, prefix);
682}
683
684/**
685 * setNamespace:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000686 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000687 * @name: the namespace prefix
688 *
689 * Set the current element namespace.
690 */
691void
Daniel Veillard27d88741999-05-29 11:51:49 +0000692setNamespace(void *ctx, const CHAR *name)
Daniel Veillard517752b1999-04-05 12:20:10 +0000693{
Daniel Veillard27d88741999-05-29 11:51:49 +0000694 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000695 xmlNsPtr ns;
696 xmlNodePtr parent;
697
698#ifdef DEBUG_SAX
699 fprintf(stderr, "SAX.setNamespace(%s)\n", name);
700#endif
701 ns = xmlSearchNs(ctxt->myDoc, ctxt->node, name);
702 if (ns == NULL) { /* ctxt->node may not have a parent yet ! */
703 if (ctxt->nodeNr >= 2) {
704 parent = ctxt->nodeTab[ctxt->nodeNr - 2];
705 if (parent != NULL)
706 ns = xmlSearchNs(ctxt->myDoc, parent, name);
707 }
708 }
709 xmlSetNs(ctxt->node, ns);
710}
711
712/**
713 * getNamespace:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000714 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000715 *
716 * Get the current element namespace.
717 */
718xmlNsPtr
Daniel Veillard27d88741999-05-29 11:51:49 +0000719getNamespace(void *ctx)
Daniel Veillard517752b1999-04-05 12:20:10 +0000720{
Daniel Veillard27d88741999-05-29 11:51:49 +0000721 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000722 xmlNsPtr ret;
723
724#ifdef DEBUG_SAX
725 fprintf(stderr, "SAX.getNamespace()\n");
726#endif
727 ret = ctxt->node->ns;
728 return(ret);
729}
730
731/**
732 * checkNamespace:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000733 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000734 * @namespace: the namespace to check against
735 *
736 * Check that the current element namespace is the same as the
737 * one read upon parsing.
738 */
739int
Daniel Veillard27d88741999-05-29 11:51:49 +0000740checkNamespace(void *ctx, CHAR *namespace)
Daniel Veillard517752b1999-04-05 12:20:10 +0000741{
Daniel Veillard27d88741999-05-29 11:51:49 +0000742 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000743 xmlNodePtr cur = ctxt->node;
744
745#ifdef DEBUG_SAX
746 fprintf(stderr, "SAX.checkNamespace(%s)\n", namespace);
747#endif
748
749 /*
750 * Check that the Name in the ETag is the same as in the STag.
751 */
752 if (namespace == NULL) {
753 if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
754 if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
755 ctxt->sax->error(ctxt,
756 "End tags for %s don't hold the namespace %s\n",
757 cur->name, cur->ns->prefix);
758 ctxt->wellFormed = 0;
759 }
760 } else {
761 if ((cur->ns == NULL) || (cur->ns->prefix == NULL)) {
762 if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
763 ctxt->sax->error(ctxt,
764 "End tags %s holds a prefix %s not used by the open tag\n",
765 cur->name, namespace);
766 ctxt->wellFormed = 0;
767 } else if (strcmp(namespace, cur->ns->prefix)) {
768 if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
769 ctxt->sax->error(ctxt,
770 "Start and End tags for %s don't use the same namespaces: %s and %s\n",
771 cur->name, cur->ns->prefix, namespace);
772 ctxt->wellFormed = 0;
773 } else
774 return(1);
775 }
776 return(0);
777}
778
779/**
780 * namespaceDecl:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000781 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000782 * @href: the namespace associated URN
783 * @prefix: the namespace prefix
784 *
785 * A namespace has been parsed.
786 */
787void
Daniel Veillard27d88741999-05-29 11:51:49 +0000788namespaceDecl(void *ctx, const CHAR *href, const CHAR *prefix)
Daniel Veillard517752b1999-04-05 12:20:10 +0000789{
Daniel Veillard27d88741999-05-29 11:51:49 +0000790 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard517752b1999-04-05 12:20:10 +0000791#ifdef DEBUG_SAX
792 if (prefix == NULL)
793 fprintf(stderr, "SAX.namespaceDecl(%s, NULL)\n", href);
794 else
795 fprintf(stderr, "SAX.namespaceDecl(%s, %s)\n", href, prefix);
796#endif
797 xmlNewNs(ctxt->node, href, prefix);
798}
799
800/**
801 * comment:
Daniel Veillard011b63c1999-06-02 17:44:04 +0000802 * @ctx: the user data (XML parser context)
Daniel Veillard517752b1999-04-05 12:20:10 +0000803 * @value: the comment content
804 *
805 * A comment has been parsed.
806 */
807void
Daniel Veillard27d88741999-05-29 11:51:49 +0000808comment(void *ctx, const CHAR *value)
Daniel Veillard517752b1999-04-05 12:20:10 +0000809{
Daniel Veillard27d88741999-05-29 11:51:49 +0000810 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Daniel Veillard14fff061999-06-22 21:49:07 +0000811 xmlNodePtr ret;
812
Daniel Veillard517752b1999-04-05 12:20:10 +0000813#ifdef DEBUG_SAX
814 fprintf(stderr, "SAX.comment(%s)\n", value);
815#endif
Daniel Veillard14fff061999-06-22 21:49:07 +0000816 ret = xmlNewDocComment(ctxt->myDoc, value);
817 xmlAddChild(ctxt->node, ret);
Daniel Veillard517752b1999-04-05 12:20:10 +0000818}
819
Daniel Veillardbe70ff71999-07-05 16:50:46 +0000820/*
821 * Default handler for XML, builds the DOM tree
822 */
Daniel Veillard260a68f1998-08-13 03:39:55 +0000823xmlSAXHandler xmlDefaultSAXHandler = {
Daniel Veillard517752b1999-04-05 12:20:10 +0000824 internalSubset,
825 isStandalone,
826 hasInternalSubset,
827 hasExternalSubset,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000828 resolveEntity,
Daniel Veillard517752b1999-04-05 12:20:10 +0000829 getEntity,
830 entityDecl,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000831 notationDecl,
Daniel Veillard517752b1999-04-05 12:20:10 +0000832 attributeDecl,
833 elementDecl,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000834 unparsedEntityDecl,
835 setDocumentLocator,
836 startDocument,
837 endDocument,
838 startElement,
839 endElement,
Daniel Veillard517752b1999-04-05 12:20:10 +0000840 reference,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000841 characters,
842 ignorableWhitespace,
843 processingInstruction,
Daniel Veillard517752b1999-04-05 12:20:10 +0000844 comment,
Daniel Veillard260a68f1998-08-13 03:39:55 +0000845 xmlParserWarning,
846 xmlParserError,
847 xmlParserError,
848};
849
Daniel Veillard97b58771998-10-20 06:14:16 +0000850/**
851 * xmlDefaultSAXHandlerInit:
852 *
853 * Initialize the default SAX handler
Daniel Veillard97b58771998-10-20 06:14:16 +0000854 */
855void
856xmlDefaultSAXHandlerInit(void)
857{
Daniel Veillard517752b1999-04-05 12:20:10 +0000858 xmlDefaultSAXHandler.internalSubset = internalSubset;
859 xmlDefaultSAXHandler.isStandalone = isStandalone;
860 xmlDefaultSAXHandler.hasInternalSubset = hasInternalSubset;
861 xmlDefaultSAXHandler.hasExternalSubset = hasExternalSubset;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000862 xmlDefaultSAXHandler.resolveEntity = resolveEntity;
Daniel Veillard517752b1999-04-05 12:20:10 +0000863 xmlDefaultSAXHandler.getEntity = getEntity;
864 xmlDefaultSAXHandler.entityDecl = entityDecl;
865 xmlDefaultSAXHandler.attributeDecl = attributeDecl;
866 xmlDefaultSAXHandler.elementDecl = elementDecl;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000867 xmlDefaultSAXHandler.notationDecl = notationDecl;
868 xmlDefaultSAXHandler.unparsedEntityDecl = unparsedEntityDecl;
869 xmlDefaultSAXHandler.setDocumentLocator = setDocumentLocator;
870 xmlDefaultSAXHandler.startDocument = startDocument;
871 xmlDefaultSAXHandler.endDocument = endDocument;
872 xmlDefaultSAXHandler.startElement = startElement;
873 xmlDefaultSAXHandler.endElement = endElement;
Daniel Veillard517752b1999-04-05 12:20:10 +0000874 xmlDefaultSAXHandler.reference = reference;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000875 xmlDefaultSAXHandler.characters = characters;
876 xmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
877 xmlDefaultSAXHandler.processingInstruction = processingInstruction;
Daniel Veillard517752b1999-04-05 12:20:10 +0000878 xmlDefaultSAXHandler.comment = comment;
Daniel Veillard260a68f1998-08-13 03:39:55 +0000879 xmlDefaultSAXHandler.warning = xmlParserWarning;
880 xmlDefaultSAXHandler.error = xmlParserError;
881 xmlDefaultSAXHandler.fatalError = xmlParserError;
882}
Daniel Veillardbe70ff71999-07-05 16:50:46 +0000883
884/*
885 * Default handler for HTML, builds the DOM tree
886 */
887xmlSAXHandler htmlDefaultSAXHandler = {
888 NULL,
889 NULL,
890 NULL,
891 NULL,
892 NULL,
893 getEntity,
894 NULL,
895 NULL,
896 NULL,
897 NULL,
898 NULL,
899 setDocumentLocator,
900 startDocument,
901 endDocument,
902 startElement,
903 endElement,
904 NULL,
905 characters,
906 ignorableWhitespace,
907 NULL,
908 comment,
909 xmlParserWarning,
910 xmlParserError,
911 xmlParserError,
912};
913
914/**
915 * htmlDefaultSAXHandlerInit:
916 *
917 * Initialize the default SAX handler
918 */
919void
920htmlDefaultSAXHandlerInit(void)
921{
922 htmlDefaultSAXHandler.internalSubset = NULL;
923 htmlDefaultSAXHandler.isStandalone = NULL;
924 htmlDefaultSAXHandler.hasInternalSubset = NULL;
925 htmlDefaultSAXHandler.hasExternalSubset = NULL;
926 htmlDefaultSAXHandler.resolveEntity = NULL;
927 htmlDefaultSAXHandler.getEntity = getEntity;
928 htmlDefaultSAXHandler.entityDecl = NULL;
929 htmlDefaultSAXHandler.attributeDecl = NULL;
930 htmlDefaultSAXHandler.elementDecl = NULL;
931 htmlDefaultSAXHandler.notationDecl = NULL;
932 htmlDefaultSAXHandler.unparsedEntityDecl = NULL;
933 htmlDefaultSAXHandler.setDocumentLocator = setDocumentLocator;
934 htmlDefaultSAXHandler.startDocument = startDocument;
935 htmlDefaultSAXHandler.endDocument = endDocument;
936 htmlDefaultSAXHandler.startElement = startElement;
937 htmlDefaultSAXHandler.endElement = endElement;
938 htmlDefaultSAXHandler.reference = NULL;
939 htmlDefaultSAXHandler.characters = characters;
940 htmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
941 htmlDefaultSAXHandler.processingInstruction = NULL;
942 htmlDefaultSAXHandler.comment = comment;
943 htmlDefaultSAXHandler.warning = xmlParserWarning;
944 htmlDefaultSAXHandler.error = xmlParserError;
945 htmlDefaultSAXHandler.fatalError = xmlParserError;
946}