Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SAX.c : Default SAX handler to build a tree. |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 3 | * |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 4 | * See Copyright for the status of this software. |
| 5 | * |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 6 | * Daniel Veillard <Daniel.Veillard@w3.org> |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
Daniel Veillard | 7f7d111 | 1999-09-22 09:46:25 +0000 | [diff] [blame] | 9 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 10 | #include <stdio.h> |
Seth Alves | e7f12e6 | 1998-10-01 20:51:15 +0000 | [diff] [blame] | 11 | #include <stdlib.h> |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 12 | #include "xmlmemory.h" |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 13 | #include "tree.h" |
| 14 | #include "parser.h" |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 15 | #include "parserInternals.h" |
| 16 | #include "valid.h" |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 17 | #include "entities.h" |
Daniel Veillard | d109e37 | 1999-03-05 06:26:45 +0000 | [diff] [blame] | 18 | #include "xml-error.h" |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 19 | #include "debugXML.h" |
Daniel Veillard | 294cbca | 1999-12-03 13:19:09 +0000 | [diff] [blame] | 20 | #include "SAX.h" |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 21 | |
| 22 | /* #define DEBUG_SAX */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 23 | /* #define DEBUG_SAX_TREE */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 24 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 25 | /** |
| 26 | * getPublicId: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 27 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 28 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 29 | * Return the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN" |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 30 | * |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 31 | * Returns a xmlChar * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 32 | */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 33 | const xmlChar * |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 34 | getPublicId(void *ctx) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 35 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 36 | /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 37 | return(NULL); |
| 38 | } |
| 39 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 40 | /** |
| 41 | * getSystemId: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 42 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 43 | * |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 44 | * Return the system ID, basically URL or filename e.g. |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 45 | * http://www.sgmlsource.com/dtds/memo.dtd |
| 46 | * |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 47 | * Returns a xmlChar * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 48 | */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 49 | const xmlChar * |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 50 | getSystemId(void *ctx) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 51 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 52 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 53 | return(BAD_CAST ctxt->input->filename); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 56 | /** |
| 57 | * getLineNumber: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 58 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 59 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 60 | * Return the line number of the current parsing point. |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 61 | * |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 62 | * Returns an int |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 63 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 64 | int |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 65 | getLineNumber(void *ctx) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 66 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 67 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 68 | return(ctxt->input->line); |
| 69 | } |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * getColumnNumber: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 73 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 74 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 75 | * Return the column number of the current parsing point. |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 76 | * |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 77 | * Returns an int |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 78 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 79 | int |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 80 | getColumnNumber(void *ctx) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 81 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 82 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 83 | return(ctxt->input->col); |
| 84 | } |
| 85 | |
| 86 | /* |
| 87 | * The default SAX Locator. |
| 88 | */ |
| 89 | |
| 90 | xmlSAXLocator xmlDefaultSAXLocator = { |
| 91 | getPublicId, getSystemId, getLineNumber, getColumnNumber |
| 92 | }; |
| 93 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 94 | /** |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 95 | * isStandalone: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 96 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 97 | * |
| 98 | * Is this document tagged standalone ? |
| 99 | * |
| 100 | * Returns 1 if true |
| 101 | */ |
| 102 | int |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 103 | isStandalone(void *ctx) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 104 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 105 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 106 | return(ctxt->myDoc->standalone == 1); |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * hasInternalSubset: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 111 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 112 | * |
| 113 | * Does this document has an internal subset |
| 114 | * |
| 115 | * Returns 1 if true |
| 116 | */ |
| 117 | int |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 118 | hasInternalSubset(void *ctx) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 119 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 120 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 121 | return(ctxt->myDoc->intSubset != NULL); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * hasExternalSubset: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 126 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 127 | * |
| 128 | * Does this document has an external subset |
| 129 | * |
| 130 | * Returns 1 if true |
| 131 | */ |
| 132 | int |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 133 | hasExternalSubset(void *ctx) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 134 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 135 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 136 | return(ctxt->myDoc->extSubset != NULL); |
| 137 | } |
| 138 | |
| 139 | /** |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 140 | * internalSubset: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 141 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 142 | * |
| 143 | * Does this document has an internal subset |
| 144 | */ |
| 145 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 146 | internalSubset(void *ctx, const xmlChar *name, |
| 147 | const xmlChar *ExternalID, const xmlChar *SystemID) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 148 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 149 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 150 | #ifdef DEBUG_SAX |
| 151 | fprintf(stderr, "SAX.internalSubset(%s, %s, %s)\n", |
| 152 | name, ExternalID, SystemID); |
| 153 | #endif |
| 154 | xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID); |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 155 | if (((ExternalID != NULL) || (SystemID != NULL)) && |
| 156 | (ctxt->validate && ctxt->wellFormed && ctxt->myDoc)) { |
| 157 | /* |
| 158 | * Try to fetch and parse the external subset. |
| 159 | */ |
| 160 | xmlDtdPtr ret = NULL; |
| 161 | xmlParserCtxtPtr dtdCtxt; |
| 162 | xmlParserInputPtr input = NULL; |
| 163 | xmlCharEncoding enc; |
| 164 | |
| 165 | dtdCtxt = xmlNewParserCtxt(); |
| 166 | if (dtdCtxt == NULL) return; |
| 167 | |
| 168 | /* |
| 169 | * Ask the Entity resolver to load the damn thing |
| 170 | */ |
| 171 | if ((ctxt->directory != NULL) && (dtdCtxt->directory == NULL)) |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 172 | dtdCtxt->directory = (char *) xmlStrdup(BAD_CAST ctxt->directory); |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 173 | |
| 174 | if ((dtdCtxt->sax != NULL) && (dtdCtxt->sax->resolveEntity != NULL)) |
| 175 | input = dtdCtxt->sax->resolveEntity(dtdCtxt->userData, ExternalID, |
| 176 | SystemID); |
| 177 | if (input == NULL) { |
| 178 | xmlFreeParserCtxt(dtdCtxt); |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | /* |
| 183 | * plug some encoding conversion routines here. !!! |
| 184 | */ |
| 185 | xmlPushInput(dtdCtxt, input); |
| 186 | enc = xmlDetectCharEncoding(dtdCtxt->input->cur); |
| 187 | xmlSwitchEncoding(dtdCtxt, enc); |
| 188 | |
| 189 | if (input->filename == NULL) |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 190 | input->filename = (char *) xmlStrdup(SystemID); |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 191 | input->line = 1; |
| 192 | input->col = 1; |
| 193 | input->base = dtdCtxt->input->cur; |
| 194 | input->cur = dtdCtxt->input->cur; |
| 195 | input->free = NULL; |
| 196 | |
| 197 | /* |
| 198 | * let's parse that entity knowing it's an external subset. |
| 199 | */ |
| 200 | xmlParseExternalSubset(dtdCtxt, ExternalID, SystemID); |
| 201 | |
| 202 | if (dtdCtxt->myDoc != NULL) { |
| 203 | if (dtdCtxt->wellFormed) { |
| 204 | ret = dtdCtxt->myDoc->intSubset; |
| 205 | dtdCtxt->myDoc->intSubset = NULL; |
| 206 | } else { |
| 207 | ret = NULL; |
| 208 | } |
| 209 | xmlFreeDoc(dtdCtxt->myDoc); |
| 210 | dtdCtxt->myDoc = NULL; |
| 211 | } |
| 212 | xmlFreeParserCtxt(dtdCtxt); |
| 213 | |
| 214 | ctxt->myDoc->extSubset = ret; |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 215 | } |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | /** |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 219 | * resolveEntity: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 220 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 221 | * @publicId: The public ID of the entity |
| 222 | * @systemId: The system ID of the entity |
| 223 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 224 | * Special entity resolver, better left to the parser, it has |
| 225 | * more context than the application layer. |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 226 | * The default behaviour is to NOT resolve the entities, in that case |
| 227 | * the ENTITY_REF nodes are built in the structure (and the parameter |
| 228 | * values). |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 229 | * |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 230 | * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 231 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 232 | xmlParserInputPtr |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 233 | resolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 234 | { |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 235 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 236 | |
| 237 | #ifdef DEBUG_SAX |
| 238 | fprintf(stderr, "SAX.resolveEntity(%s, %s)\n", publicId, systemId); |
| 239 | #endif |
Daniel Veillard | ccb0963 | 1998-10-27 06:21:04 +0000 | [diff] [blame] | 240 | |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 241 | if (systemId != NULL) { |
Daniel Veillard | 7f7d111 | 1999-09-22 09:46:25 +0000 | [diff] [blame] | 242 | return(xmlNewInputFromFile(ctxt, (char *) systemId)); |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 243 | } |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 244 | return(NULL); |
| 245 | } |
| 246 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 247 | /** |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 248 | * getEntity: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 249 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 250 | * @name: The entity name |
| 251 | * |
| 252 | * Get an entity by name |
| 253 | * |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 254 | * Returns the xmlEntityPtr if found. |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 255 | */ |
| 256 | xmlEntityPtr |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 257 | getEntity(void *ctx, const xmlChar *name) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 258 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 259 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 260 | xmlEntityPtr ret; |
| 261 | |
| 262 | #ifdef DEBUG_SAX |
| 263 | fprintf(stderr, "SAX.getEntity(%s)\n", name); |
| 264 | #endif |
| 265 | |
| 266 | ret = xmlGetDocEntity(ctxt->myDoc, name); |
| 267 | return(ret); |
| 268 | } |
| 269 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 270 | /** |
| 271 | * getParameterEntity: |
| 272 | * @ctx: the user data (XML parser context) |
| 273 | * @name: The entity name |
| 274 | * |
| 275 | * Get a parameter entity by name |
| 276 | * |
| 277 | * Returns the xmlEntityPtr if found. |
| 278 | */ |
| 279 | xmlEntityPtr |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 280 | getParameterEntity(void *ctx, const xmlChar *name) |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 281 | { |
| 282 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 283 | xmlEntityPtr ret; |
| 284 | |
| 285 | #ifdef DEBUG_SAX |
| 286 | fprintf(stderr, "SAX.getParameterEntity(%s)\n", name); |
| 287 | #endif |
| 288 | |
| 289 | ret = xmlGetParameterEntity(ctxt->myDoc, name); |
| 290 | return(ret); |
| 291 | } |
| 292 | |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 293 | |
| 294 | /** |
| 295 | * entityDecl: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 296 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 297 | * @name: the entity name |
| 298 | * @type: the entity type |
| 299 | * @publicId: The public ID of the entity |
| 300 | * @systemId: The system ID of the entity |
| 301 | * @content: the entity value (without processing). |
| 302 | * |
| 303 | * An entity definition has been parsed |
| 304 | */ |
| 305 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 306 | entityDecl(void *ctx, const xmlChar *name, int type, |
| 307 | const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 308 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 309 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 310 | |
| 311 | #ifdef DEBUG_SAX |
| 312 | fprintf(stderr, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", |
| 313 | name, type, publicId, systemId, content); |
| 314 | #endif |
| 315 | xmlAddDocEntity(ctxt->myDoc, name, type, publicId, systemId, content); |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * attributeDecl: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 320 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 321 | * @name: the attribute name |
| 322 | * @type: the attribute type |
| 323 | * @publicId: The public ID of the attribute |
| 324 | * @systemId: The system ID of the attribute |
| 325 | * @content: the attribute value (without processing). |
| 326 | * |
| 327 | * An attribute definition has been parsed |
| 328 | */ |
| 329 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 330 | attributeDecl(void *ctx, const xmlChar *elem, const xmlChar *name, |
| 331 | int type, int def, const xmlChar *defaultValue, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 332 | xmlEnumerationPtr tree) |
| 333 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 334 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 335 | xmlAttributePtr attr; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 336 | |
| 337 | #ifdef DEBUG_SAX |
| 338 | fprintf(stderr, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", |
| 339 | elem, name, type, def, defaultValue); |
| 340 | #endif |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 341 | attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem, |
| 342 | name, type, def, defaultValue, tree); |
| 343 | if (attr == 0) ctxt->valid = 0; |
| 344 | if (ctxt->validate && ctxt->wellFormed && |
| 345 | ctxt->myDoc && ctxt->myDoc->intSubset) |
| 346 | ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc, |
| 347 | attr); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | /** |
| 351 | * elementDecl: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 352 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 353 | * @name: the element name |
| 354 | * @type: the element type |
| 355 | * @publicId: The public ID of the element |
| 356 | * @systemId: The system ID of the element |
| 357 | * @content: the element value (without processing). |
| 358 | * |
| 359 | * An element definition has been parsed |
| 360 | */ |
| 361 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 362 | elementDecl(void *ctx, const xmlChar *name, int type, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 363 | xmlElementContentPtr content) |
| 364 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 365 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 366 | xmlElementPtr elem; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 367 | |
| 368 | #ifdef DEBUG_SAX |
| 369 | fprintf(stderr, "SAX.elementDecl(%s, %d, ...)\n", |
| 370 | name, type); |
| 371 | #endif |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 372 | |
| 373 | elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, |
| 374 | name, type, content); |
| 375 | if (elem == 0) ctxt->valid = 0; |
| 376 | if (ctxt->validate && ctxt->wellFormed && |
| 377 | ctxt->myDoc && ctxt->myDoc->intSubset) |
| 378 | ctxt->valid &= xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | /** |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 382 | * notationDecl: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 383 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 384 | * @name: The name of the notation |
| 385 | * @publicId: The public ID of the entity |
| 386 | * @systemId: The system ID of the entity |
| 387 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 388 | * What to do when a notation declaration has been parsed. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 389 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 390 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 391 | notationDecl(void *ctx, const xmlChar *name, |
| 392 | const xmlChar *publicId, const xmlChar *systemId) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 393 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 394 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 395 | xmlNotationPtr nota; |
| 396 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 397 | #ifdef DEBUG_SAX |
| 398 | fprintf(stderr, "SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId); |
| 399 | #endif |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 400 | |
| 401 | nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name, |
| 402 | publicId, systemId); |
| 403 | if (nota == 0) ctxt->valid = 0; |
| 404 | if (ctxt->validate && ctxt->wellFormed && |
| 405 | ctxt->myDoc && ctxt->myDoc->intSubset) |
| 406 | ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc, |
| 407 | nota); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 410 | /** |
| 411 | * unparsedEntityDecl: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 412 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 413 | * @name: The name of the entity |
| 414 | * @publicId: The public ID of the entity |
| 415 | * @systemId: The system ID of the entity |
| 416 | * @notationName: the name of the notation |
| 417 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 418 | * What to do when an unparsed entity declaration is parsed |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 419 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 420 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 421 | unparsedEntityDecl(void *ctx, const xmlChar *name, |
| 422 | const xmlChar *publicId, const xmlChar *systemId, |
| 423 | const xmlChar *notationName) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 424 | { |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 425 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 426 | #ifdef DEBUG_SAX |
| 427 | fprintf(stderr, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", |
| 428 | name, publicId, systemId, notationName); |
| 429 | #endif |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 430 | if (ctxt->validate && ctxt->wellFormed && |
| 431 | ctxt->myDoc && ctxt->myDoc->intSubset) |
| 432 | ctxt->valid &= xmlValidateNotationUse(&ctxt->vctxt, ctxt->myDoc, |
| 433 | notationName); |
| 434 | xmlAddDocEntity(ctxt->myDoc, name, |
| 435 | XML_EXTERNAL_GENERAL_UNPARSED_ENTITY, |
| 436 | publicId, systemId, notationName); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 437 | } |
| 438 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 439 | /** |
| 440 | * setDocumentLocator: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 441 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 442 | * @loc: A SAX Locator |
| 443 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 444 | * Receive the document locator at startup, actually xmlDefaultSAXLocator |
| 445 | * Everything is available on the context, so this is useless in our case. |
| 446 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 447 | void |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 448 | setDocumentLocator(void *ctx, xmlSAXLocatorPtr loc) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 449 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 450 | /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 451 | #ifdef DEBUG_SAX |
| 452 | fprintf(stderr, "SAX.setDocumentLocator()\n"); |
| 453 | #endif |
| 454 | } |
| 455 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 456 | /** |
| 457 | * startDocument: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 458 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 459 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 460 | * called when the document start being processed. |
| 461 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 462 | void |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 463 | startDocument(void *ctx) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 464 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 465 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 466 | xmlDocPtr doc; |
| 467 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 468 | #ifdef DEBUG_SAX |
| 469 | fprintf(stderr, "SAX.startDocument()\n"); |
| 470 | #endif |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 471 | doc = ctxt->myDoc = xmlNewDoc(ctxt->version); |
| 472 | if (doc != NULL) { |
| 473 | if (ctxt->encoding != NULL) |
| 474 | doc->encoding = xmlStrdup(ctxt->encoding); |
| 475 | else |
| 476 | doc->encoding = NULL; |
| 477 | doc->standalone = ctxt->standalone; |
| 478 | } |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 479 | } |
| 480 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 481 | /** |
| 482 | * endDocument: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 483 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 484 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 485 | * called when the document end has been detected. |
| 486 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 487 | void |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 488 | endDocument(void *ctx) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 489 | { |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 490 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 491 | #ifdef DEBUG_SAX |
| 492 | fprintf(stderr, "SAX.endDocument()\n"); |
| 493 | #endif |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 494 | if (ctxt->validate && ctxt->wellFormed && |
| 495 | ctxt->myDoc && ctxt->myDoc->intSubset) |
| 496 | ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 497 | } |
| 498 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 499 | /** |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 500 | * attribute: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 501 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 502 | * @name: The attribute name |
| 503 | * @value: The attribute value |
| 504 | * |
| 505 | * Handle an attribute that has been read by the parser. |
| 506 | * The default handling is to convert the attribute into an |
| 507 | * DOM subtree and past it in a new xmlAttr element added to |
| 508 | * the element. |
| 509 | */ |
| 510 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 511 | attribute(void *ctx, const xmlChar *fullname, const xmlChar *value) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 512 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 513 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 514 | xmlAttrPtr ret; |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 515 | xmlChar *name; |
| 516 | xmlChar *ns; |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 517 | xmlNsPtr namespace; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 518 | |
| 519 | /**************** |
| 520 | #ifdef DEBUG_SAX |
| 521 | fprintf(stderr, "SAX.attribute(%s, %s)\n", fullname, value); |
| 522 | #endif |
| 523 | ****************/ |
| 524 | /* |
| 525 | * Split the full name into a namespace prefix and the tag name |
| 526 | */ |
| 527 | name = xmlSplitQName(fullname, &ns); |
| 528 | |
| 529 | /* |
| 530 | * Check whether it's a namespace definition |
| 531 | */ |
| 532 | if ((ns == NULL) && |
| 533 | (name[0] == 'x') && (name[1] == 'm') && (name[2] == 'l') && |
| 534 | (name[3] == 'n') && (name[4] == 's') && (name[5] == 0)) { |
| 535 | /* a default namespace definition */ |
| 536 | xmlNewNs(ctxt->node, value, NULL); |
| 537 | if (name != NULL) |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 538 | xmlFree(name); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 539 | return; |
| 540 | } |
| 541 | if ((ns != NULL) && (ns[0] == 'x') && (ns[1] == 'm') && (ns[2] == 'l') && |
| 542 | (ns[3] == 'n') && (ns[4] == 's') && (ns[5] == 0)) { |
| 543 | /* a standard namespace definition */ |
| 544 | xmlNewNs(ctxt->node, value, name); |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 545 | xmlFree(ns); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 546 | if (name != NULL) |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 547 | xmlFree(name); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 548 | return; |
| 549 | } |
| 550 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 551 | namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, ns); |
| 552 | /* !!!!!! <a toto:arg="" xmlns:toto="http://toto.com"> */ |
| 553 | ret = xmlNewNsProp(ctxt->node, namespace, name, NULL); |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 554 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 555 | if (ret != NULL) { |
Daniel Veillard | 7c1206f | 1999-10-14 09:10:25 +0000 | [diff] [blame] | 556 | if ((ctxt->replaceEntities == 0) && (!ctxt->html)) |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 557 | ret->val = xmlStringGetNodeList(ctxt->myDoc, value); |
| 558 | else |
| 559 | ret->val = xmlNewDocText(ctxt->myDoc, value); |
| 560 | } |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 561 | |
| 562 | if (ctxt->validate && ctxt->wellFormed && |
| 563 | ctxt->myDoc && ctxt->myDoc->intSubset) |
| 564 | ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, |
| 565 | ctxt->node, ret, value); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 566 | else { |
| 567 | /* |
| 568 | * when validating, the ID registration is done at the attribute |
| 569 | * validation level. Otherwise we have to do specific handling here. |
| 570 | */ |
| 571 | if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) |
| 572 | xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret); |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 573 | else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) |
| 574 | xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 575 | } |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 576 | |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 577 | if (name != NULL) |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 578 | xmlFree(name); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 579 | if (ns != NULL) |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 580 | xmlFree(ns); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | /** |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 584 | * startElement: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 585 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 586 | * @name: The element name |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 587 | * @atts: An array of name/value attributes pairs, NULL terminated |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 588 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 589 | * called when an opening tag has been processed. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 590 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 591 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 592 | startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 593 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 594 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 595 | xmlNodePtr ret; |
| 596 | xmlNodePtr parent = ctxt->node; |
| 597 | xmlNsPtr ns; |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 598 | xmlChar *name; |
| 599 | xmlChar *prefix; |
| 600 | const xmlChar *att; |
| 601 | const xmlChar *value; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 602 | int i; |
| 603 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 604 | #ifdef DEBUG_SAX |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 605 | fprintf(stderr, "SAX.startElement(%s)\n", fullname); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 606 | #endif |
Daniel Veillard | 7f7d111 | 1999-09-22 09:46:25 +0000 | [diff] [blame] | 607 | |
| 608 | /* |
| 609 | * First check on validity: |
| 610 | */ |
| 611 | if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) && |
| 612 | ((ctxt->myDoc->intSubset == NULL) || |
| 613 | ((ctxt->myDoc->intSubset->notations == NULL) && |
| 614 | (ctxt->myDoc->intSubset->elements == NULL) && |
| 615 | (ctxt->myDoc->intSubset->attributes == NULL) && |
| 616 | (ctxt->myDoc->intSubset->entities == NULL)))) { |
| 617 | if (ctxt->vctxt.error != NULL) { |
| 618 | ctxt->vctxt.error(ctxt->vctxt.userData, |
| 619 | "Validation failed: no DTD found !\n"); |
| 620 | } |
| 621 | ctxt->validate = 0; |
| 622 | } |
| 623 | |
| 624 | |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 625 | /* |
| 626 | * Split the full name into a namespace prefix and the tag name |
| 627 | */ |
| 628 | name = xmlSplitQName(fullname, &prefix); |
| 629 | |
| 630 | |
| 631 | /* |
| 632 | * Note : the namespace resolution is deferred until the end of the |
| 633 | * attributes parsing, since local namespace can be defined as |
| 634 | * an attribute at this level. |
| 635 | */ |
| 636 | ret = xmlNewDocNode(ctxt->myDoc, NULL, name, NULL); |
| 637 | if (ret == NULL) return; |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 638 | if (ctxt->myDoc->root == NULL) { |
| 639 | #ifdef DEBUG_SAX_TREE |
| 640 | fprintf(stderr, "Setting %s as root\n", name); |
| 641 | #endif |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 642 | ctxt->myDoc->root = ret; |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 643 | } else if (parent == NULL) { |
| 644 | parent = ctxt->myDoc->root; |
| 645 | } |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 646 | |
| 647 | /* |
| 648 | * We are parsing a new node. |
| 649 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 650 | #ifdef DEBUG_SAX_TREE |
| 651 | fprintf(stderr, "pushing(%s)\n", name); |
| 652 | #endif |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 653 | nodePush(ctxt, ret); |
| 654 | |
| 655 | /* |
| 656 | * Link the child element |
| 657 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 658 | if (parent != NULL) { |
| 659 | if (parent->type == XML_ELEMENT_NODE) { |
| 660 | #ifdef DEBUG_SAX_TREE |
| 661 | fprintf(stderr, "adding child %s to %s\n", name, parent->name); |
| 662 | #endif |
| 663 | xmlAddChild(parent, ret); |
| 664 | } else { |
| 665 | #ifdef DEBUG_SAX_TREE |
| 666 | fprintf(stderr, "adding sibling %s to ", name); |
| 667 | xmlDebugDumpOneNode(stderr, parent, 0); |
| 668 | #endif |
| 669 | xmlAddSibling(parent, ret); |
| 670 | } |
| 671 | } |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 672 | |
| 673 | /* |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 674 | * process all the attributes whose name start with "xml" |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 675 | */ |
| 676 | if (atts != NULL) { |
| 677 | i = 0; |
| 678 | att = atts[i++]; |
| 679 | value = atts[i++]; |
| 680 | while ((att != NULL) && (value != NULL)) { |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 681 | if ((att[0] == 'x') && (att[1] == 'm') && (att[2] == 'l')) |
| 682 | attribute(ctxt, att, value); |
| 683 | |
| 684 | att = atts[i++]; |
| 685 | value = atts[i++]; |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | /* |
| 690 | * process all the other attributes |
| 691 | */ |
| 692 | if (atts != NULL) { |
| 693 | i = 0; |
| 694 | att = atts[i++]; |
| 695 | value = atts[i++]; |
| 696 | while ((att != NULL) && (value != NULL)) { |
| 697 | if ((att[0] != 'x') || (att[1] != 'm') || (att[2] != 'l')) |
| 698 | attribute(ctxt, att, value); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 699 | |
| 700 | /* |
| 701 | * Next ones |
| 702 | */ |
| 703 | att = atts[i++]; |
| 704 | value = atts[i++]; |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | /* |
| 709 | * Search the namespace, note that since the attributes have been |
| 710 | * processed, the local namespaces are available. |
| 711 | */ |
| 712 | ns = xmlSearchNs(ctxt->myDoc, ret, prefix); |
| 713 | if ((ns == NULL) && (parent != NULL)) |
| 714 | ns = xmlSearchNs(ctxt->myDoc, parent, prefix); |
| 715 | xmlSetNs(ret, ns); |
| 716 | |
| 717 | if (prefix != NULL) |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 718 | xmlFree(prefix); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 719 | if (name != NULL) |
Daniel Veillard | 6454aec | 1999-09-02 22:04:43 +0000 | [diff] [blame] | 720 | xmlFree(name); |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 721 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 722 | } |
| 723 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 724 | /** |
| 725 | * endElement: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 726 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 727 | * @name: The element name |
| 728 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 729 | * called when the end of an element has been detected. |
| 730 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 731 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 732 | endElement(void *ctx, const xmlChar *name) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 733 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 734 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 735 | xmlParserNodeInfo node_info; |
| 736 | xmlNodePtr cur = ctxt->node; |
| 737 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 738 | #ifdef DEBUG_SAX |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 739 | if (name == NULL) |
| 740 | fprintf(stderr, "SAX.endElement(NULL)\n"); |
| 741 | else |
| 742 | fprintf(stderr, "SAX.endElement(%s)\n", name); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 743 | #endif |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 744 | |
| 745 | /* Capture end position and add node */ |
| 746 | if (cur != NULL && ctxt->record_info) { |
| 747 | node_info.end_pos = ctxt->input->cur - ctxt->input->base; |
| 748 | node_info.end_line = ctxt->input->line; |
| 749 | node_info.node = cur; |
| 750 | xmlParserAddNodeInfo(ctxt, &node_info); |
| 751 | } |
| 752 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 753 | if (ctxt->validate && ctxt->wellFormed && |
| 754 | ctxt->myDoc && ctxt->myDoc->intSubset) |
| 755 | ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc, |
| 756 | cur); |
| 757 | |
| 758 | |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 759 | /* |
| 760 | * end of parsing of this node. |
| 761 | */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 762 | #ifdef DEBUG_SAX_TREE |
| 763 | fprintf(stderr, "popping(%s)\n", cur->name); |
| 764 | #endif |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 765 | nodePop(ctxt); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 766 | } |
| 767 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 768 | /** |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 769 | * reference: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 770 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 771 | * @name: The entity name |
Daniel Veillard | 11e0058 | 1998-10-24 18:27:49 +0000 | [diff] [blame] | 772 | * |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 773 | * called when an entity reference is detected. |
Daniel Veillard | 11e0058 | 1998-10-24 18:27:49 +0000 | [diff] [blame] | 774 | */ |
| 775 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 776 | reference(void *ctx, const xmlChar *name) |
Daniel Veillard | 11e0058 | 1998-10-24 18:27:49 +0000 | [diff] [blame] | 777 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 778 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 779 | xmlNodePtr ret; |
| 780 | |
Daniel Veillard | 11e0058 | 1998-10-24 18:27:49 +0000 | [diff] [blame] | 781 | #ifdef DEBUG_SAX |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 782 | fprintf(stderr, "SAX.reference(%s)\n", name); |
Daniel Veillard | 11e0058 | 1998-10-24 18:27:49 +0000 | [diff] [blame] | 783 | #endif |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 784 | ret = xmlNewReference(ctxt->myDoc, name); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 785 | #ifdef DEBUG_SAX_TREE |
| 786 | fprintf(stderr, "add reference %s to %s \n", name, ctxt->node->name); |
| 787 | #endif |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 788 | xmlAddChild(ctxt->node, ret); |
Daniel Veillard | 11e0058 | 1998-10-24 18:27:49 +0000 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | /** |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 792 | * characters: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 793 | * @ctx: the user data (XML parser context) |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 794 | * @ch: a xmlChar string |
| 795 | * @len: the number of xmlChar |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 796 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 797 | * receiving some chars from the parser. |
| 798 | * Question: how much at a time ??? |
| 799 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 800 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 801 | characters(void *ctx, const xmlChar *ch, int len) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 802 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 803 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 804 | xmlNodePtr lastChild; |
| 805 | |
| 806 | #ifdef DEBUG_SAX |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 807 | fprintf(stderr, "SAX.characters(%.30s, %d)\n", ch, len); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 808 | #endif |
| 809 | /* |
| 810 | * Handle the data if any. If there is no child |
| 811 | * add it as content, otherwise if the last child is text, |
| 812 | * concatenate it, else create a new node of type text. |
| 813 | */ |
| 814 | |
Daniel Veillard | 3500838 | 1999-10-25 13:15:52 +0000 | [diff] [blame] | 815 | if (ctxt->node == NULL) { |
| 816 | #ifdef DEBUG_SAX_TREE |
| 817 | fprintf(stderr, "add chars: ctxt->node == NULL !\n"); |
| 818 | #endif |
| 819 | return; |
| 820 | } |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 821 | lastChild = xmlGetLastChild(ctxt->node); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 822 | #ifdef DEBUG_SAX_TREE |
| 823 | fprintf(stderr, "add chars to %s \n", ctxt->node->name); |
| 824 | #endif |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 825 | if (lastChild == NULL) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 826 | xmlNodeAddContentLen(ctxt->node, ch, len); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 827 | else { |
| 828 | if (xmlNodeIsText(lastChild)) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 829 | xmlTextConcat(lastChild, ch, len); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 830 | else { |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 831 | lastChild = xmlNewTextLen(ch, len); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 832 | xmlAddChild(ctxt->node, lastChild); |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 837 | /** |
| 838 | * ignorableWhitespace: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 839 | * @ctx: the user data (XML parser context) |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 840 | * @ch: a xmlChar string |
| 841 | * @len: the number of xmlChar |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 842 | * |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 843 | * receiving some ignorable whitespaces from the parser. |
| 844 | * Question: how much at a time ??? |
| 845 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 846 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 847 | ignorableWhitespace(void *ctx, const xmlChar *ch, int len) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 848 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 849 | /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 850 | #ifdef DEBUG_SAX |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 851 | fprintf(stderr, "SAX.ignorableWhitespace(%.30s, %d)\n", ch, len); |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 852 | #endif |
| 853 | } |
| 854 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 855 | /** |
| 856 | * processingInstruction: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 857 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 858 | * @target: the target name |
| 859 | * @data: the PI data's |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 860 | * @len: the number of xmlChar |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 861 | * |
| 862 | * A processing instruction has been parsed. |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 863 | */ |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 864 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 865 | processingInstruction(void *ctx, const xmlChar *target, |
| 866 | const xmlChar *data) |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 867 | { |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 868 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 869 | xmlNodePtr ret; |
| 870 | xmlNodePtr parent = ctxt->node; |
| 871 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 872 | #ifdef DEBUG_SAX |
| 873 | fprintf(stderr, "SAX.processingInstruction(%s, %s)\n", target, data); |
| 874 | #endif |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 875 | |
| 876 | ret = xmlNewPI(target, data); |
| 877 | if (ret == NULL) return; |
| 878 | ret->doc = ctxt->myDoc; |
| 879 | if (ctxt->myDoc->root == NULL) { |
| 880 | #ifdef DEBUG_SAX_TREE |
| 881 | fprintf(stderr, "Setting PI %s as root\n", target); |
| 882 | #endif |
| 883 | ctxt->myDoc->root = ret; |
| 884 | } else if (parent == NULL) { |
| 885 | parent = ctxt->myDoc->root; |
| 886 | } |
| 887 | if (parent != NULL) { |
| 888 | if (parent->type == XML_ELEMENT_NODE) { |
| 889 | #ifdef DEBUG_SAX_TREE |
| 890 | fprintf(stderr, "adding PI child %s to %s\n", target, parent->name); |
| 891 | #endif |
| 892 | xmlAddChild(parent, ret); |
| 893 | } else { |
| 894 | #ifdef DEBUG_SAX_TREE |
| 895 | fprintf(stderr, "adding PI sibling %s to ", target); |
| 896 | xmlDebugDumpOneNode(stderr, parent, 0); |
| 897 | #endif |
| 898 | xmlAddSibling(parent, ret); |
| 899 | } |
| 900 | } |
| 901 | |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 902 | } |
| 903 | |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 904 | /** |
| 905 | * globalNamespace: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 906 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 907 | * @href: the namespace associated URN |
| 908 | * @prefix: the namespace prefix |
| 909 | * |
| 910 | * An old global namespace has been parsed. |
| 911 | */ |
| 912 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 913 | globalNamespace(void *ctx, const xmlChar *href, const xmlChar *prefix) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 914 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 915 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 916 | #ifdef DEBUG_SAX |
| 917 | fprintf(stderr, "SAX.globalNamespace(%s, %s)\n", href, prefix); |
| 918 | #endif |
| 919 | xmlNewGlobalNs(ctxt->myDoc, href, prefix); |
| 920 | } |
| 921 | |
| 922 | /** |
| 923 | * setNamespace: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 924 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 925 | * @name: the namespace prefix |
| 926 | * |
| 927 | * Set the current element namespace. |
| 928 | */ |
| 929 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 930 | setNamespace(void *ctx, const xmlChar *name) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 931 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 932 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 933 | xmlNsPtr ns; |
| 934 | xmlNodePtr parent; |
| 935 | |
| 936 | #ifdef DEBUG_SAX |
| 937 | fprintf(stderr, "SAX.setNamespace(%s)\n", name); |
| 938 | #endif |
| 939 | ns = xmlSearchNs(ctxt->myDoc, ctxt->node, name); |
| 940 | if (ns == NULL) { /* ctxt->node may not have a parent yet ! */ |
| 941 | if (ctxt->nodeNr >= 2) { |
| 942 | parent = ctxt->nodeTab[ctxt->nodeNr - 2]; |
| 943 | if (parent != NULL) |
| 944 | ns = xmlSearchNs(ctxt->myDoc, parent, name); |
| 945 | } |
| 946 | } |
| 947 | xmlSetNs(ctxt->node, ns); |
| 948 | } |
| 949 | |
| 950 | /** |
| 951 | * getNamespace: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 952 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 953 | * |
| 954 | * Get the current element namespace. |
| 955 | */ |
| 956 | xmlNsPtr |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 957 | getNamespace(void *ctx) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 958 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 959 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 960 | xmlNsPtr ret; |
| 961 | |
| 962 | #ifdef DEBUG_SAX |
| 963 | fprintf(stderr, "SAX.getNamespace()\n"); |
| 964 | #endif |
| 965 | ret = ctxt->node->ns; |
| 966 | return(ret); |
| 967 | } |
| 968 | |
| 969 | /** |
| 970 | * checkNamespace: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 971 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 972 | * @namespace: the namespace to check against |
| 973 | * |
| 974 | * Check that the current element namespace is the same as the |
| 975 | * one read upon parsing. |
| 976 | */ |
| 977 | int |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 978 | checkNamespace(void *ctx, xmlChar *namespace) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 979 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 980 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 981 | xmlNodePtr cur = ctxt->node; |
| 982 | |
| 983 | #ifdef DEBUG_SAX |
| 984 | fprintf(stderr, "SAX.checkNamespace(%s)\n", namespace); |
| 985 | #endif |
| 986 | |
| 987 | /* |
| 988 | * Check that the Name in the ETag is the same as in the STag. |
| 989 | */ |
| 990 | if (namespace == NULL) { |
| 991 | if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { |
| 992 | if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) |
| 993 | ctxt->sax->error(ctxt, |
| 994 | "End tags for %s don't hold the namespace %s\n", |
| 995 | cur->name, cur->ns->prefix); |
| 996 | ctxt->wellFormed = 0; |
| 997 | } |
| 998 | } else { |
| 999 | if ((cur->ns == NULL) || (cur->ns->prefix == NULL)) { |
| 1000 | if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) |
| 1001 | ctxt->sax->error(ctxt, |
| 1002 | "End tags %s holds a prefix %s not used by the open tag\n", |
| 1003 | cur->name, namespace); |
| 1004 | ctxt->wellFormed = 0; |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 1005 | } else if (xmlStrcmp(namespace, cur->ns->prefix)) { |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1006 | if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) |
| 1007 | ctxt->sax->error(ctxt, |
| 1008 | "Start and End tags for %s don't use the same namespaces: %s and %s\n", |
| 1009 | cur->name, cur->ns->prefix, namespace); |
| 1010 | ctxt->wellFormed = 0; |
| 1011 | } else |
| 1012 | return(1); |
| 1013 | } |
| 1014 | return(0); |
| 1015 | } |
| 1016 | |
| 1017 | /** |
| 1018 | * namespaceDecl: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 1019 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1020 | * @href: the namespace associated URN |
| 1021 | * @prefix: the namespace prefix |
| 1022 | * |
| 1023 | * A namespace has been parsed. |
| 1024 | */ |
| 1025 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 1026 | namespaceDecl(void *ctx, const xmlChar *href, const xmlChar *prefix) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1027 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 1028 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1029 | #ifdef DEBUG_SAX |
| 1030 | if (prefix == NULL) |
| 1031 | fprintf(stderr, "SAX.namespaceDecl(%s, NULL)\n", href); |
| 1032 | else |
| 1033 | fprintf(stderr, "SAX.namespaceDecl(%s, %s)\n", href, prefix); |
| 1034 | #endif |
| 1035 | xmlNewNs(ctxt->node, href, prefix); |
| 1036 | } |
| 1037 | |
| 1038 | /** |
| 1039 | * comment: |
Daniel Veillard | 011b63c | 1999-06-02 17:44:04 +0000 | [diff] [blame] | 1040 | * @ctx: the user data (XML parser context) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1041 | * @value: the comment content |
| 1042 | * |
| 1043 | * A comment has been parsed. |
| 1044 | */ |
| 1045 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 1046 | comment(void *ctx, const xmlChar *value) |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1047 | { |
Daniel Veillard | 27d8874 | 1999-05-29 11:51:49 +0000 | [diff] [blame] | 1048 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 1049 | xmlNodePtr ret; |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 1050 | xmlNodePtr parent = ctxt->node; |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 1051 | |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1052 | #ifdef DEBUG_SAX |
| 1053 | fprintf(stderr, "SAX.comment(%s)\n", value); |
| 1054 | #endif |
Daniel Veillard | 14fff06 | 1999-06-22 21:49:07 +0000 | [diff] [blame] | 1055 | ret = xmlNewDocComment(ctxt->myDoc, value); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 1056 | if (ret == NULL) return; |
| 1057 | |
| 1058 | if (ctxt->myDoc->root == NULL) { |
| 1059 | #ifdef DEBUG_SAX_TREE |
| 1060 | fprintf(stderr, "Setting comment as root\n"); |
| 1061 | #endif |
| 1062 | ctxt->myDoc->root = ret; |
| 1063 | } else if (parent == NULL) { |
| 1064 | parent = ctxt->myDoc->root; |
| 1065 | } |
| 1066 | if (parent != NULL) { |
| 1067 | if (parent->type == XML_ELEMENT_NODE) { |
| 1068 | #ifdef DEBUG_SAX_TREE |
| 1069 | fprintf(stderr, "adding comment child to %s\n", parent->name); |
| 1070 | #endif |
| 1071 | xmlAddChild(parent, ret); |
| 1072 | } else { |
| 1073 | #ifdef DEBUG_SAX_TREE |
| 1074 | fprintf(stderr, "adding comment sibling to "); |
| 1075 | xmlDebugDumpOneNode(stderr, parent, 0); |
| 1076 | #endif |
| 1077 | xmlAddSibling(parent, ret); |
| 1078 | } |
| 1079 | } |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | /** |
| 1083 | * cdataBlock: |
| 1084 | * @ctx: the user data (XML parser context) |
| 1085 | * @value: The pcdata content |
| 1086 | * @len: the block length |
| 1087 | * |
| 1088 | * called when a pcdata block has been parsed |
| 1089 | */ |
| 1090 | void |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 1091 | cdataBlock(void *ctx, const xmlChar *value, int len) |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1092 | { |
| 1093 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 1094 | xmlNodePtr ret; |
| 1095 | |
| 1096 | #ifdef DEBUG_SAX |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 1097 | fprintf(stderr, "SAX.pcdata(%.10s, %d)\n", value, len); |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1098 | #endif |
| 1099 | ret = xmlNewCDataBlock(ctxt->myDoc, value, len); |
| 1100 | xmlAddChild(ctxt->node, ret); |
| 1101 | /* !!!!! merges */ |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1102 | } |
| 1103 | |
Daniel Veillard | be70ff7 | 1999-07-05 16:50:46 +0000 | [diff] [blame] | 1104 | /* |
| 1105 | * Default handler for XML, builds the DOM tree |
| 1106 | */ |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1107 | xmlSAXHandler xmlDefaultSAXHandler = { |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1108 | internalSubset, |
| 1109 | isStandalone, |
| 1110 | hasInternalSubset, |
| 1111 | hasExternalSubset, |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1112 | resolveEntity, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1113 | getEntity, |
| 1114 | entityDecl, |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1115 | notationDecl, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1116 | attributeDecl, |
| 1117 | elementDecl, |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1118 | unparsedEntityDecl, |
| 1119 | setDocumentLocator, |
| 1120 | startDocument, |
| 1121 | endDocument, |
| 1122 | startElement, |
| 1123 | endElement, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1124 | reference, |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1125 | characters, |
| 1126 | ignorableWhitespace, |
| 1127 | processingInstruction, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1128 | comment, |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1129 | xmlParserWarning, |
| 1130 | xmlParserError, |
| 1131 | xmlParserError, |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1132 | getParameterEntity, |
| 1133 | cdataBlock, |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1134 | }; |
| 1135 | |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 1136 | /** |
| 1137 | * xmlDefaultSAXHandlerInit: |
| 1138 | * |
| 1139 | * Initialize the default SAX handler |
Daniel Veillard | 97b5877 | 1998-10-20 06:14:16 +0000 | [diff] [blame] | 1140 | */ |
| 1141 | void |
| 1142 | xmlDefaultSAXHandlerInit(void) |
| 1143 | { |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1144 | xmlDefaultSAXHandler.internalSubset = internalSubset; |
| 1145 | xmlDefaultSAXHandler.isStandalone = isStandalone; |
| 1146 | xmlDefaultSAXHandler.hasInternalSubset = hasInternalSubset; |
| 1147 | xmlDefaultSAXHandler.hasExternalSubset = hasExternalSubset; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1148 | xmlDefaultSAXHandler.resolveEntity = resolveEntity; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1149 | xmlDefaultSAXHandler.getEntity = getEntity; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1150 | xmlDefaultSAXHandler.getParameterEntity = getParameterEntity; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1151 | xmlDefaultSAXHandler.entityDecl = entityDecl; |
| 1152 | xmlDefaultSAXHandler.attributeDecl = attributeDecl; |
| 1153 | xmlDefaultSAXHandler.elementDecl = elementDecl; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1154 | xmlDefaultSAXHandler.notationDecl = notationDecl; |
| 1155 | xmlDefaultSAXHandler.unparsedEntityDecl = unparsedEntityDecl; |
| 1156 | xmlDefaultSAXHandler.setDocumentLocator = setDocumentLocator; |
| 1157 | xmlDefaultSAXHandler.startDocument = startDocument; |
| 1158 | xmlDefaultSAXHandler.endDocument = endDocument; |
| 1159 | xmlDefaultSAXHandler.startElement = startElement; |
| 1160 | xmlDefaultSAXHandler.endElement = endElement; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1161 | xmlDefaultSAXHandler.reference = reference; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1162 | xmlDefaultSAXHandler.characters = characters; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1163 | xmlDefaultSAXHandler.cdataBlock = cdataBlock; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1164 | xmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace; |
| 1165 | xmlDefaultSAXHandler.processingInstruction = processingInstruction; |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 1166 | xmlDefaultSAXHandler.comment = comment; |
Daniel Veillard | 260a68f | 1998-08-13 03:39:55 +0000 | [diff] [blame] | 1167 | xmlDefaultSAXHandler.warning = xmlParserWarning; |
| 1168 | xmlDefaultSAXHandler.error = xmlParserError; |
| 1169 | xmlDefaultSAXHandler.fatalError = xmlParserError; |
| 1170 | } |
Daniel Veillard | be70ff7 | 1999-07-05 16:50:46 +0000 | [diff] [blame] | 1171 | |
| 1172 | /* |
| 1173 | * Default handler for HTML, builds the DOM tree |
| 1174 | */ |
| 1175 | xmlSAXHandler htmlDefaultSAXHandler = { |
| 1176 | NULL, |
| 1177 | NULL, |
| 1178 | NULL, |
| 1179 | NULL, |
| 1180 | NULL, |
| 1181 | getEntity, |
| 1182 | NULL, |
| 1183 | NULL, |
| 1184 | NULL, |
| 1185 | NULL, |
| 1186 | NULL, |
| 1187 | setDocumentLocator, |
| 1188 | startDocument, |
| 1189 | endDocument, |
| 1190 | startElement, |
| 1191 | endElement, |
| 1192 | NULL, |
| 1193 | characters, |
| 1194 | ignorableWhitespace, |
| 1195 | NULL, |
| 1196 | comment, |
| 1197 | xmlParserWarning, |
| 1198 | xmlParserError, |
| 1199 | xmlParserError, |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1200 | getParameterEntity, |
| 1201 | NULL, |
Daniel Veillard | be70ff7 | 1999-07-05 16:50:46 +0000 | [diff] [blame] | 1202 | }; |
| 1203 | |
| 1204 | /** |
| 1205 | * htmlDefaultSAXHandlerInit: |
| 1206 | * |
| 1207 | * Initialize the default SAX handler |
| 1208 | */ |
| 1209 | void |
| 1210 | htmlDefaultSAXHandlerInit(void) |
| 1211 | { |
| 1212 | htmlDefaultSAXHandler.internalSubset = NULL; |
| 1213 | htmlDefaultSAXHandler.isStandalone = NULL; |
| 1214 | htmlDefaultSAXHandler.hasInternalSubset = NULL; |
| 1215 | htmlDefaultSAXHandler.hasExternalSubset = NULL; |
| 1216 | htmlDefaultSAXHandler.resolveEntity = NULL; |
| 1217 | htmlDefaultSAXHandler.getEntity = getEntity; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1218 | htmlDefaultSAXHandler.getParameterEntity = NULL; |
Daniel Veillard | be70ff7 | 1999-07-05 16:50:46 +0000 | [diff] [blame] | 1219 | htmlDefaultSAXHandler.entityDecl = NULL; |
| 1220 | htmlDefaultSAXHandler.attributeDecl = NULL; |
| 1221 | htmlDefaultSAXHandler.elementDecl = NULL; |
| 1222 | htmlDefaultSAXHandler.notationDecl = NULL; |
| 1223 | htmlDefaultSAXHandler.unparsedEntityDecl = NULL; |
| 1224 | htmlDefaultSAXHandler.setDocumentLocator = setDocumentLocator; |
| 1225 | htmlDefaultSAXHandler.startDocument = startDocument; |
| 1226 | htmlDefaultSAXHandler.endDocument = endDocument; |
| 1227 | htmlDefaultSAXHandler.startElement = startElement; |
| 1228 | htmlDefaultSAXHandler.endElement = endElement; |
| 1229 | htmlDefaultSAXHandler.reference = NULL; |
| 1230 | htmlDefaultSAXHandler.characters = characters; |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 1231 | htmlDefaultSAXHandler.cdataBlock = NULL; |
Daniel Veillard | be70ff7 | 1999-07-05 16:50:46 +0000 | [diff] [blame] | 1232 | htmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace; |
| 1233 | htmlDefaultSAXHandler.processingInstruction = NULL; |
| 1234 | htmlDefaultSAXHandler.comment = comment; |
| 1235 | htmlDefaultSAXHandler.warning = xmlParserWarning; |
| 1236 | htmlDefaultSAXHandler.error = xmlParserError; |
| 1237 | htmlDefaultSAXHandler.fatalError = xmlParserError; |
| 1238 | } |