Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1 | /* |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 2 | * SAX.c : Old SAX v1 handlers to build a tree. |
| 3 | * Deprecated except for compatibility |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 4 | * |
| 5 | * See Copyright for the status of this software. |
| 6 | * |
Daniel Veillard | c5d6434 | 2001-06-24 12:13:24 +0000 | [diff] [blame] | 7 | * Daniel Veillard <daniel@veillard.com> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | |
Daniel Veillard | 34ce8be | 2002-03-18 19:37:11 +0000 | [diff] [blame] | 11 | #define IN_LIBXML |
Bjorn Reese | 70a9da5 | 2001-04-21 16:57:29 +0000 | [diff] [blame] | 12 | #include "libxml.h" |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 13 | #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 Veillard | 48da910 | 2001-08-07 01:10:10 +0000 | [diff] [blame] | 26 | #include <libxml/valid.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 27 | #include <libxml/HTMLtree.h> |
Daniel Veillard | 3c01b1d | 2001-10-17 15:58:35 +0000 | [diff] [blame] | 28 | #include <libxml/globals.h> |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 29 | #include <libxml/SAX2.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 30 | |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 31 | #ifdef LIBXML_LEGACY_ENABLED |
Daniel Veillard | 8127390 | 2003-09-30 00:43:48 +0000 | [diff] [blame] | 32 | #ifdef LIBXML_SAX1_ENABLED |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 33 | /** |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 34 | * initxmlDefaultSAXHandler: |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 35 | * @hdlr: the SAX handler |
| 36 | * @warning: flag if non-zero sets the handler warning procedure |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 37 | * |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 38 | * Initialize the default XML SAX version 1 handler |
| 39 | * DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 40 | */ |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 41 | void |
Daniel Veillard | 092643b | 2003-09-25 14:29:29 +0000 | [diff] [blame] | 42 | initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning) |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 43 | { |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 44 | |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 45 | if(hdlr->initialized == 1) |
| 46 | return; |
| 47 | |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 48 | hdlr->internalSubset = xmlSAX2InternalSubset; |
| 49 | hdlr->externalSubset = xmlSAX2ExternalSubset; |
| 50 | hdlr->isStandalone = xmlSAX2IsStandalone; |
| 51 | hdlr->hasInternalSubset = xmlSAX2HasInternalSubset; |
| 52 | hdlr->hasExternalSubset = xmlSAX2HasExternalSubset; |
| 53 | hdlr->resolveEntity = xmlSAX2ResolveEntity; |
| 54 | hdlr->getEntity = xmlSAX2GetEntity; |
| 55 | hdlr->getParameterEntity = xmlSAX2GetParameterEntity; |
| 56 | hdlr->entityDecl = xmlSAX2EntityDecl; |
| 57 | hdlr->attributeDecl = xmlSAX2AttributeDecl; |
| 58 | hdlr->elementDecl = xmlSAX2ElementDecl; |
| 59 | hdlr->notationDecl = xmlSAX2NotationDecl; |
| 60 | hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl; |
| 61 | hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator; |
| 62 | hdlr->startDocument = xmlSAX2StartDocument; |
| 63 | hdlr->endDocument = xmlSAX2EndDocument; |
| 64 | hdlr->startElement = xmlSAX2StartElement; |
| 65 | hdlr->endElement = xmlSAX2EndElement; |
| 66 | hdlr->reference = xmlSAX2Reference; |
| 67 | hdlr->characters = xmlSAX2Characters; |
| 68 | hdlr->cdataBlock = xmlSAX2CDataBlock; |
| 69 | hdlr->ignorableWhitespace = xmlSAX2Characters; |
| 70 | hdlr->processingInstruction = xmlSAX2ProcessingInstruction; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 71 | if (warning == 0) |
| 72 | hdlr->warning = NULL; |
| 73 | else |
| 74 | hdlr->warning = xmlParserWarning; |
| 75 | hdlr->error = xmlParserError; |
| 76 | hdlr->fatalError = xmlParserError; |
| 77 | |
| 78 | hdlr->initialized = 1; |
| 79 | } |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 80 | |
Daniel Veillard | eae522a | 2001-04-23 13:41:34 +0000 | [diff] [blame] | 81 | #ifdef LIBXML_HTML_ENABLED |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 82 | |
| 83 | /** |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 84 | * inithtmlDefaultSAXHandler: |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 85 | * @hdlr: the SAX handler |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 86 | * |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 87 | * Initialize the default HTML SAX version 1 handler |
| 88 | * DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 89 | */ |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 90 | void |
Daniel Veillard | 092643b | 2003-09-25 14:29:29 +0000 | [diff] [blame] | 91 | inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr) |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 92 | { |
| 93 | if(hdlr->initialized == 1) |
| 94 | return; |
| 95 | |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 96 | hdlr->internalSubset = xmlSAX2InternalSubset; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 97 | hdlr->externalSubset = NULL; |
| 98 | hdlr->isStandalone = NULL; |
| 99 | hdlr->hasInternalSubset = NULL; |
| 100 | hdlr->hasExternalSubset = NULL; |
| 101 | hdlr->resolveEntity = NULL; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 102 | hdlr->getEntity = xmlSAX2GetEntity; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 103 | hdlr->getParameterEntity = NULL; |
| 104 | hdlr->entityDecl = NULL; |
| 105 | hdlr->attributeDecl = NULL; |
| 106 | hdlr->elementDecl = NULL; |
| 107 | hdlr->notationDecl = NULL; |
| 108 | hdlr->unparsedEntityDecl = NULL; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 109 | hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator; |
| 110 | hdlr->startDocument = xmlSAX2StartDocument; |
| 111 | hdlr->endDocument = xmlSAX2EndDocument; |
| 112 | hdlr->startElement = xmlSAX2StartElement; |
| 113 | hdlr->endElement = xmlSAX2EndElement; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 114 | hdlr->reference = NULL; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 115 | hdlr->characters = xmlSAX2Characters; |
| 116 | hdlr->cdataBlock = xmlSAX2CDataBlock; |
| 117 | hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace; |
Daniel Veillard | fc484dd | 2004-10-22 14:34:23 +0000 | [diff] [blame] | 118 | hdlr->processingInstruction = xmlSAX2ProcessingInstruction; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 119 | hdlr->comment = xmlSAX2Comment; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 120 | hdlr->warning = xmlParserWarning; |
| 121 | hdlr->error = xmlParserError; |
| 122 | hdlr->fatalError = xmlParserError; |
| 123 | |
| 124 | hdlr->initialized = 1; |
| 125 | } |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 126 | |
Daniel Veillard | eae522a | 2001-04-23 13:41:34 +0000 | [diff] [blame] | 127 | #endif /* LIBXML_HTML_ENABLED */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 128 | |
Daniel Veillard | eae522a | 2001-04-23 13:41:34 +0000 | [diff] [blame] | 129 | #ifdef LIBXML_DOCB_ENABLED |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 130 | /** |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 131 | * initdocbDefaultSAXHandler: |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 132 | * @hdlr: the SAX handler |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 133 | * |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 134 | * Initialize the default DocBook SAX version 1 handler |
| 135 | * DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 136 | */ |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 137 | void |
Daniel Veillard | 092643b | 2003-09-25 14:29:29 +0000 | [diff] [blame] | 138 | initdocbDefaultSAXHandler(xmlSAXHandlerV1 *hdlr) |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 139 | { |
| 140 | if(hdlr->initialized == 1) |
| 141 | return; |
| 142 | |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 143 | hdlr->internalSubset = xmlSAX2InternalSubset; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 144 | hdlr->externalSubset = NULL; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 145 | hdlr->isStandalone = xmlSAX2IsStandalone; |
| 146 | hdlr->hasInternalSubset = xmlSAX2HasInternalSubset; |
| 147 | hdlr->hasExternalSubset = xmlSAX2HasExternalSubset; |
| 148 | hdlr->resolveEntity = xmlSAX2ResolveEntity; |
| 149 | hdlr->getEntity = xmlSAX2GetEntity; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 150 | hdlr->getParameterEntity = NULL; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 151 | hdlr->entityDecl = xmlSAX2EntityDecl; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 152 | hdlr->attributeDecl = NULL; |
| 153 | hdlr->elementDecl = NULL; |
| 154 | hdlr->notationDecl = NULL; |
| 155 | hdlr->unparsedEntityDecl = NULL; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 156 | hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator; |
| 157 | hdlr->startDocument = xmlSAX2StartDocument; |
| 158 | hdlr->endDocument = xmlSAX2EndDocument; |
| 159 | hdlr->startElement = xmlSAX2StartElement; |
| 160 | hdlr->endElement = xmlSAX2EndElement; |
| 161 | hdlr->reference = xmlSAX2Reference; |
| 162 | hdlr->characters = xmlSAX2Characters; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 163 | hdlr->cdataBlock = NULL; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 164 | hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 165 | hdlr->processingInstruction = NULL; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 166 | hdlr->comment = xmlSAX2Comment; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 167 | hdlr->warning = xmlParserWarning; |
| 168 | hdlr->error = xmlParserError; |
| 169 | hdlr->fatalError = xmlParserError; |
| 170 | |
| 171 | hdlr->initialized = 1; |
| 172 | } |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 173 | |
Daniel Veillard | eae522a | 2001-04-23 13:41:34 +0000 | [diff] [blame] | 174 | #endif /* LIBXML_DOCB_ENABLED */ |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 175 | |
| 176 | #endif /* LIBXML_SAX1_ENABLED */ |
| 177 | |
Daniel Veillard | 5d4644e | 2005-04-01 13:11:58 +0000 | [diff] [blame] | 178 | #define bottom_SAX |
| 179 | #include "elfgcchack.h" |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 180 | #endif /* LIBXML_LEGACY_ENABLED */ |