SAX.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * SAX.c : Old SAX v1 handlers to build a tree.
  3. * Deprecated except for compatibility
  4. *
  5. * See Copyright for the status of this software.
  6. *
  7. * Daniel Veillard <daniel@veillard.com>
  8. */
  9. #define IN_LIBXML
  10. #include "libxml.h"
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <libxml/xmlmemory.h>
  14. #include <libxml/tree.h>
  15. #include <libxml/parser.h>
  16. #include <libxml/parserInternals.h>
  17. #include <libxml/valid.h>
  18. #include <libxml/entities.h>
  19. #include <libxml/xmlerror.h>
  20. #include <libxml/debugXML.h>
  21. #include <libxml/xmlIO.h>
  22. #include <libxml/SAX.h>
  23. #include <libxml/uri.h>
  24. #include <libxml/valid.h>
  25. #include <libxml/HTMLtree.h>
  26. #include <libxml/globals.h>
  27. #include <libxml/SAX2.h>
  28. #ifdef LIBXML_LEGACY_ENABLED
  29. #ifdef LIBXML_SAX1_ENABLED
  30. /**
  31. * initxmlDefaultSAXHandler:
  32. * @hdlr: the SAX handler
  33. * @warning: flag if non-zero sets the handler warning procedure
  34. *
  35. * Initialize the default XML SAX version 1 handler
  36. * DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
  37. */
  38. void
  39. initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
  40. {
  41. if(hdlr->initialized == 1)
  42. return;
  43. hdlr->internalSubset = xmlSAX2InternalSubset;
  44. hdlr->externalSubset = xmlSAX2ExternalSubset;
  45. hdlr->isStandalone = xmlSAX2IsStandalone;
  46. hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
  47. hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
  48. hdlr->resolveEntity = xmlSAX2ResolveEntity;
  49. hdlr->getEntity = xmlSAX2GetEntity;
  50. hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
  51. hdlr->entityDecl = xmlSAX2EntityDecl;
  52. hdlr->attributeDecl = xmlSAX2AttributeDecl;
  53. hdlr->elementDecl = xmlSAX2ElementDecl;
  54. hdlr->notationDecl = xmlSAX2NotationDecl;
  55. hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
  56. hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
  57. hdlr->startDocument = xmlSAX2StartDocument;
  58. hdlr->endDocument = xmlSAX2EndDocument;
  59. hdlr->startElement = xmlSAX2StartElement;
  60. hdlr->endElement = xmlSAX2EndElement;
  61. hdlr->reference = xmlSAX2Reference;
  62. hdlr->characters = xmlSAX2Characters;
  63. hdlr->cdataBlock = xmlSAX2CDataBlock;
  64. hdlr->ignorableWhitespace = xmlSAX2Characters;
  65. hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
  66. if (warning == 0)
  67. hdlr->warning = NULL;
  68. else
  69. hdlr->warning = xmlParserWarning;
  70. hdlr->error = xmlParserError;
  71. hdlr->fatalError = xmlParserError;
  72. hdlr->initialized = 1;
  73. }
  74. #ifdef LIBXML_HTML_ENABLED
  75. /**
  76. * inithtmlDefaultSAXHandler:
  77. * @hdlr: the SAX handler
  78. *
  79. * Initialize the default HTML SAX version 1 handler
  80. * DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
  81. */
  82. void
  83. inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
  84. {
  85. if(hdlr->initialized == 1)
  86. return;
  87. hdlr->internalSubset = xmlSAX2InternalSubset;
  88. hdlr->externalSubset = NULL;
  89. hdlr->isStandalone = NULL;
  90. hdlr->hasInternalSubset = NULL;
  91. hdlr->hasExternalSubset = NULL;
  92. hdlr->resolveEntity = NULL;
  93. hdlr->getEntity = xmlSAX2GetEntity;
  94. hdlr->getParameterEntity = NULL;
  95. hdlr->entityDecl = NULL;
  96. hdlr->attributeDecl = NULL;
  97. hdlr->elementDecl = NULL;
  98. hdlr->notationDecl = NULL;
  99. hdlr->unparsedEntityDecl = NULL;
  100. hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
  101. hdlr->startDocument = xmlSAX2StartDocument;
  102. hdlr->endDocument = xmlSAX2EndDocument;
  103. hdlr->startElement = xmlSAX2StartElement;
  104. hdlr->endElement = xmlSAX2EndElement;
  105. hdlr->reference = NULL;
  106. hdlr->characters = xmlSAX2Characters;
  107. hdlr->cdataBlock = xmlSAX2CDataBlock;
  108. hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
  109. hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
  110. hdlr->comment = xmlSAX2Comment;
  111. hdlr->warning = xmlParserWarning;
  112. hdlr->error = xmlParserError;
  113. hdlr->fatalError = xmlParserError;
  114. hdlr->initialized = 1;
  115. }
  116. #endif /* LIBXML_HTML_ENABLED */
  117. #ifdef LIBXML_DOCB_ENABLED
  118. /**
  119. * initdocbDefaultSAXHandler:
  120. * @hdlr: the SAX handler
  121. *
  122. * Initialize the default DocBook SAX version 1 handler
  123. * DEPRECATED: use xmlSAX2InitDocbDefaultSAXHandler() for the new SAX2 blocks
  124. */
  125. void
  126. initdocbDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
  127. {
  128. if(hdlr->initialized == 1)
  129. return;
  130. hdlr->internalSubset = xmlSAX2InternalSubset;
  131. hdlr->externalSubset = NULL;
  132. hdlr->isStandalone = xmlSAX2IsStandalone;
  133. hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
  134. hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
  135. hdlr->resolveEntity = xmlSAX2ResolveEntity;
  136. hdlr->getEntity = xmlSAX2GetEntity;
  137. hdlr->getParameterEntity = NULL;
  138. hdlr->entityDecl = xmlSAX2EntityDecl;
  139. hdlr->attributeDecl = NULL;
  140. hdlr->elementDecl = NULL;
  141. hdlr->notationDecl = NULL;
  142. hdlr->unparsedEntityDecl = NULL;
  143. hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
  144. hdlr->startDocument = xmlSAX2StartDocument;
  145. hdlr->endDocument = xmlSAX2EndDocument;
  146. hdlr->startElement = xmlSAX2StartElement;
  147. hdlr->endElement = xmlSAX2EndElement;
  148. hdlr->reference = xmlSAX2Reference;
  149. hdlr->characters = xmlSAX2Characters;
  150. hdlr->cdataBlock = NULL;
  151. hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
  152. hdlr->processingInstruction = NULL;
  153. hdlr->comment = xmlSAX2Comment;
  154. hdlr->warning = xmlParserWarning;
  155. hdlr->error = xmlParserError;
  156. hdlr->fatalError = xmlParserError;
  157. hdlr->initialized = 1;
  158. }
  159. #endif /* LIBXML_DOCB_ENABLED */
  160. #endif /* LIBXML_SAX1_ENABLED */
  161. #define bottom_SAX
  162. #include "elfgcchack.h"
  163. #endif /* LIBXML_LEGACY_ENABLED */