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