blob: 0ff2017d30c6c7c85054464b5f8359aa87bcce17 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
Daniel Veillard1af9a412003-08-20 22:54:39 +00002 * SAX.c : Old SAX v1 handlers to build a tree.
3 * Deprecated except for compatibility
Owen Taylor3473f882001-02-23 17:55:21 +00004 *
5 * See Copyright for the status of this software.
6 *
Daniel Veillardc5d64342001-06-24 12:13:24 +00007 * Daniel Veillard <daniel@veillard.com>
Owen Taylor3473f882001-02-23 17:55:21 +00008 */
9
10
Daniel Veillard34ce8be2002-03-18 19:37:11 +000011#define IN_LIBXML
Bjorn Reese70a9da52001-04-21 16:57:29 +000012#include "libxml.h"
Owen Taylor3473f882001-02-23 17:55:21 +000013#include <stdlib.h>
14#include <string.h>
15#include <libxml/xmlmemory.h>
16#include <libxml/tree.h>
17#include <libxml/parser.h>
18#include <libxml/parserInternals.h>
19#include <libxml/valid.h>
20#include <libxml/entities.h>
21#include <libxml/xmlerror.h>
22#include <libxml/debugXML.h>
23#include <libxml/xmlIO.h>
24#include <libxml/SAX.h>
25#include <libxml/uri.h>
Daniel Veillard48da9102001-08-07 01:10:10 +000026#include <libxml/valid.h>
Owen Taylor3473f882001-02-23 17:55:21 +000027#include <libxml/HTMLtree.h>
Daniel Veillard3c01b1d2001-10-17 15:58:35 +000028#include <libxml/globals.h>
Daniel Veillard1af9a412003-08-20 22:54:39 +000029#include <libxml/SAX2.h>
Owen Taylor3473f882001-02-23 17:55:21 +000030
Daniel Veillard81273902003-09-30 00:43:48 +000031#ifdef LIBXML_SAX1_ENABLED
Daniel Veillardd0463562001-10-13 09:15:48 +000032/**
Daniel Veillard9d06d302002-01-22 18:15:52 +000033 * initxmlDefaultSAXHandler:
Daniel Veillardcbaf3992001-12-31 16:16:02 +000034 * @hdlr: the SAX handler
35 * @warning: flag if non-zero sets the handler warning procedure
Daniel Veillardd0463562001-10-13 09:15:48 +000036 *
Daniel Veillard1af9a412003-08-20 22:54:39 +000037 * Initialize the default XML SAX version 1 handler
38 * DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
Owen Taylor3473f882001-02-23 17:55:21 +000039 */
Daniel Veillardd0463562001-10-13 09:15:48 +000040void
Daniel Veillard092643b2003-09-25 14:29:29 +000041initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
Daniel Veillardd0463562001-10-13 09:15:48 +000042{
Daniel Veillard1af9a412003-08-20 22:54:39 +000043
Daniel Veillardd0463562001-10-13 09:15:48 +000044 if(hdlr->initialized == 1)
45 return;
46
Daniel Veillard1af9a412003-08-20 22:54:39 +000047 hdlr->internalSubset = xmlSAX2InternalSubset;
48 hdlr->externalSubset = xmlSAX2ExternalSubset;
49 hdlr->isStandalone = xmlSAX2IsStandalone;
50 hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
51 hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
52 hdlr->resolveEntity = xmlSAX2ResolveEntity;
53 hdlr->getEntity = xmlSAX2GetEntity;
54 hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
55 hdlr->entityDecl = xmlSAX2EntityDecl;
56 hdlr->attributeDecl = xmlSAX2AttributeDecl;
57 hdlr->elementDecl = xmlSAX2ElementDecl;
58 hdlr->notationDecl = xmlSAX2NotationDecl;
59 hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
60 hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
61 hdlr->startDocument = xmlSAX2StartDocument;
62 hdlr->endDocument = xmlSAX2EndDocument;
63 hdlr->startElement = xmlSAX2StartElement;
64 hdlr->endElement = xmlSAX2EndElement;
65 hdlr->reference = xmlSAX2Reference;
66 hdlr->characters = xmlSAX2Characters;
67 hdlr->cdataBlock = xmlSAX2CDataBlock;
68 hdlr->ignorableWhitespace = xmlSAX2Characters;
69 hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
Daniel Veillardd0463562001-10-13 09:15:48 +000070 if (warning == 0)
71 hdlr->warning = NULL;
72 else
73 hdlr->warning = xmlParserWarning;
74 hdlr->error = xmlParserError;
75 hdlr->fatalError = xmlParserError;
76
77 hdlr->initialized = 1;
78}
Daniel Veillard81273902003-09-30 00:43:48 +000079#endif /* LIBXML_SAX1_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +000080
Daniel Veillardeae522a2001-04-23 13:41:34 +000081#ifdef LIBXML_HTML_ENABLED
Daniel Veillardd0463562001-10-13 09:15:48 +000082
83/**
Daniel Veillard9d06d302002-01-22 18:15:52 +000084 * inithtmlDefaultSAXHandler:
Daniel Veillardcbaf3992001-12-31 16:16:02 +000085 * @hdlr: the SAX handler
Daniel Veillardd0463562001-10-13 09:15:48 +000086 *
Daniel Veillard1af9a412003-08-20 22:54:39 +000087 * Initialize the default HTML SAX version 1 handler
88 * DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
Owen Taylor3473f882001-02-23 17:55:21 +000089 */
Daniel Veillardd0463562001-10-13 09:15:48 +000090void
Daniel Veillard092643b2003-09-25 14:29:29 +000091inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
Daniel Veillardd0463562001-10-13 09:15:48 +000092{
93 if(hdlr->initialized == 1)
94 return;
95
Daniel Veillard1af9a412003-08-20 22:54:39 +000096 hdlr->internalSubset = xmlSAX2InternalSubset;
Daniel Veillardd0463562001-10-13 09:15:48 +000097 hdlr->externalSubset = NULL;
98 hdlr->isStandalone = NULL;
99 hdlr->hasInternalSubset = NULL;
100 hdlr->hasExternalSubset = NULL;
101 hdlr->resolveEntity = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000102 hdlr->getEntity = xmlSAX2GetEntity;
Daniel Veillardd0463562001-10-13 09:15:48 +0000103 hdlr->getParameterEntity = NULL;
104 hdlr->entityDecl = NULL;
105 hdlr->attributeDecl = NULL;
106 hdlr->elementDecl = NULL;
107 hdlr->notationDecl = NULL;
108 hdlr->unparsedEntityDecl = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000109 hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
110 hdlr->startDocument = xmlSAX2StartDocument;
111 hdlr->endDocument = xmlSAX2EndDocument;
112 hdlr->startElement = xmlSAX2StartElement;
113 hdlr->endElement = xmlSAX2EndElement;
Daniel Veillardd0463562001-10-13 09:15:48 +0000114 hdlr->reference = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000115 hdlr->characters = xmlSAX2Characters;
116 hdlr->cdataBlock = xmlSAX2CDataBlock;
117 hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
Daniel Veillardd0463562001-10-13 09:15:48 +0000118 hdlr->processingInstruction = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000119 hdlr->comment = xmlSAX2Comment;
Daniel Veillardd0463562001-10-13 09:15:48 +0000120 hdlr->warning = xmlParserWarning;
121 hdlr->error = xmlParserError;
122 hdlr->fatalError = xmlParserError;
123
124 hdlr->initialized = 1;
125}
Owen Taylor3473f882001-02-23 17:55:21 +0000126
Daniel Veillardeae522a2001-04-23 13:41:34 +0000127#endif /* LIBXML_HTML_ENABLED */
Owen Taylor3473f882001-02-23 17:55:21 +0000128
Daniel Veillardeae522a2001-04-23 13:41:34 +0000129#ifdef LIBXML_DOCB_ENABLED
Daniel Veillardd0463562001-10-13 09:15:48 +0000130
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000131/**
Daniel Veillard9d06d302002-01-22 18:15:52 +0000132 * initdocbDefaultSAXHandler:
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000133 * @hdlr: the SAX handler
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000134 *
Daniel Veillard1af9a412003-08-20 22:54:39 +0000135 * Initialize the default DocBook SAX version 1 handler
136 * DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000137 */
Daniel Veillardd0463562001-10-13 09:15:48 +0000138void
Daniel Veillard092643b2003-09-25 14:29:29 +0000139initdocbDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
Daniel Veillardd0463562001-10-13 09:15:48 +0000140{
141 if(hdlr->initialized == 1)
142 return;
143
Daniel Veillard1af9a412003-08-20 22:54:39 +0000144 hdlr->internalSubset = xmlSAX2InternalSubset;
Daniel Veillardd0463562001-10-13 09:15:48 +0000145 hdlr->externalSubset = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000146 hdlr->isStandalone = xmlSAX2IsStandalone;
147 hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
148 hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
149 hdlr->resolveEntity = xmlSAX2ResolveEntity;
150 hdlr->getEntity = xmlSAX2GetEntity;
Daniel Veillardd0463562001-10-13 09:15:48 +0000151 hdlr->getParameterEntity = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000152 hdlr->entityDecl = xmlSAX2EntityDecl;
Daniel Veillardd0463562001-10-13 09:15:48 +0000153 hdlr->attributeDecl = NULL;
154 hdlr->elementDecl = NULL;
155 hdlr->notationDecl = NULL;
156 hdlr->unparsedEntityDecl = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000157 hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
158 hdlr->startDocument = xmlSAX2StartDocument;
159 hdlr->endDocument = xmlSAX2EndDocument;
160 hdlr->startElement = xmlSAX2StartElement;
161 hdlr->endElement = xmlSAX2EndElement;
162 hdlr->reference = xmlSAX2Reference;
163 hdlr->characters = xmlSAX2Characters;
Daniel Veillardd0463562001-10-13 09:15:48 +0000164 hdlr->cdataBlock = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000165 hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
Daniel Veillardd0463562001-10-13 09:15:48 +0000166 hdlr->processingInstruction = NULL;
Daniel Veillard1af9a412003-08-20 22:54:39 +0000167 hdlr->comment = xmlSAX2Comment;
Daniel Veillardd0463562001-10-13 09:15:48 +0000168 hdlr->warning = xmlParserWarning;
169 hdlr->error = xmlParserError;
170 hdlr->fatalError = xmlParserError;
171
172 hdlr->initialized = 1;
173}
Owen Taylor3473f882001-02-23 17:55:21 +0000174
Daniel Veillardeae522a2001-04-23 13:41:34 +0000175#endif /* LIBXML_DOCB_ENABLED */