blob: 3d29c984bb5e0e8175420fca6990e06ac452f666 [file] [log] [blame]
Daniel Veillard8940fd52003-09-29 09:07:08 +00001/*
2 * legacy.c: set of deprecated routines, not to be used anymore but
3 * kept purely for ABI compatibility
4 *
5 * See Copyright for the status of this software.
6 *
7 * daniel@veillard.com
8 */
9
10#define IN_LIBXML
11#include "libxml.h"
12
13#include <libxml/tree.h>
14#include <libxml/entities.h>
15#include <libxml/SAX.h>
16#include <libxml/parserInternals.h>
17
18#ifdef LIBXML_LEGACY_ENABLED
19void xmlUpgradeOldNs(xmlDocPtr doc);
20
21/************************************************************************
22 * *
23 * Deprecated functions kept for compatibility *
24 * *
25 ************************************************************************/
26
Daniel Veillard73b013f2003-09-30 12:36:01 +000027static const char *xmlFeaturesList[] = {
28 "validate",
29 "load subset",
30 "keep blanks",
31 "disable SAX",
32 "fetch external entities",
33 "substitute entities",
34 "gather line info",
35 "user data",
36 "is html",
37 "is standalone",
38 "stop parser",
39 "document",
40 "is well formed",
41 "is valid",
42 "SAX block",
43 "SAX function internalSubset",
44 "SAX function isStandalone",
45 "SAX function hasInternalSubset",
46 "SAX function hasExternalSubset",
47 "SAX function resolveEntity",
48 "SAX function getEntity",
49 "SAX function entityDecl",
50 "SAX function notationDecl",
51 "SAX function attributeDecl",
52 "SAX function elementDecl",
53 "SAX function unparsedEntityDecl",
54 "SAX function setDocumentLocator",
55 "SAX function startDocument",
56 "SAX function endDocument",
57 "SAX function startElement",
58 "SAX function endElement",
59 "SAX function reference",
60 "SAX function characters",
61 "SAX function ignorableWhitespace",
62 "SAX function processingInstruction",
63 "SAX function comment",
64 "SAX function warning",
65 "SAX function error",
66 "SAX function fatalError",
67 "SAX function getParameterEntity",
68 "SAX function cdataBlock",
69 "SAX function externalSubset",
70};
71
72/**
73 * xmlGetFeaturesList:
74 * @len: the length of the features name array (input/output)
75 * @result: an array of string to be filled with the features name.
76 *
77 * Copy at most *@len feature names into the @result array
78 *
79 * Returns -1 in case or error, or the total number of features,
80 * len is updated with the number of strings copied,
81 * strings must not be deallocated
82 */
83int
84xmlGetFeaturesList(int *len, const char **result) {
85 int ret, i;
86
87 ret = sizeof(xmlFeaturesList)/sizeof(xmlFeaturesList[0]);
88 if ((len == NULL) || (result == NULL))
89 return(ret);
90 if ((*len < 0) || (*len >= 1000))
91 return(-1);
92 if (*len > ret)
93 *len = ret;
94 for (i = 0;i < *len;i++)
95 result[i] = xmlFeaturesList[i];
96 return(ret);
97}
98
99/**
100 * xmlGetFeature:
101 * @ctxt: an XML/HTML parser context
102 * @name: the feature name
103 * @result: location to store the result
104 *
105 * Read the current value of one feature of this parser instance
106 *
107 * Returns -1 in case or error, 0 otherwise
108 */
109int
110xmlGetFeature(xmlParserCtxtPtr ctxt, const char *name, void *result) {
111 if ((ctxt == NULL) || (name == NULL) || (result == NULL))
112 return(-1);
113
114 if (!strcmp(name, "validate")) {
115 *((int *) result) = ctxt->validate;
116 } else if (!strcmp(name, "keep blanks")) {
117 *((int *) result) = ctxt->keepBlanks;
118 } else if (!strcmp(name, "disable SAX")) {
119 *((int *) result) = ctxt->disableSAX;
120 } else if (!strcmp(name, "fetch external entities")) {
121 *((int *) result) = ctxt->loadsubset;
122 } else if (!strcmp(name, "substitute entities")) {
123 *((int *) result) = ctxt->replaceEntities;
124 } else if (!strcmp(name, "gather line info")) {
125 *((int *) result) = ctxt->record_info;
126 } else if (!strcmp(name, "user data")) {
127 *((void **)result) = ctxt->userData;
128 } else if (!strcmp(name, "is html")) {
129 *((int *) result) = ctxt->html;
130 } else if (!strcmp(name, "is standalone")) {
131 *((int *) result) = ctxt->standalone;
132 } else if (!strcmp(name, "document")) {
133 *((xmlDocPtr *) result) = ctxt->myDoc;
134 } else if (!strcmp(name, "is well formed")) {
135 *((int *) result) = ctxt->wellFormed;
136 } else if (!strcmp(name, "is valid")) {
137 *((int *) result) = ctxt->valid;
138 } else if (!strcmp(name, "SAX block")) {
139 *((xmlSAXHandlerPtr *) result) = ctxt->sax;
140 } else if (!strcmp(name, "SAX function internalSubset")) {
141 *((internalSubsetSAXFunc *) result) = ctxt->sax->internalSubset;
142 } else if (!strcmp(name, "SAX function isStandalone")) {
143 *((isStandaloneSAXFunc *) result) = ctxt->sax->isStandalone;
144 } else if (!strcmp(name, "SAX function hasInternalSubset")) {
145 *((hasInternalSubsetSAXFunc *) result) = ctxt->sax->hasInternalSubset;
146 } else if (!strcmp(name, "SAX function hasExternalSubset")) {
147 *((hasExternalSubsetSAXFunc *) result) = ctxt->sax->hasExternalSubset;
148 } else if (!strcmp(name, "SAX function resolveEntity")) {
149 *((resolveEntitySAXFunc *) result) = ctxt->sax->resolveEntity;
150 } else if (!strcmp(name, "SAX function getEntity")) {
151 *((getEntitySAXFunc *) result) = ctxt->sax->getEntity;
152 } else if (!strcmp(name, "SAX function entityDecl")) {
153 *((entityDeclSAXFunc *) result) = ctxt->sax->entityDecl;
154 } else if (!strcmp(name, "SAX function notationDecl")) {
155 *((notationDeclSAXFunc *) result) = ctxt->sax->notationDecl;
156 } else if (!strcmp(name, "SAX function attributeDecl")) {
157 *((attributeDeclSAXFunc *) result) = ctxt->sax->attributeDecl;
158 } else if (!strcmp(name, "SAX function elementDecl")) {
159 *((elementDeclSAXFunc *) result) = ctxt->sax->elementDecl;
160 } else if (!strcmp(name, "SAX function unparsedEntityDecl")) {
161 *((unparsedEntityDeclSAXFunc *) result) = ctxt->sax->unparsedEntityDecl;
162 } else if (!strcmp(name, "SAX function setDocumentLocator")) {
163 *((setDocumentLocatorSAXFunc *) result) = ctxt->sax->setDocumentLocator;
164 } else if (!strcmp(name, "SAX function startDocument")) {
165 *((startDocumentSAXFunc *) result) = ctxt->sax->startDocument;
166 } else if (!strcmp(name, "SAX function endDocument")) {
167 *((endDocumentSAXFunc *) result) = ctxt->sax->endDocument;
168 } else if (!strcmp(name, "SAX function startElement")) {
169 *((startElementSAXFunc *) result) = ctxt->sax->startElement;
170 } else if (!strcmp(name, "SAX function endElement")) {
171 *((endElementSAXFunc *) result) = ctxt->sax->endElement;
172 } else if (!strcmp(name, "SAX function reference")) {
173 *((referenceSAXFunc *) result) = ctxt->sax->reference;
174 } else if (!strcmp(name, "SAX function characters")) {
175 *((charactersSAXFunc *) result) = ctxt->sax->characters;
176 } else if (!strcmp(name, "SAX function ignorableWhitespace")) {
177 *((ignorableWhitespaceSAXFunc *) result) = ctxt->sax->ignorableWhitespace;
178 } else if (!strcmp(name, "SAX function processingInstruction")) {
179 *((processingInstructionSAXFunc *) result) = ctxt->sax->processingInstruction;
180 } else if (!strcmp(name, "SAX function comment")) {
181 *((commentSAXFunc *) result) = ctxt->sax->comment;
182 } else if (!strcmp(name, "SAX function warning")) {
183 *((warningSAXFunc *) result) = ctxt->sax->warning;
184 } else if (!strcmp(name, "SAX function error")) {
185 *((errorSAXFunc *) result) = ctxt->sax->error;
186 } else if (!strcmp(name, "SAX function fatalError")) {
187 *((fatalErrorSAXFunc *) result) = ctxt->sax->fatalError;
188 } else if (!strcmp(name, "SAX function getParameterEntity")) {
189 *((getParameterEntitySAXFunc *) result) = ctxt->sax->getParameterEntity;
190 } else if (!strcmp(name, "SAX function cdataBlock")) {
191 *((cdataBlockSAXFunc *) result) = ctxt->sax->cdataBlock;
192 } else if (!strcmp(name, "SAX function externalSubset")) {
193 *((externalSubsetSAXFunc *) result) = ctxt->sax->externalSubset;
194 } else {
195 return(-1);
196 }
197 return(0);
198}
199
200/**
201 * xmlSetFeature:
202 * @ctxt: an XML/HTML parser context
203 * @name: the feature name
204 * @value: pointer to the location of the new value
205 *
206 * Change the current value of one feature of this parser instance
207 *
208 * Returns -1 in case or error, 0 otherwise
209 */
210int
211xmlSetFeature(xmlParserCtxtPtr ctxt, const char *name, void *value) {
212 if ((ctxt == NULL) || (name == NULL) || (value == NULL))
213 return(-1);
214
215 if (!strcmp(name, "validate")) {
216 int newvalidate = *((int *) value);
217 if ((!ctxt->validate) && (newvalidate != 0)) {
218 if (ctxt->vctxt.warning == NULL)
219 ctxt->vctxt.warning = xmlParserValidityWarning;
220 if (ctxt->vctxt.error == NULL)
221 ctxt->vctxt.error = xmlParserValidityError;
222 ctxt->vctxt.nodeMax = 0;
223 }
224 ctxt->validate = newvalidate;
225 } else if (!strcmp(name, "keep blanks")) {
226 ctxt->keepBlanks = *((int *) value);
227 } else if (!strcmp(name, "disable SAX")) {
228 ctxt->disableSAX = *((int *) value);
229 } else if (!strcmp(name, "fetch external entities")) {
230 ctxt->loadsubset = *((int *) value);
231 } else if (!strcmp(name, "substitute entities")) {
232 ctxt->replaceEntities = *((int *) value);
233 } else if (!strcmp(name, "gather line info")) {
234 ctxt->record_info = *((int *) value);
235 } else if (!strcmp(name, "user data")) {
236 ctxt->userData = *((void **)value);
237 } else if (!strcmp(name, "is html")) {
238 ctxt->html = *((int *) value);
239 } else if (!strcmp(name, "is standalone")) {
240 ctxt->standalone = *((int *) value);
241 } else if (!strcmp(name, "document")) {
242 ctxt->myDoc = *((xmlDocPtr *) value);
243 } else if (!strcmp(name, "is well formed")) {
244 ctxt->wellFormed = *((int *) value);
245 } else if (!strcmp(name, "is valid")) {
246 ctxt->valid = *((int *) value);
247 } else if (!strcmp(name, "SAX block")) {
248 ctxt->sax = *((xmlSAXHandlerPtr *) value);
249 } else if (!strcmp(name, "SAX function internalSubset")) {
250 ctxt->sax->internalSubset = *((internalSubsetSAXFunc *) value);
251 } else if (!strcmp(name, "SAX function isStandalone")) {
252 ctxt->sax->isStandalone = *((isStandaloneSAXFunc *) value);
253 } else if (!strcmp(name, "SAX function hasInternalSubset")) {
254 ctxt->sax->hasInternalSubset = *((hasInternalSubsetSAXFunc *) value);
255 } else if (!strcmp(name, "SAX function hasExternalSubset")) {
256 ctxt->sax->hasExternalSubset = *((hasExternalSubsetSAXFunc *) value);
257 } else if (!strcmp(name, "SAX function resolveEntity")) {
258 ctxt->sax->resolveEntity = *((resolveEntitySAXFunc *) value);
259 } else if (!strcmp(name, "SAX function getEntity")) {
260 ctxt->sax->getEntity = *((getEntitySAXFunc *) value);
261 } else if (!strcmp(name, "SAX function entityDecl")) {
262 ctxt->sax->entityDecl = *((entityDeclSAXFunc *) value);
263 } else if (!strcmp(name, "SAX function notationDecl")) {
264 ctxt->sax->notationDecl = *((notationDeclSAXFunc *) value);
265 } else if (!strcmp(name, "SAX function attributeDecl")) {
266 ctxt->sax->attributeDecl = *((attributeDeclSAXFunc *) value);
267 } else if (!strcmp(name, "SAX function elementDecl")) {
268 ctxt->sax->elementDecl = *((elementDeclSAXFunc *) value);
269 } else if (!strcmp(name, "SAX function unparsedEntityDecl")) {
270 ctxt->sax->unparsedEntityDecl = *((unparsedEntityDeclSAXFunc *) value);
271 } else if (!strcmp(name, "SAX function setDocumentLocator")) {
272 ctxt->sax->setDocumentLocator = *((setDocumentLocatorSAXFunc *) value);
273 } else if (!strcmp(name, "SAX function startDocument")) {
274 ctxt->sax->startDocument = *((startDocumentSAXFunc *) value);
275 } else if (!strcmp(name, "SAX function endDocument")) {
276 ctxt->sax->endDocument = *((endDocumentSAXFunc *) value);
277 } else if (!strcmp(name, "SAX function startElement")) {
278 ctxt->sax->startElement = *((startElementSAXFunc *) value);
279 } else if (!strcmp(name, "SAX function endElement")) {
280 ctxt->sax->endElement = *((endElementSAXFunc *) value);
281 } else if (!strcmp(name, "SAX function reference")) {
282 ctxt->sax->reference = *((referenceSAXFunc *) value);
283 } else if (!strcmp(name, "SAX function characters")) {
284 ctxt->sax->characters = *((charactersSAXFunc *) value);
285 } else if (!strcmp(name, "SAX function ignorableWhitespace")) {
286 ctxt->sax->ignorableWhitespace = *((ignorableWhitespaceSAXFunc *) value);
287 } else if (!strcmp(name, "SAX function processingInstruction")) {
288 ctxt->sax->processingInstruction = *((processingInstructionSAXFunc *) value);
289 } else if (!strcmp(name, "SAX function comment")) {
290 ctxt->sax->comment = *((commentSAXFunc *) value);
291 } else if (!strcmp(name, "SAX function warning")) {
292 ctxt->sax->warning = *((warningSAXFunc *) value);
293 } else if (!strcmp(name, "SAX function error")) {
294 ctxt->sax->error = *((errorSAXFunc *) value);
295 } else if (!strcmp(name, "SAX function fatalError")) {
296 ctxt->sax->fatalError = *((fatalErrorSAXFunc *) value);
297 } else if (!strcmp(name, "SAX function getParameterEntity")) {
298 ctxt->sax->getParameterEntity = *((getParameterEntitySAXFunc *) value);
299 } else if (!strcmp(name, "SAX function cdataBlock")) {
300 ctxt->sax->cdataBlock = *((cdataBlockSAXFunc *) value);
301 } else if (!strcmp(name, "SAX function externalSubset")) {
302 ctxt->sax->externalSubset = *((externalSubsetSAXFunc *) value);
303 } else {
304 return(-1);
305 }
306 return(0);
307}
308
Daniel Veillard8940fd52003-09-29 09:07:08 +0000309/**
310 * xmlDecodeEntities:
311 * @ctxt: the parser context
312 * @len: the len to decode (in bytes !), -1 for no size limit
313 * @what: combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF
314 * @end: an end marker xmlChar, 0 if none
315 * @end2: an end marker xmlChar, 0 if none
316 * @end3: an end marker xmlChar, 0 if none
317 *
318 * This function is deprecated, we now always process entities content
319 * through xmlStringDecodeEntities
320 *
321 * TODO: remove it in next major release.
322 *
323 * [67] Reference ::= EntityRef | CharRef
324 *
325 * [69] PEReference ::= '%' Name ';'
326 *
327 * Returns A newly allocated string with the substitution done. The caller
328 * must deallocate it !
329 */
330xmlChar *
331xmlDecodeEntities(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
332 int len ATTRIBUTE_UNUSED, int what ATTRIBUTE_UNUSED,
333 xmlChar end ATTRIBUTE_UNUSED,
334 xmlChar end2 ATTRIBUTE_UNUSED,
335 xmlChar end3 ATTRIBUTE_UNUSED)
336{
337 static int deprecated = 0;
338
339 if (!deprecated) {
340 xmlGenericError(xmlGenericErrorContext,
341 "xmlDecodeEntities() deprecated function reached\n");
342 deprecated = 1;
343 }
344 return (NULL);
345}
346
347/**
348 * xmlNamespaceParseNCName:
349 * @ctxt: an XML parser context
350 *
351 * parse an XML namespace name.
352 *
353 * TODO: this seems not in use anymore, the namespace handling is done on
354 * top of the SAX interfaces, i.e. not on raw input.
355 *
356 * [NS 3] NCName ::= (Letter | '_') (NCNameChar)*
357 *
358 * [NS 4] NCNameChar ::= Letter | Digit | '.' | '-' | '_' |
359 * CombiningChar | Extender
360 *
361 * Returns the namespace name or NULL
362 */
363
364xmlChar *
365xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
366{
367 static int deprecated = 0;
368
369 if (!deprecated) {
370 xmlGenericError(xmlGenericErrorContext,
371 "xmlNamespaceParseNCName() deprecated function reached\n");
372 deprecated = 1;
373 }
374 return (NULL);
375}
376
377/**
378 * xmlNamespaceParseQName:
379 * @ctxt: an XML parser context
380 * @prefix: a xmlChar **
381 *
382 * TODO: this seems not in use anymore, the namespace handling is done on
383 * top of the SAX interfaces, i.e. not on raw input.
384 *
385 * parse an XML qualified name
386 *
387 * [NS 5] QName ::= (Prefix ':')? LocalPart
388 *
389 * [NS 6] Prefix ::= NCName
390 *
391 * [NS 7] LocalPart ::= NCName
392 *
393 * Returns the local part, and prefix is updated
394 * to get the Prefix if any.
395 */
396
397xmlChar *
398xmlNamespaceParseQName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
399 xmlChar ** prefix ATTRIBUTE_UNUSED)
400{
401
402 static int deprecated = 0;
403
404 if (!deprecated) {
405 xmlGenericError(xmlGenericErrorContext,
406 "xmlNamespaceParseQName() deprecated function reached\n");
407 deprecated = 1;
408 }
409 return (NULL);
410}
411
412/**
413 * xmlNamespaceParseNSDef:
414 * @ctxt: an XML parser context
415 *
416 * parse a namespace prefix declaration
417 *
418 * TODO: this seems not in use anymore, the namespace handling is done on
419 * top of the SAX interfaces, i.e. not on raw input.
420 *
421 * [NS 1] NSDef ::= PrefixDef Eq SystemLiteral
422 *
423 * [NS 2] PrefixDef ::= 'xmlns' (':' NCName)?
424 *
425 * Returns the namespace name
426 */
427
428xmlChar *
429xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
430{
431 static int deprecated = 0;
432
433 if (!deprecated) {
434 xmlGenericError(xmlGenericErrorContext,
435 "xmlNamespaceParseNSDef() deprecated function reached\n");
436 deprecated = 1;
437 }
438 return (NULL);
439}
440
441/**
442 * xmlParseQuotedString:
443 * @ctxt: an XML parser context
444 *
445 * Parse and return a string between quotes or doublequotes
446 *
447 * TODO: Deprecated, to be removed at next drop of binary compatibility
448 *
449 * Returns the string parser or NULL.
450 */
451xmlChar *
452xmlParseQuotedString(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
453{
454 static int deprecated = 0;
455
456 if (!deprecated) {
457 xmlGenericError(xmlGenericErrorContext,
458 "xmlParseQuotedString() deprecated function reached\n");
459 deprecated = 1;
460 }
461 return (NULL);
462}
463
464/**
465 * xmlParseNamespace:
466 * @ctxt: an XML parser context
467 *
468 * xmlParseNamespace: parse specific PI '<?namespace ...' constructs.
469 *
470 * This is what the older xml-name Working Draft specified, a bunch of
471 * other stuff may still rely on it, so support is still here as
472 * if it was declared on the root of the Tree:-(
473 *
474 * TODO: remove from library
475 *
476 * To be removed at next drop of binary compatibility
477 */
478
479void
480xmlParseNamespace(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
481{
482 static int deprecated = 0;
483
484 if (!deprecated) {
485 xmlGenericError(xmlGenericErrorContext,
486 "xmlParseNamespace() deprecated function reached\n");
487 deprecated = 1;
488 }
489}
490
491/**
492 * xmlScanName:
493 * @ctxt: an XML parser context
494 *
495 * Trickery: parse an XML name but without consuming the input flow
496 * Needed for rollback cases. Used only when parsing entities references.
497 *
498 * TODO: seems deprecated now, only used in the default part of
499 * xmlParserHandleReference
500 *
501 * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' |
502 * CombiningChar | Extender
503 *
504 * [5] Name ::= (Letter | '_' | ':') (NameChar)*
505 *
506 * [6] Names ::= Name (S Name)*
507 *
508 * Returns the Name parsed or NULL
509 */
510
511xmlChar *
512xmlScanName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
513{
514 static int deprecated = 0;
515
516 if (!deprecated) {
517 xmlGenericError(xmlGenericErrorContext,
518 "xmlScanName() deprecated function reached\n");
519 deprecated = 1;
520 }
521 return (NULL);
522}
523
524/**
525 * xmlParserHandleReference:
526 * @ctxt: the parser context
527 *
528 * TODO: Remove, now deprecated ... the test is done directly in the
529 * content parsing
530 * routines.
531 *
532 * [67] Reference ::= EntityRef | CharRef
533 *
534 * [68] EntityRef ::= '&' Name ';'
535 *
536 * [ WFC: Entity Declared ]
537 * the Name given in the entity reference must match that in an entity
538 * declaration, except that well-formed documents need not declare any
539 * of the following entities: amp, lt, gt, apos, quot.
540 *
541 * [ WFC: Parsed Entity ]
542 * An entity reference must not contain the name of an unparsed entity
543 *
544 * [66] CharRef ::= '&#' [0-9]+ ';' |
545 * '&#x' [0-9a-fA-F]+ ';'
546 *
547 * A PEReference may have been detected in the current input stream
548 * the handling is done accordingly to
549 * http://www.w3.org/TR/REC-xml#entproc
550 */
551void
552xmlParserHandleReference(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
553{
554 static int deprecated = 0;
555
556 if (!deprecated) {
557 xmlGenericError(xmlGenericErrorContext,
558 "xmlParserHandleReference() deprecated function reached\n");
559 deprecated = 1;
560 }
561
562 return;
563}
564
565/**
566 * xmlHandleEntity:
567 * @ctxt: an XML parser context
568 * @entity: an XML entity pointer.
569 *
570 * Default handling of defined entities, when should we define a new input
571 * stream ? When do we just handle that as a set of chars ?
572 *
573 * OBSOLETE: to be removed at some point.
574 */
575
576void
577xmlHandleEntity(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
578 xmlEntityPtr entity ATTRIBUTE_UNUSED)
579{
580 static int deprecated = 0;
581
582 if (!deprecated) {
583 xmlGenericError(xmlGenericErrorContext,
584 "xmlHandleEntity() deprecated function reached\n");
585 deprecated = 1;
586 }
587}
588
589/**
590 * xmlNewGlobalNs:
591 * @doc: the document carrying the namespace
592 * @href: the URI associated
593 * @prefix: the prefix for the namespace
594 *
595 * Creation of a Namespace, the old way using PI and without scoping
596 * DEPRECATED !!!
597 * It now create a namespace on the root element of the document if found.
598 * Returns NULL this functionality had been removed
599 */
600xmlNsPtr
601xmlNewGlobalNs(xmlDocPtr doc ATTRIBUTE_UNUSED,
602 const xmlChar * href ATTRIBUTE_UNUSED,
603 const xmlChar * prefix ATTRIBUTE_UNUSED)
604{
605 static int deprecated = 0;
606
607 if (!deprecated) {
608 xmlGenericError(xmlGenericErrorContext,
609 "xmlNewGlobalNs() deprecated function reached\n");
610 deprecated = 1;
611 }
612 return (NULL);
613}
614
615/**
616 * xmlUpgradeOldNs:
617 * @doc: a document pointer
618 *
619 * Upgrade old style Namespaces (PI) and move them to the root of the document.
620 * DEPRECATED
621 */
622void
623xmlUpgradeOldNs(xmlDocPtr doc ATTRIBUTE_UNUSED)
624{
625 static int deprecated = 0;
626
627 if (!deprecated) {
628 xmlGenericError(xmlGenericErrorContext,
629 "xmlUpgradeOldNs() deprecated function reached\n");
630 deprecated = 1;
631 }
632}
633
634/**
635 * xmlEncodeEntities:
636 * @doc: the document containing the string
637 * @input: A string to convert to XML.
638 *
639 * TODO: remove xmlEncodeEntities, once we are not afraid of breaking binary
640 * compatibility
641 *
642 * People must migrate their code to xmlEncodeEntitiesReentrant !
643 * This routine will issue a warning when encountered.
644 *
645 * Returns NULL
646 */
647const xmlChar *
648xmlEncodeEntities(xmlDocPtr doc ATTRIBUTE_UNUSED,
649 const xmlChar *input ATTRIBUTE_UNUSED) {
650 static int warning = 1;
651
652 if (warning) {
653 xmlGenericError(xmlGenericErrorContext,
654 "Deprecated API xmlEncodeEntities() used\n");
655 xmlGenericError(xmlGenericErrorContext,
656 " change code to use xmlEncodeEntitiesReentrant()\n");
657 warning = 0;
658 }
659 return(NULL);
660}
661
662/************************************************************************
663 * *
664 * Old set of SAXv1 functions *
665 * *
666 ************************************************************************/
667static int deprecated_v1_msg = 0;
668
669#define DEPRECATED(n) \
670 if (deprecated_v1_msg == 0) \
671 xmlGenericError(xmlGenericErrorContext, \
672 "Use of deprecated SAXv1 function %s\n", n); \
673 deprecated_v1_msg++;
674
675/**
676 * getPublicId:
677 * @ctx: the user data (XML parser context)
678 *
679 * Provides the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"
680 * DEPRECATED: use xmlSAX2GetPublicId()
681 *
682 * Returns a xmlChar *
683 */
684const xmlChar *
685getPublicId(void *ctx)
686{
687 DEPRECATED("getPublicId")
688 return(xmlSAX2GetPublicId(ctx));
689}
690
691/**
692 * getSystemId:
693 * @ctx: the user data (XML parser context)
694 *
695 * Provides the system ID, basically URL or filename e.g.
696 * http://www.sgmlsource.com/dtds/memo.dtd
697 * DEPRECATED: use xmlSAX2GetSystemId()
698 *
699 * Returns a xmlChar *
700 */
701const xmlChar *
702getSystemId(void *ctx)
703{
704 DEPRECATED("getSystemId")
705 return(xmlSAX2GetSystemId(ctx));
706}
707
708/**
709 * getLineNumber:
710 * @ctx: the user data (XML parser context)
711 *
712 * Provide the line number of the current parsing point.
713 * DEPRECATED: use xmlSAX2GetLineNumber()
714 *
715 * Returns an int
716 */
717int
718getLineNumber(void *ctx)
719{
720 DEPRECATED("getLineNumber")
721 return(xmlSAX2GetLineNumber(ctx));
722}
723
724/**
725 * getColumnNumber:
726 * @ctx: the user data (XML parser context)
727 *
728 * Provide the column number of the current parsing point.
729 * DEPRECATED: use xmlSAX2GetColumnNumber()
730 *
731 * Returns an int
732 */
733int
734getColumnNumber(void *ctx)
735{
736 DEPRECATED("getColumnNumber")
737 return(xmlSAX2GetColumnNumber(ctx));
738}
739
740/**
741 * isStandalone:
742 * @ctx: the user data (XML parser context)
743 *
744 * Is this document tagged standalone ?
745 * DEPRECATED: use xmlSAX2IsStandalone()
746 *
747 * Returns 1 if true
748 */
749int
750isStandalone(void *ctx)
751{
752 DEPRECATED("isStandalone")
753 return(xmlSAX2IsStandalone(ctx));
754}
755
756/**
757 * hasInternalSubset:
758 * @ctx: the user data (XML parser context)
759 *
760 * Does this document has an internal subset
761 * DEPRECATED: use xmlSAX2HasInternalSubset()
762 *
763 * Returns 1 if true
764 */
765int
766hasInternalSubset(void *ctx)
767{
768 DEPRECATED("hasInternalSubset")
769 return(xmlSAX2HasInternalSubset(ctx));
770}
771
772/**
773 * hasExternalSubset:
774 * @ctx: the user data (XML parser context)
775 *
776 * Does this document has an external subset
777 * DEPRECATED: use xmlSAX2HasExternalSubset()
778 *
779 * Returns 1 if true
780 */
781int
782hasExternalSubset(void *ctx)
783{
784 DEPRECATED("hasExternalSubset")
785 return(xmlSAX2HasExternalSubset(ctx));
786}
787
788/**
789 * internalSubset:
790 * @ctx: the user data (XML parser context)
791 * @name: the root element name
792 * @ExternalID: the external ID
793 * @SystemID: the SYSTEM ID (e.g. filename or URL)
794 *
795 * Callback on internal subset declaration.
796 * DEPRECATED: use xmlSAX2InternalSubset()
797 */
798void
799internalSubset(void *ctx, const xmlChar *name,
800 const xmlChar *ExternalID, const xmlChar *SystemID)
801{
802 DEPRECATED("internalSubset")
803 xmlSAX2InternalSubset(ctx, name, ExternalID, SystemID);
804}
805
806/**
807 * externalSubset:
808 * @ctx: the user data (XML parser context)
809 * @name: the root element name
810 * @ExternalID: the external ID
811 * @SystemID: the SYSTEM ID (e.g. filename or URL)
812 *
813 * Callback on external subset declaration.
814 * DEPRECATED: use xmlSAX2ExternalSubset()
815 */
816void
817externalSubset(void *ctx, const xmlChar *name,
818 const xmlChar *ExternalID, const xmlChar *SystemID)
819{
820 DEPRECATED("externalSubset")
821 xmlSAX2ExternalSubset(ctx, name, ExternalID, SystemID);
822}
823
824/**
825 * resolveEntity:
826 * @ctx: the user data (XML parser context)
827 * @publicId: The public ID of the entity
828 * @systemId: The system ID of the entity
829 *
830 * The entity loader, to control the loading of external entities,
831 * the application can either:
832 * - override this resolveEntity() callback in the SAX block
833 * - or better use the xmlSetExternalEntityLoader() function to
834 * set up it's own entity resolution routine
835 * DEPRECATED: use xmlSAX2ResolveEntity()
836 *
837 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
838 */
839xmlParserInputPtr
840resolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
841{
842 DEPRECATED("resolveEntity")
843 return(xmlSAX2ResolveEntity(ctx, publicId, systemId));
844}
845
846/**
847 * getEntity:
848 * @ctx: the user data (XML parser context)
849 * @name: The entity name
850 *
851 * Get an entity by name
852 * DEPRECATED: use xmlSAX2GetEntity()
853 *
854 * Returns the xmlEntityPtr if found.
855 */
856xmlEntityPtr
857getEntity(void *ctx, const xmlChar *name)
858{
859 DEPRECATED("getEntity")
860 return(xmlSAX2GetEntity(ctx, name));
861}
862
863/**
864 * getParameterEntity:
865 * @ctx: the user data (XML parser context)
866 * @name: The entity name
867 *
868 * Get a parameter entity by name
869 * DEPRECATED: use xmlSAX2GetParameterEntity()
870 *
871 * Returns the xmlEntityPtr if found.
872 */
873xmlEntityPtr
874getParameterEntity(void *ctx, const xmlChar *name)
875{
876 DEPRECATED("getParameterEntity")
877 return(xmlSAX2GetParameterEntity(ctx, name));
878}
879
880
881/**
882 * entityDecl:
883 * @ctx: the user data (XML parser context)
884 * @name: the entity name
885 * @type: the entity type
886 * @publicId: The public ID of the entity
887 * @systemId: The system ID of the entity
888 * @content: the entity value (without processing).
889 *
890 * An entity definition has been parsed
891 * DEPRECATED: use xmlSAX2EntityDecl()
892 */
893void
894entityDecl(void *ctx, const xmlChar *name, int type,
895 const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
896{
897 DEPRECATED("entityDecl")
898 xmlSAX2EntityDecl(ctx, name, type, publicId, systemId, content);
899}
900
901/**
902 * attributeDecl:
903 * @ctx: the user data (XML parser context)
904 * @elem: the name of the element
905 * @fullname: the attribute name
906 * @type: the attribute type
907 * @def: the type of default value
908 * @defaultValue: the attribute default value
909 * @tree: the tree of enumerated value set
910 *
911 * An attribute definition has been parsed
912 * DEPRECATED: use xmlSAX2AttributeDecl()
913 */
914void
915attributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
916 int type, int def, const xmlChar *defaultValue,
917 xmlEnumerationPtr tree)
918{
919 DEPRECATED("attributeDecl")
920 xmlSAX2AttributeDecl(ctx, elem, fullname, type, def, defaultValue, tree);
921}
922
923/**
924 * elementDecl:
925 * @ctx: the user data (XML parser context)
926 * @name: the element name
927 * @type: the element type
928 * @content: the element value tree
929 *
930 * An element definition has been parsed
931 * DEPRECATED: use xmlSAX2ElementDecl()
932 */
933void
934elementDecl(void *ctx, const xmlChar * name, int type,
935 xmlElementContentPtr content)
936{
937 DEPRECATED("elementDecl")
938 xmlSAX2ElementDecl(ctx, name, type, content);
939}
940
941/**
942 * notationDecl:
943 * @ctx: the user data (XML parser context)
944 * @name: The name of the notation
945 * @publicId: The public ID of the entity
946 * @systemId: The system ID of the entity
947 *
948 * What to do when a notation declaration has been parsed.
949 * DEPRECATED: use xmlSAX2NotationDecl()
950 */
951void
952notationDecl(void *ctx, const xmlChar *name,
953 const xmlChar *publicId, const xmlChar *systemId)
954{
955 DEPRECATED("notationDecl")
956 xmlSAX2NotationDecl(ctx, name, publicId, systemId);
957}
958
959/**
960 * unparsedEntityDecl:
961 * @ctx: the user data (XML parser context)
962 * @name: The name of the entity
963 * @publicId: The public ID of the entity
964 * @systemId: The system ID of the entity
965 * @notationName: the name of the notation
966 *
967 * What to do when an unparsed entity declaration is parsed
968 * DEPRECATED: use xmlSAX2UnparsedEntityDecl()
969 */
970void
971unparsedEntityDecl(void *ctx, const xmlChar *name,
972 const xmlChar *publicId, const xmlChar *systemId,
973 const xmlChar *notationName)
974{
975 DEPRECATED("unparsedEntityDecl")
976 xmlSAX2UnparsedEntityDecl(ctx, name, publicId, systemId, notationName);
977}
978
979/**
980 * setDocumentLocator:
981 * @ctx: the user data (XML parser context)
982 * @loc: A SAX Locator
983 *
984 * Receive the document locator at startup, actually xmlDefaultSAXLocator
985 * Everything is available on the context, so this is useless in our case.
986 * DEPRECATED
987 */
988void
989setDocumentLocator(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
990{
991 DEPRECATED("setDocumentLocator")
992}
993
994/**
995 * startDocument:
996 * @ctx: the user data (XML parser context)
997 *
998 * called when the document start being processed.
999 * DEPRECATED: use xmlSAX2StartDocument()
1000 */
1001void
1002startDocument(void *ctx)
1003{
1004 DEPRECATED("startDocument")
1005 xmlSAX2StartDocument(ctx);
1006}
1007
1008/**
1009 * endDocument:
1010 * @ctx: the user data (XML parser context)
1011 *
1012 * called when the document end has been detected.
1013 * DEPRECATED: use xmlSAX2EndDocument()
1014 */
1015void
1016endDocument(void *ctx)
1017{
1018 DEPRECATED("endDocument")
1019 xmlSAX2EndDocument(ctx);
1020}
1021
1022/**
1023 * attribute:
1024 * @ctx: the user data (XML parser context)
1025 * @fullname: The attribute name, including namespace prefix
1026 * @value: The attribute value
1027 *
1028 * Handle an attribute that has been read by the parser.
1029 * The default handling is to convert the attribute into an
1030 * DOM subtree and past it in a new xmlAttr element added to
1031 * the element.
1032 * DEPRECATED: use xmlSAX2Attribute()
1033 */
1034void
1035attribute(void *ctx ATTRIBUTE_UNUSED, const xmlChar *fullname ATTRIBUTE_UNUSED, const xmlChar *value ATTRIBUTE_UNUSED)
1036{
1037 DEPRECATED("attribute")
1038}
1039
1040/**
1041 * startElement:
1042 * @ctx: the user data (XML parser context)
1043 * @fullname: The element name, including namespace prefix
1044 * @atts: An array of name/value attributes pairs, NULL terminated
1045 *
1046 * called when an opening tag has been processed.
1047 * DEPRECATED: use xmlSAX2StartElement()
1048 */
1049void
1050startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
1051{
1052 DEPRECATED("startElement")
1053 xmlSAX2StartElement(ctx, fullname, atts);
1054}
1055
1056/**
1057 * endElement:
1058 * @ctx: the user data (XML parser context)
1059 * @name: The element name
1060 *
1061 * called when the end of an element has been detected.
1062 * DEPRECATED: use xmlSAX2EndElement()
1063 */
1064void
1065endElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
1066{
1067 DEPRECATED("endElement")
1068 xmlSAX2EndElement(ctx, name);
1069}
1070
1071/**
1072 * reference:
1073 * @ctx: the user data (XML parser context)
1074 * @name: The entity name
1075 *
1076 * called when an entity reference is detected.
1077 * DEPRECATED: use xmlSAX2Reference()
1078 */
1079void
1080reference(void *ctx, const xmlChar *name)
1081{
1082 DEPRECATED("reference")
1083 xmlSAX2Reference(ctx, name);
1084}
1085
1086/**
1087 * characters:
1088 * @ctx: the user data (XML parser context)
1089 * @ch: a xmlChar string
1090 * @len: the number of xmlChar
1091 *
1092 * receiving some chars from the parser.
1093 * DEPRECATED: use xmlSAX2Characters()
1094 */
1095void
1096characters(void *ctx, const xmlChar *ch, int len)
1097{
1098 DEPRECATED("characters")
1099 xmlSAX2Characters(ctx, ch, len);
1100}
1101
1102/**
1103 * ignorableWhitespace:
1104 * @ctx: the user data (XML parser context)
1105 * @ch: a xmlChar string
1106 * @len: the number of xmlChar
1107 *
1108 * receiving some ignorable whitespaces from the parser.
1109 * UNUSED: by default the DOM building will use characters
1110 * DEPRECATED: use xmlSAX2IgnorableWhitespace()
1111 */
1112void
1113ignorableWhitespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED)
1114{
1115 DEPRECATED("ignorableWhitespace")
1116}
1117
1118/**
1119 * processingInstruction:
1120 * @ctx: the user data (XML parser context)
1121 * @target: the target name
1122 * @data: the PI data's
1123 *
1124 * A processing instruction has been parsed.
1125 * DEPRECATED: use xmlSAX2ProcessingInstruction()
1126 */
1127void
1128processingInstruction(void *ctx, const xmlChar *target,
1129 const xmlChar *data)
1130{
1131 DEPRECATED("processingInstruction")
1132 xmlSAX2ProcessingInstruction(ctx, target, data);
1133}
1134
1135/**
1136 * globalNamespace:
1137 * @ctx: the user data (XML parser context)
1138 * @href: the namespace associated URN
1139 * @prefix: the namespace prefix
1140 *
1141 * An old global namespace has been parsed.
1142 * DEPRECATED
1143 */
1144void
1145globalNamespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *href ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED)
1146{
1147 DEPRECATED("globalNamespace")
1148}
1149
1150/**
1151 * setNamespace:
1152 * @ctx: the user data (XML parser context)
1153 * @name: the namespace prefix
1154 *
1155 * Set the current element namespace.
1156 * DEPRECATED
1157 */
1158
1159void
1160setNamespace(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name ATTRIBUTE_UNUSED)
1161{
1162 DEPRECATED("setNamespace")
1163}
1164
1165/**
1166 * getNamespace:
1167 * @ctx: the user data (XML parser context)
1168 *
1169 * Get the current element namespace.
1170 * DEPRECATED
1171 *
1172 * Returns the xmlNsPtr or NULL if none
1173 */
1174
1175xmlNsPtr
1176getNamespace(void *ctx ATTRIBUTE_UNUSED)
1177{
1178 DEPRECATED("getNamespace")
1179 return(NULL);
1180}
1181
1182/**
1183 * checkNamespace:
1184 * @ctx: the user data (XML parser context)
1185 * @namespace: the namespace to check against
1186 *
1187 * Check that the current element namespace is the same as the
1188 * one read upon parsing.
1189 * DEPRECATED
1190 *
1191 * Returns 1 if true 0 otherwise
1192 */
1193
1194int
1195checkNamespace(void *ctx ATTRIBUTE_UNUSED, xmlChar *namespace ATTRIBUTE_UNUSED)
1196{
1197 DEPRECATED("checkNamespace")
1198 return(0);
1199}
1200
1201/**
1202 * namespaceDecl:
1203 * @ctx: the user data (XML parser context)
1204 * @href: the namespace associated URN
1205 * @prefix: the namespace prefix
1206 *
1207 * A namespace has been parsed.
1208 * DEPRECATED
1209 */
1210void
1211namespaceDecl(void *ctx ATTRIBUTE_UNUSED, const xmlChar *href ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED)
1212{
1213 DEPRECATED("namespaceDecl")
1214}
1215
1216/**
1217 * comment:
1218 * @ctx: the user data (XML parser context)
1219 * @value: the comment content
1220 *
1221 * A comment has been parsed.
1222 * DEPRECATED: use xmlSAX2Comment()
1223 */
1224void
1225comment(void *ctx, const xmlChar *value)
1226{
1227 DEPRECATED("comment")
1228 xmlSAX2Comment(ctx, value);
1229}
1230
1231/**
1232 * cdataBlock:
1233 * @ctx: the user data (XML parser context)
1234 * @value: The pcdata content
1235 * @len: the block length
1236 *
1237 * called when a pcdata block has been parsed
1238 * DEPRECATED: use xmlSAX2CDataBlock()
1239 */
1240void
1241cdataBlock(void *ctx, const xmlChar *value, int len)
1242{
1243 DEPRECATED("cdataBlock")
1244 xmlSAX2CDataBlock(ctx, value, len);
1245}
1246
1247#endif /* LIBXML_LEGACY_ENABLED */
1248