SAX.c 5.4 KB
Newer Older
1
/*
2 3
 * SAX.c : Old SAX v1 handlers to build a tree.
 *         Deprecated except for compatibility
4 5 6
 *
 * See Copyright for the status of this software.
 *
7
 * Daniel Veillard <daniel@veillard.com>
8 9 10
 */


11
#define IN_LIBXML
Bjorn Reese's avatar
Bjorn Reese committed
12
#include "libxml.h"
13 14 15 16 17 18 19 20 21 22 23 24 25
#include <stdlib.h>
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/valid.h>
#include <libxml/entities.h>
#include <libxml/xmlerror.h>
#include <libxml/debugXML.h>
#include <libxml/xmlIO.h>
#include <libxml/SAX.h>
#include <libxml/uri.h>
26
#include <libxml/valid.h>
27
#include <libxml/HTMLtree.h>
28
#include <libxml/globals.h>
29
#include <libxml/SAX2.h>
30

31
#ifdef LIBXML_LEGACY_ENABLED
32
#ifdef LIBXML_SAX1_ENABLED
33
/**
34
 * initxmlDefaultSAXHandler:
35 36
 * @hdlr:  the SAX handler
 * @warning:  flag if non-zero sets the handler warning procedure
37
 *
38 39
 * Initialize the default XML SAX version 1 handler
 * DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
40 41
 */
void
42
initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
43
{
44
    
45
    if(hdlr->initialized == 1)
46 47
	return;

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    hdlr->internalSubset = xmlSAX2InternalSubset;
    hdlr->externalSubset = xmlSAX2ExternalSubset;
    hdlr->isStandalone = xmlSAX2IsStandalone;
    hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
    hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
    hdlr->resolveEntity = xmlSAX2ResolveEntity;
    hdlr->getEntity = xmlSAX2GetEntity;
    hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
    hdlr->entityDecl = xmlSAX2EntityDecl;
    hdlr->attributeDecl = xmlSAX2AttributeDecl;
    hdlr->elementDecl = xmlSAX2ElementDecl;
    hdlr->notationDecl = xmlSAX2NotationDecl;
    hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
    hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
    hdlr->startDocument = xmlSAX2StartDocument;
    hdlr->endDocument = xmlSAX2EndDocument;
    hdlr->startElement = xmlSAX2StartElement;
    hdlr->endElement = xmlSAX2EndElement;
    hdlr->reference = xmlSAX2Reference;
    hdlr->characters = xmlSAX2Characters;
    hdlr->cdataBlock = xmlSAX2CDataBlock;
    hdlr->ignorableWhitespace = xmlSAX2Characters;
    hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
71 72
    if (warning == 0)
	hdlr->warning = NULL;
73
    else
74 75 76
	hdlr->warning = xmlParserWarning;
    hdlr->error = xmlParserError;
    hdlr->fatalError = xmlParserError;
77

78
    hdlr->initialized = 1;
79 80
}

81
#ifdef LIBXML_HTML_ENABLED
82 83

/**
84
 * inithtmlDefaultSAXHandler:
85
 * @hdlr:  the SAX handler
86
 *
87 88
 * Initialize the default HTML SAX version 1 handler
 * DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
89 90
 */
void
91
inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
92
{
93
    if(hdlr->initialized == 1)
94 95
	return;

96
    hdlr->internalSubset = xmlSAX2InternalSubset;
97 98 99 100 101
    hdlr->externalSubset = NULL;
    hdlr->isStandalone = NULL;
    hdlr->hasInternalSubset = NULL;
    hdlr->hasExternalSubset = NULL;
    hdlr->resolveEntity = NULL;
102
    hdlr->getEntity = xmlSAX2GetEntity;
103 104 105 106 107 108
    hdlr->getParameterEntity = NULL;
    hdlr->entityDecl = NULL;
    hdlr->attributeDecl = NULL;
    hdlr->elementDecl = NULL;
    hdlr->notationDecl = NULL;
    hdlr->unparsedEntityDecl = NULL;
109 110 111 112 113
    hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
    hdlr->startDocument = xmlSAX2StartDocument;
    hdlr->endDocument = xmlSAX2EndDocument;
    hdlr->startElement = xmlSAX2StartElement;
    hdlr->endElement = xmlSAX2EndElement;
114
    hdlr->reference = NULL;
115 116 117
    hdlr->characters = xmlSAX2Characters;
    hdlr->cdataBlock = xmlSAX2CDataBlock;
    hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
118
    hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
119
    hdlr->processingInstruction = NULL;
120
    hdlr->comment = xmlSAX2Comment;
121 122 123 124 125
    hdlr->warning = xmlParserWarning;
    hdlr->error = xmlParserError;
    hdlr->fatalError = xmlParserError;

    hdlr->initialized = 1;
126
}
127

128
#endif /* LIBXML_HTML_ENABLED */
129

130
#ifdef LIBXML_DOCB_ENABLED
131
/**
132
 * initdocbDefaultSAXHandler:
133 134
 * @hdlr:  the SAX handler
 *
135 136
 * Initialize the default DocBook SAX version 1 handler
 * DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks
137
 */
138
void
139
initdocbDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
140 141 142 143
{
    if(hdlr->initialized == 1)
	return;

144
    hdlr->internalSubset = xmlSAX2InternalSubset;
145
    hdlr->externalSubset = NULL;
146 147 148 149 150
    hdlr->isStandalone = xmlSAX2IsStandalone;
    hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
    hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
    hdlr->resolveEntity = xmlSAX2ResolveEntity;
    hdlr->getEntity = xmlSAX2GetEntity;
151
    hdlr->getParameterEntity = NULL;
152
    hdlr->entityDecl = xmlSAX2EntityDecl;
153 154 155 156
    hdlr->attributeDecl = NULL;
    hdlr->elementDecl = NULL;
    hdlr->notationDecl = NULL;
    hdlr->unparsedEntityDecl = NULL;
157 158 159 160 161 162 163
    hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
    hdlr->startDocument = xmlSAX2StartDocument;
    hdlr->endDocument = xmlSAX2EndDocument;
    hdlr->startElement = xmlSAX2StartElement;
    hdlr->endElement = xmlSAX2EndElement;
    hdlr->reference = xmlSAX2Reference;
    hdlr->characters = xmlSAX2Characters;
164
    hdlr->cdataBlock = NULL;
165
    hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
166
    hdlr->processingInstruction = NULL;
167
    hdlr->comment = xmlSAX2Comment;
168 169 170 171 172 173
    hdlr->warning = xmlParserWarning;
    hdlr->error = xmlParserError;
    hdlr->fatalError = xmlParserError;

    hdlr->initialized = 1;
}
174

175
#endif /* LIBXML_DOCB_ENABLED */
176 177 178 179

#endif /* LIBXML_SAX1_ENABLED */

#endif /* LIBXML_LEGACY_ENABLED */