Annotation of XML/SAX.c, revision 1.1
1.1 ! daniel 1: /*
! 2: * SAX.c : Default SAX handler to build a tree.
! 3: */
! 4:
! 5: #include <stdio.h>
! 6: #include "tree.h"
! 7: #include "parser.h"
! 8: #include "error.h"
! 9:
! 10: /*
! 11: * Return the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"
! 12: */
! 13: static const CHAR *getPublicId(xmlParserCtxtPtr ctxt) {
! 14: return(NULL);
! 15: }
! 16:
! 17: /*
! 18: * Return the system ID, basically URI or filename e.g.
! 19: * http://www.sgmlsource.com/dtds/memo.dtd
! 20: */
! 21: static const CHAR *getSystemId(xmlParserCtxtPtr ctxt) {
! 22: return(ctxt->input->filename);
! 23: }
! 24:
! 25: /*
! 26: * Return the line number of the current parsing point.
! 27: */
! 28: static int getLineNumber(xmlParserCtxtPtr ctxt) {
! 29: return(ctxt->input->line);
! 30: }
! 31: /*
! 32: * Return the column number of the current parsing point.
! 33: */
! 34: static int getColumnNumber(xmlParserCtxtPtr ctxt) {
! 35: return(ctxt->input->col);
! 36: }
! 37:
! 38: /*
! 39: * The default SAX Locator.
! 40: */
! 41:
! 42: xmlSAXLocator xmlDefaultSAXLocator = {
! 43: getPublicId, getSystemId, getLineNumber, getColumnNumber
! 44: };
! 45:
! 46: /*
! 47: * Special entity resolver, better left to the parser, it has
! 48: * more context than the application layer.
! 49: */
! 50: static xmlParserInputPtr resolveEntity(xmlParserCtxtPtr ctxt,
! 51: const CHAR *publicId, const CHAR *systemId) {
! 52: return(NULL);
! 53: }
! 54:
! 55: /*
! 56: * What to do when a notation declaration has been parsed.
! 57: * TODO Not handled currently.
! 58: */
! 59: static void notationDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
! 60: const CHAR *publicId, const CHAR *systemId) {
! 61: }
! 62:
! 63: /*
! 64: * What to do when an unparsed entity declaration is parsed
! 65: * TODO Create an Entity node.
! 66: */
! 67: static void unparsedEntityDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
! 68: const CHAR *publicId, const CHAR *systemId,
! 69: const CHAR *notationName) {
! 70: }
! 71:
! 72: /*
! 73: * Receive the document locator at startup, actually xmlDefaultSAXLocator
! 74: * Everything is available on the context, so this is useless in our case.
! 75: */
! 76: static void setDocumentLocator(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc) {
! 77: }
! 78:
! 79: /*
! 80: * called when the document start being processed.
! 81: */
! 82: static void startDocument(xmlParserCtxtPtr ctxt) {
! 83: }
! 84:
! 85: /*
! 86: * called when the document end has been detected.
! 87: */
! 88: static void endDocument(xmlParserCtxtPtr ctxt) {
! 89: }
! 90:
! 91: /*
! 92: * called when an opening tag has been processed.
! 93: * TODO We currently have a small pblm with the arguments ...
! 94: */
! 95: static void startElement(xmlParserCtxtPtr ctxt, const CHAR *name) {
! 96: }
! 97:
! 98: /*
! 99: * called when the end of an element has been detected.
! 100: */
! 101: static void endElement(xmlParserCtxtPtr ctxt, const CHAR *name) {
! 102: }
! 103:
! 104: /*
! 105: * receiving some chars from the parser.
! 106: * Question: how much at a time ???
! 107: */
! 108: static void characters(xmlParserCtxtPtr ctxt, const CHAR *ch,
! 109: int start, int len) {
! 110: }
! 111:
! 112: /*
! 113: * receiving some ignorable whitespaces from the parser.
! 114: * Question: how much at a time ???
! 115: */
! 116: static void ignorableWhitespace(xmlParserCtxtPtr ctxt, const CHAR *ch,
! 117: int start, int len) {
! 118: }
! 119:
! 120: /*
! 121: * A processing instruction has beem parsed.
! 122: */
! 123: static void processingInstruction(xmlParserCtxtPtr ctxt, const CHAR *target,
! 124: const CHAR *data) {
! 125: }
! 126:
! 127: xmlSAXHandler xmlDefaultSAXHandler = {
! 128: resolveEntity,
! 129: notationDecl,
! 130: unparsedEntityDecl,
! 131: setDocumentLocator,
! 132: startDocument,
! 133: endDocument,
! 134: startElement,
! 135: endElement,
! 136: characters,
! 137: ignorableWhitespace,
! 138: processingInstruction,
! 139: xmlParserWarning,
! 140: xmlParserError,
! 141: xmlParserError
! 142: };
Webmaster