* xmlSAX2EntityDecl: * @ctx: the user data (XML parser context) * @name: the entity name * @type: the entity type * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @content: the entity value (without processing). * * An entity definition has been parsed */
| 524 | * An entity definition has been parsed |
| 525 | */ |
| 526 | void |
| 527 | xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, |
| 528 | const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) |
| 529 | { |
| 530 | xmlEntityPtr ent; |
| 531 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 532 | int extSubset; |
| 533 | int res; |
| 534 | |
| 535 | if ((ctxt == NULL) || (ctxt->myDoc == NULL)) |
| 536 | return; |
| 537 | |
| 538 | extSubset = ctxt->inSubset == 2; |
| 539 | res = xmlAddEntity(ctxt->myDoc, extSubset, name, type, publicId, systemId, |
| 540 | content, &ent); |
| 541 | switch (res) { |
| 542 | case XML_ERR_OK: |
| 543 | break; |
| 544 | case XML_ERR_NO_MEMORY: |
| 545 | xmlSAX2ErrMemory(ctxt); |
| 546 | return; |
| 547 | case XML_WAR_ENTITY_REDEFINED: |
| 548 | if (ctxt->pedantic) { |
| 549 | if (extSubset) |
| 550 | xmlWarnMsg(ctxt, res, "Entity(%s) already defined in the" |
| 551 | " external subset\n", name); |
| 552 | else |
| 553 | xmlWarnMsg(ctxt, res, "Entity(%s) already defined in the" |
| 554 | " internal subset\n", name); |
| 555 | } |
| 556 | return; |
| 557 | case XML_ERR_REDECL_PREDEF_ENTITY: |
| 558 | /* |
| 559 | * Technically an error but it's a common mistake to get double |
| 560 | * escaping according to "4.6 Predefined Entities" wrong. |
| 561 | */ |
| 562 | xmlWarnMsg(ctxt, res, "Invalid redeclaration of predefined" |
| 563 | " entity '%s'", name); |
| 564 | return; |
| 565 | default: |
| 566 | xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, |
| 567 | "Unexpected error code from xmlAddEntity\n", |
| 568 | NULL, NULL); |
| 569 | return; |
| 570 | } |
| 571 | |
| 572 | if ((ent->URI == NULL) && (systemId != NULL)) { |
| 573 | xmlChar *URI; |
| 574 | const char *base = NULL; |
| 575 | int i; |
| 576 | |
| 577 | for (i = ctxt->inputNr - 1; i >= 0; i--) { |
| 578 | if (ctxt->inputTab[i]->filename != NULL) { |
| 579 | base = ctxt->inputTab[i]->filename; |
| 580 | break; |
| 581 | } |
| 582 | } |
| 583 |
no test coverage detected