1 /* 2 * The contents of this file are subject to the Mozilla Public 3 * License Version 1.1 (the "License"); you may not use this file 4 * except in compliance with the License. You may obtain a copy of 5 * the License at http://www.mozilla.org/MPL/ 6 * 7 * Software distributed under the License is distributed on an "AS 8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 * implied. See the License for the specific language governing 10 * rights and limitations under the License. 11 * 12 * The Original Code is the Sablotron XSLT Processor. 13 * 14 * The Initial Developer of the Original Code is Ginger Alliance Ltd. 15 * Portions created by Ginger Alliance are Copyright (C) 2000-2002 16 * Ginger Alliance Ltd. All Rights Reserved. 17 * 18 * Contributor(s): 19 * 20 * Alternatively, the contents of this file may be used under the 21 * terms of the GNU General Public License Version 2 or later (the 22 * "GPL"), in which case the provisions of the GPL are applicable 23 * instead of those above. If you wish to allow use of your 24 * version of this file only under the terms of the GPL and not to 25 * allow others to use your version of this file under the MPL, 26 * indicate your decision by deleting the provisions above and 27 * replace them with the notice and other provisions required by 28 * the GPL. If you do not delete the provisions above, a recipient 29 * may use your version of this file under either the MPL or the 30 * GPL. 31 */ 32 33 #ifndef ErrorHIncl 34 #define ErrorHIncl 35 36 // GP: clean 37 38 /* 39 #define Err(situation, code) { if (situation) { situation->error(code, (char*) NULL, (char*) NULL); return NOT_OK; } } 40 #define Err1(situation, code, arg1) { if (situation) { situation->error(code, arg1, (char*) NULL); return NOT_OK; } } 41 #define Err2(situation, code, arg1, arg2) { if (situation) { situation->error(code, arg1, arg2); return NOT_OK; } } 42 */ 43 44 #define Err(sit, code) \ 45 { report(sit, MT_ERROR, code, (char*)NULL, (char*)NULL); return NOT_OK; } 46 #define Err1(sit, code, arg1) \ 47 { report(sit, MT_ERROR, code, arg1, (char*)NULL); return NOT_OK; } 48 #define Err2(sit, code, arg1, arg2) \ 49 { report(sit, MT_ERROR, code, arg1, arg2); return NOT_OK; } 50 51 #define ErrT(obj, sit, code) \ 52 { obj -> report(sit, MT_ERROR, code, (char*)NULL, (char*)NULL); return NOT_OK; } 53 #define Err1T(obj, sit, code, arg1) \ 54 { obj -> report(sit, MT_ERROR, code, arg1, (char*)NULL); return NOT_OK; } 55 #define Err2T(obj, sit, code, arg1, arg2) \ 56 { obj -> report(sit, MT_ERROR, code, arg1, arg2); return NOT_OK; } 57 58 #define E(statement) {if (statement) return NOT_OK;} 59 #define E_DO(statement, onExit) {if (statement) {{onExit;}; return NOT_OK;}} 60 61 // the memory allocation checking macro 62 // use as M( newInstance = new SomeClass ); 63 #define M( sit, ptr ) {if (!(ptr)) Err(sit, E_MEMORY);} 64 #define MT( obj, sit, ptr ) {if (!(ptr)) ErrT(obj, sit, E_MEMORY);} 65 66 #define Warn(sit, code) \ 67 report(sit, MT_WARN, code, (char*)NULL, (char*)NULL); 68 #define Warn1(sit, code, arg1) \ 69 report(sit, MT_WARN, code, arg1, (char*)NULL); 70 #define Warn2(sit, code, arg1, arg2) \ 71 report(sit, MT_WARN, code, arg1, arg2); 72 #define Log(sit, code) \ 73 report(sit, MT_LOG, code, (char*)NULL, (char*)NULL); 74 #define Log1(sit, code, arg1) \ 75 report(sit, MT_LOG, code, arg1, (char*)NULL); 76 #define Log2(sit, code, arg1, arg2) \ 77 report(sit, MT_LOG, code, arg1, arg2); 78 79 enum MsgCode 80 { 81 82 // 83 // errors 84 // 85 86 // no error: 87 E_OK, 88 // generic error 89 E_NOT_OK, 90 91 // XML parsing 92 93 // expat parsing error 94 E_XML, 95 // bad char for encoding '...' 96 E1_BAD_CHAR, 97 98 // resource allocation 99 100 // file open problem 101 E_FILE_OPEN, 102 // not enough memory to open processor 103 E_MEMORY, 104 105 // XSLT parsing 106 107 // unsupported XSL instruction 108 E1_UNSUPP_XSL, 109 // nonexistent XSL instruction 110 ET_BAD_XSL, 111 // missing required attribute 112 ET_REQ_ATTR, 113 // unexpected attribute 114 ET_BAD_ATTR, 115 // bad axis 116 E1_UNKNOWN_AXIS, 117 // general expression syntax error 118 ET_EXPR_SYNTAX, 119 // number in bad format 120 ET_BAD_NUMBER, 121 // illegal variable name 122 ET_BAD_VAR, 123 // missing right delimiter of a literal 124 ET_INFINITE_LITERAL, 125 // '(' expected 126 ET_LPAREN_EXP, 127 // ')' expected 128 ET_RPAREN_EXP, 129 // '(' or '[' expected 130 ET_LPARCKET_EXP, 131 // ']' expected 132 ET_RBRACKET_EXP, 133 // pattern empty 134 ET_EMPTY_PATT, 135 // token not recognized 136 ET_BAD_TOKEN, 137 // patterns allow only several axes 138 E_BAD_AXIS_IN_PATTERN, 139 // invalid pattern 140 E_BAD_PATTERN, 141 // variable in match att 142 E_VAR_IN_MATCH, 143 // invalid namespace prefix 144 ET_BAD_PREFIX, 145 // name contains 2 colons 146 E1_EXTRA_COLON, 147 // this XSLT element must be empty 148 E_ELEM_MUST_EMPTY, 149 // element can only contain XSLT elements 150 E_ELEM_CONT_TEXT_OR_LRE, 151 // element cannot contain this element at this point 152 E_ELEM_CONTAINS_ELEM, 153 //element must contain PCDATA only 154 E_ELEM_MUST_BE_PCDATA, 155 // element can only be used at top level 156 E1_ELEM_TOPLEVEL, 157 // bad element content 158 E_BAD_ELEM_CONTENT, 159 160 // XSLT stylesheet compilation 161 162 // duplicate rule name 163 ET_DUPLICATE_RULE_NAME, 164 //duplicate attribute set name 165 ET_DUPLICATE_ASET_NAME, 166 E1_NONEX_ASET_NAME, 167 E1_CIRCULAR_ASET_REF, 168 // name contains 2 colons 169 // E1_EXTRA_COLON, (above) 170 // number in bad format 171 // ET_BAD_NUMBER, (above) 172 // duplicate key name 173 E1_DUPLICIT_KEY, 174 // non-existent key name 175 E1_KEY_NOT_FOUND, 176 177 // decimal-format related: 178 179 // option specified twice 180 E1_FORMAT_DUPLICIT_OPTION, 181 182 // option value must be char 183 E1_FORMAT_OPTION_CHAR, 184 185 // decimal-format name conflict 186 E1_FORMAT_DUPLICIT_NAME, 187 188 // decimal-format not defined 189 E1_FORMAT_NOT_FOUND, 190 191 // invalid format string 192 E_FORMAT_INVALID, 193 194 // xsl:number related: 195 // invalid value of @level: 196 E1_NUMBER_LEVEL, 197 // invalid value of @letter-value: 198 E1_NUMBER_LETTER_VALUE, 199 200 // circular include/import/ext entity ref 201 E1_CIRCULAR_INCLUSION, 202 203 // XSLT execution 204 205 // variable not found 206 E1_VAR_NOT_FOUND, 207 // circular var reference 208 E1_VAR_CIRCULAR_REF, 209 // expression is not a node set 210 ET_CONTEXT_FOR_BAD_EXPR, 211 // invalid # of arguments 212 ET_BAD_ARGS_N, 213 // illegal function argument type 214 ET_BAD_ARG_TYPE, 215 // called unsupported function 216 ET_FUNC_NOT_SUPPORTED, 217 // invalid namespace prefix 218 // ET_BAD_PREFIX, (above) 219 // called non-existent rule 220 E1_RULE_NOT_FOUND, 221 // conflicting variable bindings (name) 222 E1_MULT_ASSIGNMENT, 223 // name contains 2 colons 224 // E1_EXTRA_COLON, (above) 225 // must be a yes/no attribute 226 E1_ATTR_YES_NO, 227 // attribute created after a child was added 228 E1_ATTRIBUTE_TOO_LATE, 229 // attribute with no parent 230 E1_ATTRIBUTE_OUTSIDE, 231 // character '...' is illegal in this encoding (on output) 232 E1_BAD_CHAR_IN_ENC, 233 // invalid processing instruction target 234 E1_PI_TARGET, 235 // element created inside a comment or PI 236 E_ELEM_IN_COMMENT_PI, 237 // terminating xsl:message 238 E1_XSL_MESSAGE_TERM, 239 240 // hard to file 241 242 // can't open document 243 E1_URI_OPEN, 244 // can't close document 245 E1_URI_CLOSE, 246 // can't read from document 247 E1_URI_READ, 248 // can't write to document 249 E1_URI_WRITE, 250 // named buffer (arg://...) not found 251 E1_ARG_NOT_FOUND, 252 // duplicate named buffer 253 E1_DUPLICATE_ARG, 254 // unsupported URI scheme 255 E1_UNSUPPORTED_SCHEME, 256 // invalid handler type 257 E1_INVALID_HLR_TYPE, 258 // unknown encoding 259 E1_UNKNOWN_ENC, 260 261 // DOM exception 262 263 E2_SDOM, 264 265 E_NONE, 266 267 //namespace exclusions 268 E_EX_NAMESPACE_UNKNOWN, 269 270 // ?> in PI data 271 E_INVALID_DATA_IN_PI, 272 273 //extension elements 274 E_UNSUPPORTED_EXELEMENT, 275 E_ATTR_MISSING, 276 E_JS_EVAL_ERROR, 277 278 E_DUPLICIT_ATTRIBUTE, 279 E_DUPLICIT_OUTDOC, 280 281 // 282 // warnings 283 // 284 285 // lang() not supported, returning false 286 W_UNSUPP_LANG, 287 // included/importe stylesheet is no stylesheet 288 W_NO_STYLESHEET, 289 290 // scheme handler warnings 291 292 // conflicting handler registration 293 W1_HLR_REGISTERED, 294 // handler not registered, can't unregister 295 W1_HLR_NOT_REGISTERED, 296 // obsolete XSLT namespace 297 W1_OLD_NS_USED, 298 // xsl prefix bound to non-XSLT URI 299 W1_XSL_NOT_XSL, 300 // conflicting attributes on xsl:output 301 W1_OUTPUT_ATTR, 302 // can't disable output escaping on non-text 303 W_DISABLE_OUTPUT_ESC, 304 // unsupported output encoding 305 W1_UNSUPP_OUT_ENCODING, 306 // unsupported XSL instruction 307 W1_UNSUPP_XSL, 308 // non-terminating xsl:message 309 W1_XSL_MESSAGE_NOTERM, 310 // unknown data type on xsl:sort 311 W1_SORT_DATA_TYPE, 312 // invlaid sort order on xsl:sort 313 W1_SORT_ORDER, 314 // invalid case order on xsl:sort 315 W1_SORT_CASE_ORDER, 316 // unsupported language on xsl:sort 317 W1_LANG, 318 // wcsxfrm unavailable 319 W_NO_WCSXFRM, 320 // document starts with unrecognizable sequence 321 W_BAD_START, 322 // no valid value of @grouping-size or @grouping-seoarator on xsl:number 323 W_NUMBER_GROUPING, 324 // a non-positive number in xsl:number 325 W_NUMBER_NOT_POSITIVE, 326 // attribute set redefinition 327 W2_ATTSET_REDEF, 328 // alias redefinition 329 W1_ALIAS_REDEF, 330 //invalid xml names 331 E_INVALID_QNAME, 332 E_INVALID_NCNAME, 333 //doc fragment 334 E_DOC_FRAGMENT, 335 //invalid operand to comparison (usually EX_EXTERNAL) 336 E_INVALID_OPERAND_TYPE, 337 //attribute emitted in a bad place 338 E1_ATTRIBUTE_MISPLACED, 339 340 W_NONE, 341 342 // 343 // log messages 344 // 345 346 // starting processing 347 L_START, 348 // stopping processing 349 L_STOP, 350 // starting parse 351 L1_PARSING, 352 // parse finished 353 L1_PARSE_DONE, 354 // starting execution 355 L1_EXECUTING, 356 // execution finished 357 L1_EXECUTION_DONE, 358 // parsing external entity 359 L1_READING_EXT_ENTITY, 360 // destroying the arena 361 L2_DISP_ARENA, 362 // destroying the hash table 363 L2_DISP_HASH, 364 // key added 365 L2_KEY_ADDED, 366 //subsidiary document 367 L2_SUBDOC, 368 L2_SUBDOC_BASE, 369 L2_SUBDOC_STARTED, 370 //Javascript Logging 371 L_JS_LOG, 372 //stylesheet structure 373 L_SHEET_STRUCTURE, 374 L_SHEET_ITEM, 375 376 L_NONE, 377 378 //used for debugger 379 DBG_BREAK_PROCESSOR, 380 381 MSG_ERROR = 0x4000, 382 MSG_WARNING, 383 MSG_LOG, 384 385 //terminal 386 MSG_LAST 387 }; 388 389 struct SabMsg 390 { 391 MsgCode code; 392 const char *text; 393 }; 394 395 extern SabMsg* GetMessage(MsgCode e); 396 397 #endif //ifndef ErrorHIncl 398