SAX.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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/SAX2.h>
  27. #ifdef LIBXML_LEGACY_ENABLED
  28. #ifdef LIBXML_SAX1_ENABLED
  29. /**
  30. * initxmlDefaultSAXHandler:
  31. * @hdlr: the SAX handler
  32. * @warning: flag if non-zero sets the handler warning procedure
  33. *
  34. * Initialize the default XML SAX version 1 handler
  35. * DEPRECATED: use xmlSAX2InitDefaultSAXHandler() for the new SAX2 blocks
  36. */
  37. void
  38. initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
  39. {
  40. if(hdlr->initialized == 1)
  41. return;
  42. hdlr->internalSubset = xmlSAX2InternalSubset;
  43. hdlr->externalSubset = xmlSAX2ExternalSubset;
  44. hdlr->isStandalone = xmlSAX2IsStandalone;
  45. hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
  46. hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
  47. hdlr->resolveEntity = xmlSAX2ResolveEntity;
  48. hdlr->getEntity = xmlSAX2GetEntity;
  49. hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
  50. hdlr->entityDecl = xmlSAX2EntityDecl;
  51. hdlr->attributeDecl = xmlSAX2AttributeDecl;
  52. hdlr->elementDecl = xmlSAX2ElementDecl;
  53. hdlr->notationDecl = xmlSAX2NotationDecl;
  54. hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
  55. hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
  56. hdlr->startDocument = xmlSAX2StartDocument;
  57. hdlr->endDocument = xmlSAX2EndDocument;
  58. hdlr->startElement = xmlSAX2StartElement;
  59. hdlr->endElement = xmlSAX2EndElement;
  60. hdlr->reference = xmlSAX2Reference;
  61. hdlr->characters = xmlSAX2Characters;
  62. hdlr->cdataBlock = xmlSAX2CDataBlock;
  63. hdlr->ignorableWhitespace = xmlSAX2Characters;
  64. hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
  65. if (warning == 0)
  66. hdlr->warning = NULL;
  67. else
  68. hdlr->warning = xmlParserWarning;
  69. hdlr->error = xmlParserError;
  70. hdlr->fatalError = xmlParserError;
  71. hdlr->initialized = 1;
  72. }
  73. #ifdef LIBXML_HTML_ENABLED
  74. /**
  75. * inithtmlDefaultSAXHandler:
  76. * @hdlr: the SAX handler
  77. *
  78. * Initialize the default HTML SAX version 1 handler
  79. * DEPRECATED: use xmlSAX2InitHtmlDefaultSAXHandler() for the new SAX2 blocks
  80. */
  81. void
  82. inithtmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr)
  83. {
  84. if(hdlr->initialized == 1)
  85. return;
  86. hdlr->internalSubset = xmlSAX2InternalSubset;
  87. hdlr->externalSubset = NULL;
  88. hdlr->isStandalone = NULL;
  89. hdlr->hasInternalSubset = NULL;
  90. hdlr->hasExternalSubset = NULL;
  91. hdlr->resolveEntity = NULL;
  92. hdlr->getEntity = xmlSAX2GetEntity;
  93. hdlr->getParameterEntity = NULL;
  94. hdlr->entityDecl = NULL;
  95. hdlr->attributeDecl = NULL;
  96. hdlr->elementDecl = NULL;
  97. hdlr->notationDecl = NULL;
  98. hdlr->unparsedEntityDecl = NULL;
  99. hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
  100. hdlr->startDocument = xmlSAX2StartDocument;
  101. hdlr->endDocument = xmlSAX2EndDocument;
  102. hdlr->startElement = xmlSAX2StartElement;
  103. hdlr->endElement = xmlSAX2EndElement;
  104. hdlr->reference = NULL;
  105. hdlr->characters = xmlSAX2Characters;
  106. hdlr->cdataBlock = xmlSAX2CDataBlock;
  107. hdlr->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
  108. hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
  109. hdlr->comment = xmlSAX2Comment;
  110. hdlr->warning = xmlParserWarning;
  111. hdlr->error = xmlParserError;
  112. hdlr->fatalError = xmlParserError;
  113. hdlr->initialized = 1;
  114. }
  115. #endif /* LIBXML_HTML_ENABLED */
  116. #endif /* LIBXML_SAX1_ENABLED */
  117. #endif /* LIBXML_LEGACY_ENABLED */