ReactOS 0.4.16-dev-2208-g6350669
SAX2.h File Reference
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
Include dependency graph for SAX2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

XMLPUBFUN const xmlCharxmlSAX2GetPublicId (void *ctx)
 
XMLPUBFUN const xmlCharxmlSAX2GetSystemId (void *ctx)
 
XMLPUBFUN void xmlSAX2SetDocumentLocator (void *ctx, xmlSAXLocatorPtr loc)
 
XMLPUBFUN int xmlSAX2GetLineNumber (void *ctx)
 
XMLPUBFUN int xmlSAX2GetColumnNumber (void *ctx)
 
XMLPUBFUN int xmlSAX2IsStandalone (void *ctx)
 
XMLPUBFUN int xmlSAX2HasInternalSubset (void *ctx)
 
XMLPUBFUN int xmlSAX2HasExternalSubset (void *ctx)
 
XMLPUBFUN void xmlSAX2InternalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
XMLPUBFUN void xmlSAX2ExternalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
XMLPUBFUN xmlEntityPtr xmlSAX2GetEntity (void *ctx, const xmlChar *name)
 
XMLPUBFUN xmlEntityPtr xmlSAX2GetParameterEntity (void *ctx, const xmlChar *name)
 
XMLPUBFUN xmlParserInputPtr xmlSAX2ResolveEntity (void *ctx, const xmlChar *publicId, const xmlChar *systemId)
 
XMLPUBFUN void xmlSAX2EntityDecl (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
 
XMLPUBFUN void xmlSAX2AttributeDecl (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
 
XMLPUBFUN void xmlSAX2ElementDecl (void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)
 
XMLPUBFUN void xmlSAX2NotationDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 
XMLPUBFUN void xmlSAX2UnparsedEntityDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
 
XMLPUBFUN void xmlSAX2StartDocument (void *ctx)
 
XMLPUBFUN void xmlSAX2EndDocument (void *ctx)
 
XMLPUBFUN void xmlSAX2StartElementNs (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)
 
XMLPUBFUN void xmlSAX2EndElementNs (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
 
XMLPUBFUN void xmlSAX2Reference (void *ctx, const xmlChar *name)
 
XMLPUBFUN void xmlSAX2Characters (void *ctx, const xmlChar *ch, int len)
 
XMLPUBFUN void xmlSAX2IgnorableWhitespace (void *ctx, const xmlChar *ch, int len)
 
XMLPUBFUN void xmlSAX2ProcessingInstruction (void *ctx, const xmlChar *target, const xmlChar *data)
 
XMLPUBFUN void xmlSAX2Comment (void *ctx, const xmlChar *value)
 
XMLPUBFUN void xmlSAX2CDataBlock (void *ctx, const xmlChar *value, int len)
 
XMLPUBFUN int xmlSAXVersion (xmlSAXHandler *hdlr, int version)
 
XMLPUBFUN void xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, int warning)
 
XML_DEPRECATED XMLPUBFUN void xmlDefaultSAXHandlerInit (void)
 

Function Documentation

◆ xmlDefaultSAXHandlerInit()

XML_DEPRECATED XMLPUBFUN void xmlDefaultSAXHandlerInit ( void  )

xmlDefaultSAXHandlerInit:

DEPRECATED: This function is a no-op. Call xmlInitParser to initialize the library.

Initialize the default SAX2 handler

Definition at line 2783 of file SAX2.c.

2784{
2785}

◆ xmlSAX2AttributeDecl()

XMLPUBFUN void xmlSAX2AttributeDecl ( void ctx,
const xmlChar elem,
const xmlChar fullname,
int  type,
int  def,
const xmlChar defaultValue,
xmlEnumerationPtr  tree 
)

Definition at line 653 of file SAX2.c.

656{
657 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
658 xmlAttributePtr attr;
659 xmlChar *name = NULL, *prefix = NULL;
660
661 /* Avoid unused variable warning if features are disabled. */
662 (void) attr;
663
664 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
665 return;
666
667 if ((xmlStrEqual(fullname, BAD_CAST "xml:id")) &&
668 (type != XML_ATTRIBUTE_ID)) {
669 /*
670 * Raise the error but keep the validity flag
671 */
672 int tmp = ctxt->valid;
673 xmlErrValid(ctxt, XML_DTD_XMLID_TYPE,
674 "xml:id : attribute type should be ID\n", NULL, NULL);
675 ctxt->valid = tmp;
676 }
677 /* TODO: optimize name/prefix allocation */
679 ctxt->vctxt.valid = 1;
680 if (ctxt->inSubset == 1)
681 attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem,
682 name, prefix, (xmlAttributeType) type,
683 (xmlAttributeDefault) def, defaultValue, tree);
684 else if (ctxt->inSubset == 2)
685 attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, elem,
686 name, prefix, (xmlAttributeType) type,
687 (xmlAttributeDefault) def, defaultValue, tree);
688 else {
689 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
690 "SAX.xmlSAX2AttributeDecl(%s) called while not in subset\n",
691 name, NULL);
692 xmlFree(name);
694 return;
695 }
696#ifdef LIBXML_VALID_ENABLED
697 if (ctxt->vctxt.valid == 0)
698 ctxt->valid = 0;
699 if ((attr != NULL) && (ctxt->validate) && (ctxt->wellFormed) &&
700 (ctxt->myDoc->intSubset != NULL))
701 ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc,
702 attr);
703#endif /* LIBXML_VALID_ENABLED */
704 if (prefix != NULL)
706 if (name != NULL)
707 xmlFree(name);
708}
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
const char * fullname
Definition: shader.c:1766
static size_t elem
Definition: string.c:71
XMLPUBFUN xmlChar * xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix)
Definition: parser.c:3157
xmlFreeFunc xmlFree
Definition: globals.c:184
Definition: cookie.c:202
Definition: name.c:39
Character const *const prefix
Definition: tempnam.cpp:195
XMLPUBFUN void xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1662
XMLPUBFUN xmlAttributePtr xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, const xmlChar *ns, xmlAttributeType type, xmlAttributeDefault def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
Definition: valid.c:1812
@ XML_DTD_XMLID_TYPE
Definition: xmlerror.h:260
@ XML_ERR_INTERNAL_ERROR
Definition: xmlerror.h:101
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2CDataBlock()

XMLPUBFUN void xmlSAX2CDataBlock ( void ctx,
const xmlChar value,
int  len 
)

xmlSAX2CDataBlock: @ctx: the user data (XML parser context) @value: The pcdata content @len: the block length

called when a pcdata block has been parsed

Definition at line 2660 of file SAX2.c.

2661{
2662 xmlSAX2Text((xmlParserCtxtPtr) ctx, value, len, XML_CDATA_SECTION_NODE);
2663}
static void xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len, xmlElementType type)
Definition: SAX2.c:2401
GLenum GLsizei len
Definition: glext.h:6722
Definition: pdh_main.c:96

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2Characters()

XMLPUBFUN void xmlSAX2Characters ( void ctx,
const xmlChar ch,
int  len 
)

xmlSAX2Characters: @ctx: the user data (XML parser context) @ch: a xmlChar string @len: the number of xmlChar

receiving some chars from the parser.

Definition at line 2539 of file SAX2.c.

2540{
2541 xmlSAX2Text((xmlParserCtxtPtr) ctx, ch, len, XML_TEXT_NODE);
2542}
unsigned char ch[4][2]
Definition: console.c:118

Referenced by sax_characters(), and xmlSAXVersion().

◆ xmlSAX2Comment()

XMLPUBFUN void xmlSAX2Comment ( void ctx,
const xmlChar value 
)

xmlSAX2Comment: @ctx: the user data (XML parser context) @value: the xmlSAX2Comment content

A xmlSAX2Comment has been parsed.

Definition at line 2614 of file SAX2.c.

2615{
2616 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2617 xmlNodePtr ret;
2618 xmlNodePtr parent;
2619
2620 if (ctx == NULL) return;
2621 parent = ctxt->node;
2622 ret = xmlNewDocComment(ctxt->myDoc, value);
2623 if (ret == NULL) return;
2624 if (ctxt->linenumbers) {
2625 if (ctxt->input != NULL) {
2626 if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
2627 ret->line = ctxt->input->line;
2628 else
2629 ret->line = USHRT_MAX;
2630 }
2631 }
2632
2633 if (ctxt->inSubset == 1) {
2634 xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret);
2635 return;
2636 } else if (ctxt->inSubset == 2) {
2637 xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
2638 return;
2639 }
2640 if (parent == NULL) {
2641 xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
2642 return;
2643 }
2644 if (parent->type == XML_ELEMENT_NODE) {
2645 xmlAddChild(parent, ret);
2646 } else {
2647 xmlAddSibling(parent, ret);
2648 }
2649}
#define USHRT_MAX
Definition: limits.h:23
return ret
Definition: mutex.c:146
r parent
Definition: btrfs.c:3010

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2ElementDecl()

XMLPUBFUN void xmlSAX2ElementDecl ( void ctx,
const xmlChar name,
int  type,
xmlElementContentPtr  content 
)

Definition at line 720 of file SAX2.c.

722{
723 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
724 xmlElementPtr elem = NULL;
725
726 /* Avoid unused variable warning if features are disabled. */
727 (void) elem;
728
729 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
730 return;
731
732 if (ctxt->inSubset == 1)
733 elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset,
734 name, (xmlElementTypeVal) type, content);
735 else if (ctxt->inSubset == 2)
736 elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->extSubset,
737 name, (xmlElementTypeVal) type, content);
738 else {
739 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
740 "SAX.xmlSAX2ElementDecl(%s) called while not in subset\n",
741 name, NULL);
742 return;
743 }
744#ifdef LIBXML_VALID_ENABLED
745 if (elem == NULL)
746 ctxt->valid = 0;
747 if (ctxt->validate && ctxt->wellFormed &&
748 ctxt->myDoc && ctxt->myDoc->intSubset)
749 ctxt->valid &=
750 xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem);
751#endif /* LIBXML_VALID_ENABLED */
752}
content
Definition: atl_ax.c:994
XMLPUBFUN xmlElementPtr xmlAddElementDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlElementTypeVal type, xmlElementContentPtr content)
Definition: valid.c:1263

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2EndDocument()

XMLPUBFUN void xmlSAX2EndDocument ( void ctx)

xmlSAX2EndDocument: @ctx: the user data (XML parser context)

called when the document end has been detected.

Definition at line 944 of file SAX2.c.

945{
946 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
947 xmlDocPtr doc;
948
949 if (ctx == NULL) return;
950#ifdef LIBXML_VALID_ENABLED
951 if (ctxt->validate && ctxt->wellFormed &&
952 ctxt->myDoc && ctxt->myDoc->intSubset)
953 ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc);
954#endif /* LIBXML_VALID_ENABLED */
955
956 doc = ctxt->myDoc;
957 if ((doc != NULL) && (doc->encoding == NULL)) {
958 const xmlChar *encoding = xmlGetActualEncoding(ctxt);
959
960 if (encoding != NULL) {
961 doc->encoding = xmlStrdup(encoding);
962 if (doc->encoding == NULL)
963 xmlSAX2ErrMemory(ctxt, "xmlSAX2EndDocument");
964 }
965 }
966}
XML_HIDDEN const xmlChar * xmlGetActualEncoding(xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2EndElementNs()

XMLPUBFUN void xmlSAX2EndElementNs ( void ctx,
const xmlChar localname,
const xmlChar prefix,
const xmlChar URI 
)

Referenced by doparse().

◆ xmlSAX2EntityDecl()

XMLPUBFUN void xmlSAX2EntityDecl ( void ctx,
const xmlChar name,
int  type,
const xmlChar publicId,
const xmlChar systemId,
xmlChar content 
)

Definition at line 588 of file SAX2.c.

590{
591 xmlEntityPtr ent;
592 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
593
594 if (ctx == NULL) return;
595 if (ctxt->inSubset == 1) {
596 ent = xmlAddDocEntity(ctxt->myDoc, name, type, publicId,
597 systemId, content);
598 if ((ent == NULL) && (ctxt->pedantic))
599 xmlWarnMsg(ctxt, XML_WAR_ENTITY_REDEFINED,
600 "Entity(%s) already defined in the internal subset\n",
601 name);
602 if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
603 xmlChar *URI;
604 const char *base = NULL;
605
606 if (ctxt->input != NULL)
607 base = ctxt->input->filename;
608 if (base == NULL)
609 base = ctxt->directory;
610
611 URI = xmlBuildURI(systemId, (const xmlChar *) base);
612 ent->URI = URI;
613 }
614 } else if (ctxt->inSubset == 2) {
615 ent = xmlAddDtdEntity(ctxt->myDoc, name, type, publicId,
616 systemId, content);
617 if ((ent == NULL) && (ctxt->pedantic) &&
618 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
619 ctxt->sax->warning(ctxt->userData,
620 "Entity(%s) already defined in the external subset\n", name);
621 if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
622 xmlChar *URI;
623 const char *base = NULL;
624
625 if (ctxt->input != NULL)
626 base = ctxt->input->filename;
627 if (base == NULL)
628 base = ctxt->directory;
629
630 URI = xmlBuildURI(systemId, (const xmlChar *) base);
631 ent->URI = URI;
632 }
633 } else {
634 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
635 "SAX.xmlSAX2EntityDecl(%s) called while not in subset\n",
636 name, NULL);
637 }
638}
XMLPUBFUN xmlEntityPtr xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content)
XMLPUBFUN xmlEntityPtr xmlAddDtdEntity(xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content)
XMLPUBFUN xmlChar * xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1902
@ XML_WAR_ENTITY_REDEFINED
Definition: xmlerror.h:207
@ XML_ERR_ENTITY_PROCESSING
Definition: xmlerror.h:204

Referenced by doparse(), xmlParseEntityDecl(), and xmlSAXVersion().

◆ xmlSAX2ExternalSubset()

XMLPUBFUN void xmlSAX2ExternalSubset ( void ctx,
const xmlChar name,
const xmlChar ExternalID,
const xmlChar SystemID 
)

Definition at line 357 of file SAX2.c.

359{
360 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
361 if (ctx == NULL) return;
362 if (((ExternalID != NULL) || (SystemID != NULL)) &&
363 (((ctxt->validate) || (ctxt->loadsubset != 0)) &&
364 (ctxt->wellFormed && ctxt->myDoc))) {
365 /*
366 * Try to fetch and parse the external subset.
367 */
368 xmlParserInputPtr oldinput;
369 int oldinputNr;
370 int oldinputMax;
371 xmlParserInputPtr *oldinputTab;
372 xmlParserInputPtr input = NULL;
373 const xmlChar *oldencoding;
374 int oldprogressive;
375 unsigned long consumed;
376 size_t buffered;
377
378 /*
379 * Ask the Entity resolver to load the damn thing
380 */
381 if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL))
382 input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID,
383 SystemID);
384 if (input == NULL) {
385 return;
386 }
387
388 xmlNewDtd(ctxt->myDoc, name, ExternalID, SystemID);
389
390 /*
391 * make sure we won't destroy the main document context
392 */
393 oldinput = ctxt->input;
394 oldinputNr = ctxt->inputNr;
395 oldinputMax = ctxt->inputMax;
396 oldinputTab = ctxt->inputTab;
397 oldencoding = ctxt->encoding;
398 oldprogressive = ctxt->progressive;
399 ctxt->encoding = NULL;
400 ctxt->progressive = 0;
401
402 ctxt->inputTab = (xmlParserInputPtr *)
403 xmlMalloc(5 * sizeof(xmlParserInputPtr));
404 if (ctxt->inputTab == NULL) {
405 xmlSAX2ErrMemory(ctxt, "xmlSAX2ExternalSubset");
407 ctxt->input = oldinput;
408 ctxt->inputNr = oldinputNr;
409 ctxt->inputMax = oldinputMax;
410 ctxt->inputTab = oldinputTab;
411 ctxt->encoding = oldencoding;
412 ctxt->progressive = oldprogressive;
413 return;
414 }
415 ctxt->inputNr = 0;
416 ctxt->inputMax = 5;
417 ctxt->input = NULL;
418 xmlPushInput(ctxt, input);
419
420 if (input->filename == NULL)
421 input->filename = (char *) xmlCanonicPath(SystemID);
422 input->line = 1;
423 input->col = 1;
424 input->base = ctxt->input->cur;
425 input->cur = ctxt->input->cur;
426 input->free = NULL;
427
428 /*
429 * let's parse that entity knowing it's an external subset.
430 */
431 xmlParseExternalSubset(ctxt, ExternalID, SystemID);
432
433 /*
434 * Free up the external entities
435 */
436
437 while (ctxt->inputNr > 1)
438 xmlPopInput(ctxt);
439
440 consumed = ctxt->input->consumed;
441 buffered = ctxt->input->cur - ctxt->input->base;
442 if (buffered > ULONG_MAX - consumed)
444 else
445 consumed += buffered;
446 if (consumed > ULONG_MAX - ctxt->sizeentities)
447 ctxt->sizeentities = ULONG_MAX;
448 else
449 ctxt->sizeentities += consumed;
450
451 xmlFreeInputStream(ctxt->input);
452 xmlFree(ctxt->inputTab);
453
454 /*
455 * Restore the parsing context of the main entity
456 */
457 ctxt->input = oldinput;
458 ctxt->inputNr = oldinputNr;
459 ctxt->inputMax = oldinputMax;
460 ctxt->inputTab = oldinputTab;
461 if ((ctxt->encoding != NULL) &&
462 ((ctxt->dict == NULL) ||
463 (!xmlDictOwns(ctxt->dict, ctxt->encoding))))
464 xmlFree((xmlChar *) ctxt->encoding);
465 ctxt->encoding = oldencoding;
466 ctxt->progressive = oldprogressive;
467 /* ctxt->wellFormed = oldwellFormed; */
468 }
469}
#define ULONG_MAX
Definition: limits.h:31
int consumed
Definition: scanf.h:200
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN xmlChar xmlPopInput(xmlParserCtxtPtr ctxt)
Definition: parser.c:2419
XMLPUBFUN void xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID)
Definition: parser.c:7160
XMLPUBFUN int xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
Definition: parser.c:2449
XMLPUBFUN void xmlFreeInputStream(xmlParserInputPtr input)
int xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:376
xmlMallocFunc xmlMalloc
Definition: globals.c:193
XMLPUBFUN xmlChar * xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2394

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2GetColumnNumber()

XMLPUBFUN int xmlSAX2GetColumnNumber ( void ctx)

xmlSAX2GetColumnNumber: @ctx: the user data (XML parser context)

Provide the column number of the current parsing point.

Returns an int

Definition at line 259 of file SAX2.c.

260{
261 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
262 if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
263 return(ctxt->input->col);
264}

Referenced by update_position().

◆ xmlSAX2GetEntity()

XMLPUBFUN xmlEntityPtr xmlSAX2GetEntity ( void ctx,
const xmlChar name 
)

Definition at line 518 of file SAX2.c.

519{
520 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
521 xmlEntityPtr ret = NULL;
522
523 if (ctx == NULL) return(NULL);
524
525 if (ctxt->inSubset == 0) {
527 if (ret != NULL)
528 return(ret);
529 }
530 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->standalone == 1)) {
531 if (ctxt->inSubset == 2) {
532 ctxt->myDoc->standalone = 0;
533 ret = xmlGetDocEntity(ctxt->myDoc, name);
534 ctxt->myDoc->standalone = 1;
535 } else {
536 ret = xmlGetDocEntity(ctxt->myDoc, name);
537 if (ret == NULL) {
538 ctxt->myDoc->standalone = 0;
539 ret = xmlGetDocEntity(ctxt->myDoc, name);
540 if (ret != NULL) {
541 xmlFatalErrMsg(ctxt, XML_ERR_NOT_STANDALONE,
542 "Entity(%s) document marked standalone but requires external subset\n",
543 name, NULL);
544 }
545 ctxt->myDoc->standalone = 1;
546 }
547 }
548 } else {
549 ret = xmlGetDocEntity(ctxt->myDoc, name);
550 }
551 return(ret);
552}
XMLPUBFUN xmlEntityPtr xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name)
XMLPUBFUN xmlEntityPtr xmlGetPredefinedEntity(const xmlChar *name)
@ XML_ERR_NOT_STANDALONE
Definition: xmlerror.h:203

Referenced by doparse(), xmlParseEntityDecl(), xmlParseEntityRef(), xmlParseStringEntityRef(), and xmlSAXVersion().

◆ xmlSAX2GetLineNumber()

XMLPUBFUN int xmlSAX2GetLineNumber ( void ctx)

xmlSAX2GetLineNumber: @ctx: the user data (XML parser context)

Provide the line number of the current parsing point.

Returns an int

Definition at line 243 of file SAX2.c.

244{
245 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
246 if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
247 return(ctxt->input->line);
248}

Referenced by update_position().

◆ xmlSAX2GetParameterEntity()

XMLPUBFUN xmlEntityPtr xmlSAX2GetParameterEntity ( void ctx,
const xmlChar name 
)

Definition at line 564 of file SAX2.c.

565{
566 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
567 xmlEntityPtr ret;
568
569 if (ctx == NULL) return(NULL);
570
571 ret = xmlGetParameterEntity(ctxt->myDoc, name);
572 return(ret);
573}
XMLPUBFUN xmlEntityPtr xmlGetParameterEntity(xmlDocPtr doc, const xmlChar *name)

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2GetPublicId()

XMLPUBFUN const xmlChar * xmlSAX2GetPublicId ( void ctx)

Referenced by isaxlocator_getPublicId().

◆ xmlSAX2GetSystemId()

XMLPUBFUN const xmlChar * xmlSAX2GetSystemId ( void ctx)

xmlSAX2GetSystemId: @ctx: the user data (XML parser context)

Provides the system ID, basically URL or filename e.g. http://www.sgmlsource.com/dtds/memo.dtd

Returns a xmlChar *

Definition at line 227 of file SAX2.c.

228{
229 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
230 if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);
231 return((const xmlChar *) ctxt->input->filename);
232}

Referenced by isaxlocator_getSystemId().

◆ xmlSAX2HasExternalSubset()

XMLPUBFUN int xmlSAX2HasExternalSubset ( void ctx)

xmlSAX2HasExternalSubset: @ctx: the user data (XML parser context)

Does this document has an external subset

Returns 1 if true

Definition at line 307 of file SAX2.c.

308{
309 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
310 if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0);
311 return(ctxt->myDoc->extSubset != NULL);
312}

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2HasInternalSubset()

XMLPUBFUN int xmlSAX2HasInternalSubset ( void ctx)

xmlSAX2HasInternalSubset: @ctx: the user data (XML parser context)

Does this document has an internal subset

Returns 1 if true

Definition at line 291 of file SAX2.c.

292{
293 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
294 if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0);
295 return(ctxt->myDoc->intSubset != NULL);
296}

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2IgnorableWhitespace()

XMLPUBFUN void xmlSAX2IgnorableWhitespace ( void ctx,
const xmlChar ch,
int  len 
)

◆ xmlSAX2InitDefaultSAXHandler()

XMLPUBFUN void xmlSAX2InitDefaultSAXHandler ( xmlSAXHandler *  hdlr,
int  warning 
)

xmlSAX2InitDefaultSAXHandler: @hdlr: the SAX handler

Warning
: flag if non-zero sets the handler warning procedure

Initialize the default XML SAX2 handler

Definition at line 2762 of file SAX2.c.

2763{
2764 if ((hdlr == NULL) || (hdlr->initialized != 0))
2765 return;
2766
2768 if (warning == 0)
2769 hdlr->warning = NULL;
2770 else
2771 hdlr->warning = xmlParserWarning;
2772}
int xmlSAXVersion(xmlSAXHandler *hdlr, int version)
Definition: SAX2.c:2704
static int xmlSAX2DefaultVersionValue
Definition: SAX2.c:2665
#define warning(s)
Definition: debug.h:83
XMLPUBFUN void XMLPUBFUN void xmlParserWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2

◆ xmlSAX2InternalSubset()

XMLPUBFUN void xmlSAX2InternalSubset ( void ctx,
const xmlChar name,
const xmlChar ExternalID,
const xmlChar SystemID 
)

Definition at line 324 of file SAX2.c.

326{
327 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
328 xmlDtdPtr dtd;
329 if (ctx == NULL) return;
330
331 if (ctxt->myDoc == NULL)
332 return;
333 dtd = xmlGetIntSubset(ctxt->myDoc);
334 if (dtd != NULL) {
335 if (ctxt->html)
336 return;
337 xmlUnlinkNode((xmlNodePtr) dtd);
338 xmlFreeDtd(dtd);
339 ctxt->myDoc->intSubset = NULL;
340 }
341 ctxt->myDoc->intSubset =
342 xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
343 if (ctxt->myDoc->intSubset == NULL)
344 xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset");
345}

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2IsStandalone()

XMLPUBFUN int xmlSAX2IsStandalone ( void ctx)

xmlSAX2IsStandalone: @ctx: the user data (XML parser context)

Is this document tagged standalone ?

Returns 1 if true

Definition at line 275 of file SAX2.c.

276{
277 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
278 if ((ctx == NULL) || (ctxt->myDoc == NULL)) return(0);
279 return(ctxt->myDoc->standalone == 1);
280}

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2NotationDecl()

XMLPUBFUN void xmlSAX2NotationDecl ( void ctx,
const xmlChar name,
const xmlChar publicId,
const xmlChar systemId 
)

Definition at line 764 of file SAX2.c.

766{
767 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
768 xmlNotationPtr nota = NULL;
769
770 /* Avoid unused variable warning if features are disabled. */
771 (void) nota;
772
773 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
774 return;
775
776 if ((publicId == NULL) && (systemId == NULL)) {
777 xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
778 "SAX.xmlSAX2NotationDecl(%s) externalID or PublicID missing\n",
779 name, NULL);
780 return;
781 } else if (ctxt->inSubset == 1)
782 nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name,
783 publicId, systemId);
784 else if (ctxt->inSubset == 2)
785 nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, name,
786 publicId, systemId);
787 else {
788 xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
789 "SAX.xmlSAX2NotationDecl(%s) called while not in subset\n",
790 name, NULL);
791 return;
792 }
793#ifdef LIBXML_VALID_ENABLED
794 if (nota == NULL) ctxt->valid = 0;
795 if ((ctxt->validate) && (ctxt->wellFormed) &&
796 (ctxt->myDoc->intSubset != NULL))
797 ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc,
798 nota);
799#endif /* LIBXML_VALID_ENABLED */
800}
XMLPUBFUN xmlNotationPtr xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, const xmlChar *PublicID, const xmlChar *SystemID)
Definition: valid.c:2239
@ XML_ERR_NOTATION_PROCESSING
Definition: xmlerror.h:205

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2ProcessingInstruction()

XMLPUBFUN void xmlSAX2ProcessingInstruction ( void ctx,
const xmlChar target,
const xmlChar data 
)

xmlSAX2ProcessingInstruction: @ctx: the user data (XML parser context) @target: the target name @data: the PI data's

A processing instruction has been parsed.

Definition at line 2567 of file SAX2.c.

2569{
2570 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2571 xmlNodePtr ret;
2572 xmlNodePtr parent;
2573
2574 if (ctx == NULL) return;
2575 parent = ctxt->node;
2576
2577 ret = xmlNewDocPI(ctxt->myDoc, target, data);
2578 if (ret == NULL) return;
2579
2580 if (ctxt->linenumbers) {
2581 if (ctxt->input != NULL) {
2582 if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
2583 ret->line = ctxt->input->line;
2584 else
2585 ret->line = USHRT_MAX;
2586 }
2587 }
2588 if (ctxt->inSubset == 1) {
2589 xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret);
2590 return;
2591 } else if (ctxt->inSubset == 2) {
2592 xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
2593 return;
2594 }
2595 if (parent == NULL) {
2596 xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
2597 return;
2598 }
2599 if (parent->type == XML_ELEMENT_NODE) {
2600 xmlAddChild(parent, ret);
2601 } else {
2602 xmlAddSibling(parent, ret);
2603 }
2604}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: tools.h:99

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2Reference()

XMLPUBFUN void xmlSAX2Reference ( void ctx,
const xmlChar name 
)

Definition at line 2379 of file SAX2.c.

2380{
2381 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2382 xmlNodePtr ret;
2383
2384 if (ctx == NULL) return;
2385 ret = xmlNewReference(ctxt->myDoc, name);
2386 if (xmlAddChild(ctxt->node, ret) == NULL) {
2387 xmlFreeNode(ret);
2388 }
2389}

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2ResolveEntity()

XMLPUBFUN xmlParserInputPtr xmlSAX2ResolveEntity ( void ctx,
const xmlChar publicId,
const xmlChar systemId 
)

xmlSAX2ResolveEntity: @ctx: the user data (XML parser context) @publicId: The public ID of the entity @systemId: The system ID of the entity

The entity loader, to control the loading of external entities, the application can either:

Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.

Definition at line 486 of file SAX2.c.

487{
488 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
489 xmlParserInputPtr ret;
490 xmlChar *URI;
491 const char *base = NULL;
492
493 if (ctx == NULL) return(NULL);
494 if (ctxt->input != NULL)
495 base = ctxt->input->filename;
496 if (base == NULL)
497 base = ctxt->directory;
498
499 URI = xmlBuildURI(systemId, (const xmlChar *) base);
500
501 ret = xmlLoadExternalEntity((const char *) URI,
502 (const char *) publicId, ctxt);
503 if (URI != NULL)
504 xmlFree(URI);
505 return(ret);
506}
XMLPUBFUN xmlParserInputPtr xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)

Referenced by doparse(), libxmlresolveentity(), and xmlSAXVersion().

◆ xmlSAX2SetDocumentLocator()

XMLPUBFUN void xmlSAX2SetDocumentLocator ( void ctx,
xmlSAXLocatorPtr  loc 
)

Referenced by doparse().

◆ xmlSAX2StartDocument()

XMLPUBFUN void xmlSAX2StartDocument ( void ctx)

xmlSAX2StartDocument: @ctx: the user data (XML parser context)

called when the document start being processed.

Definition at line 887 of file SAX2.c.

888{
889 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
890 xmlDocPtr doc;
891
892 if (ctx == NULL) return;
893
894 if (ctxt->html) {
895#ifdef LIBXML_HTML_ENABLED
896 if (ctxt->myDoc == NULL)
897 ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
898 if (ctxt->myDoc == NULL) {
899 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
900 return;
901 }
902 ctxt->myDoc->properties = XML_DOC_HTML;
903 ctxt->myDoc->parseFlags = ctxt->options;
904#else
906 "libxml2 built without HTML support\n");
907 ctxt->errNo = XML_ERR_INTERNAL_ERROR;
908 ctxt->instate = XML_PARSER_EOF;
909 ctxt->disableSAX = 1;
910 return;
911#endif
912 } else {
913 doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
914 if (doc != NULL) {
915 doc->properties = 0;
916 if (ctxt->options & XML_PARSE_OLD10)
917 doc->properties |= XML_DOC_OLD10;
918 doc->parseFlags = ctxt->options;
919 doc->standalone = ctxt->standalone;
920 } else {
921 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
922 return;
923 }
924 if ((ctxt->dictNames) && (doc != NULL)) {
925 doc->dict = ctxt->dict;
926 xmlDictReference(doc->dict);
927 }
928 }
929 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) &&
930 (ctxt->input != NULL) && (ctxt->input->filename != NULL)) {
931 ctxt->myDoc->URL = xmlPathToURI((const xmlChar *)ctxt->input->filename);
932 if (ctxt->myDoc->URL == NULL)
933 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
934 }
935}
int xmlDictReference(xmlDictPtr dict)
Definition: dict.c:317
void * xmlGenericErrorContext
Definition: globals.c:410
xmlGenericErrorFunc xmlGenericError
Definition: globals.c:396
@ XML_PARSER_EOF
Definition: parser.h:116
@ XML_PARSE_OLD10
Definition: parser.h:1249
XMLPUBFUN xmlChar * xmlPathToURI(const xmlChar *path)
Definition: uri.c:2535

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2StartElementNs()

XMLPUBFUN void xmlSAX2StartElementNs ( void ctx,
const xmlChar localname,
const xmlChar prefix,
const xmlChar URI,
int  nb_namespaces,
const xmlChar **  namespaces,
int  nb_attributes,
int  nb_defaulted,
const xmlChar **  attributes 
)

xmlSAX2StartElementNs: @ctx: the user data (XML parser context) @localname: the local name of the element @prefix: the element namespace prefix if available @URI: the element namespace name if available @nb_namespaces: number of namespace definitions on that node @namespaces: pointer to the array of prefix/URI pairs namespace definitions @nb_attributes: the number of attributes on that node @nb_defaulted: the number of defaulted attributes. @attributes: pointer to the array of (localname/prefix/URI/value/end) attribute values.

SAX2 callback when an element start has been detected by the parser. It provides the namespace information for the element, as well as the new namespace declarations on the element.

Definition at line 2077 of file SAX2.c.

2086{
2087 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2088 xmlNodePtr ret;
2089 xmlNodePtr parent;
2090 xmlNsPtr last = NULL, ns;
2091 const xmlChar *uri, *pref;
2092 xmlChar *lname = NULL;
2093 int i, j;
2094
2095 if (ctx == NULL) return;
2096 /*
2097 * First check on validity:
2098 */
2099 if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
2100 ((ctxt->myDoc->intSubset == NULL) ||
2101 ((ctxt->myDoc->intSubset->notations == NULL) &&
2102 (ctxt->myDoc->intSubset->elements == NULL) &&
2103 (ctxt->myDoc->intSubset->attributes == NULL) &&
2104 (ctxt->myDoc->intSubset->entities == NULL)))) {
2105 xmlErrValid(ctxt, XML_DTD_NO_DTD,
2106 "Validation failed: no DTD found !", NULL, NULL);
2107 ctxt->validate = 0;
2108 }
2109
2110 /*
2111 * Take care of the rare case of an undefined namespace prefix
2112 */
2113 if ((prefix != NULL) && (URI == NULL)) {
2114 if (ctxt->dictNames) {
2115 const xmlChar *fullname;
2116
2117 fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
2118 if (fullname != NULL)
2119 localname = fullname;
2120 } else {
2121 lname = xmlBuildQName(localname, prefix, NULL, 0);
2122 }
2123 }
2124 /*
2125 * allocate the node
2126 */
2127 if (ctxt->freeElems != NULL) {
2128 ret = ctxt->freeElems;
2129 ctxt->freeElems = ret->next;
2130 ctxt->freeElemsNr--;
2131 memset(ret, 0, sizeof(xmlNode));
2132 ret->doc = ctxt->myDoc;
2133 ret->type = XML_ELEMENT_NODE;
2134
2135 if (ctxt->dictNames)
2136 ret->name = localname;
2137 else {
2138 if (lname == NULL)
2139 ret->name = xmlStrdup(localname);
2140 else
2141 ret->name = lname;
2142 if (ret->name == NULL) {
2143 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2144 xmlFree(ret);
2145 return;
2146 }
2147 }
2150 } else {
2151 if (ctxt->dictNames)
2152 ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
2153 (xmlChar *) localname, NULL);
2154 else if (lname == NULL)
2155 ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
2156 else
2157 ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
2158 (xmlChar *) lname, NULL);
2159 if (ret == NULL) {
2160 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2161 return;
2162 }
2163 }
2164 if (ctxt->linenumbers) {
2165 if (ctxt->input != NULL) {
2166 if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
2167 ret->line = ctxt->input->line;
2168 else
2169 ret->line = USHRT_MAX;
2170 }
2171 }
2172
2173 /*
2174 * Build the namespace list
2175 */
2176 for (i = 0,j = 0;j < nb_namespaces;j++) {
2177 pref = namespaces[i++];
2178 uri = namespaces[i++];
2179 ns = xmlNewNs(NULL, uri, pref);
2180 if (ns != NULL) {
2181 if (last == NULL) {
2182 ret->nsDef = last = ns;
2183 } else {
2184 last->next = ns;
2185 last = ns;
2186 }
2187 if ((URI != NULL) && (prefix == pref))
2188 ret->ns = ns;
2189 } else {
2190 /*
2191 * any out of memory error would already have been raised
2192 * but we can't be guaranteed it's the actual error due to the
2193 * API, best is to skip in this case
2194 */
2195 continue;
2196 }
2197
2198 xmlParserNsUpdateSax(ctxt, pref, ns);
2199
2200#ifdef LIBXML_VALID_ENABLED
2201 if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
2202 ctxt->myDoc && ctxt->myDoc->intSubset) {
2203 ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
2204 ret, prefix, ns, uri);
2205 }
2206#endif /* LIBXML_VALID_ENABLED */
2207 }
2208 ctxt->nodemem = -1;
2209
2210 /* Initialize parent before pushing node */
2211 parent = ctxt->node;
2212 if (parent == NULL)
2213 parent = (xmlNodePtr) ctxt->myDoc;
2214
2215 /*
2216 * We are parsing a new node.
2217 */
2218 if (nodePush(ctxt, ret) < 0) {
2219 xmlUnlinkNode(ret);
2220 xmlFreeNode(ret);
2221 return;
2222 }
2223
2224 /*
2225 * Link the child element
2226 */
2227 xmlAddChild(parent, ret);
2228
2229 /*
2230 * Insert the defaulted attributes from the DTD only if requested:
2231 */
2232 if ((nb_defaulted != 0) &&
2233 ((ctxt->loadsubset & XML_COMPLETE_ATTRS) == 0))
2234 nb_attributes -= nb_defaulted;
2235
2236 /*
2237 * Search the namespace if it wasn't already found
2238 * Note that, if prefix is NULL, this searches for the default Ns
2239 */
2240 if ((URI != NULL) && (ret->ns == NULL)) {
2241 ret->ns = xmlParserNsLookupSax(ctxt, prefix);
2242 if ((ret->ns == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
2243 ret->ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
2244 }
2245 if (ret->ns == NULL) {
2246 ns = xmlNewNs(ret, NULL, prefix);
2247 if (ns == NULL) {
2248
2249 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2250 return;
2251 }
2252 if (prefix != NULL)
2253 xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
2254 "Namespace prefix %s was not found\n",
2255 prefix, NULL);
2256 else
2257 xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
2258 "Namespace default prefix was not found\n",
2259 NULL, NULL);
2260 }
2261 }
2262
2263 /*
2264 * process all the other attributes
2265 */
2266 if (nb_attributes > 0) {
2267 xmlAttrPtr prev = NULL;
2268
2269 for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
2270 xmlAttrPtr attr = NULL;
2271
2272 /*
2273 * Handle the rare case of an undefined attribute prefix
2274 */
2275 if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
2276 if (ctxt->dictNames) {
2277 const xmlChar *fullname;
2278
2279 fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
2280 attributes[j]);
2281 if (fullname != NULL) {
2283 attributes[j+3],
2284 attributes[j+4]);
2285 goto have_attr;
2286 }
2287 } else {
2288 lname = xmlBuildQName(attributes[j], attributes[j+1],
2289 NULL, 0);
2290 if (lname != NULL) {
2291 attr = xmlSAX2AttributeNs(ctxt, lname, NULL,
2292 attributes[j+3],
2293 attributes[j+4]);
2294 xmlFree(lname);
2295 goto have_attr;
2296 }
2297 }
2298 }
2299 attr = xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
2300 attributes[j+3], attributes[j+4]);
2301have_attr:
2302 if (attr == NULL)
2303 continue;
2304
2305 /* link at the end to preserve order */
2306 if (prev == NULL) {
2307 ctxt->node->properties = attr;
2308 } else {
2309 prev->next = attr;
2310 attr->prev = prev;
2311 }
2312
2313 prev = attr;
2314 }
2315 }
2316
2317#ifdef LIBXML_VALID_ENABLED
2318 /*
2319 * If it's the Document root, finish the DTD validation and
2320 * check the document root element for validity
2321 */
2322 if ((ctxt->validate) &&
2323 ((ctxt->vctxt.flags & XML_VCTXT_DTD_VALIDATED) == 0)) {
2324 int chk;
2325
2326 chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
2327 if (chk <= 0)
2328 ctxt->valid = 0;
2329 if (chk < 0)
2330 ctxt->wellFormed = 0;
2331 ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
2332 ctxt->vctxt.flags |= XML_VCTXT_DTD_VALIDATED;
2333 }
2334#endif /* LIBXML_VALID_ENABLED */
2335}
static xmlAttrPtr xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt, const xmlChar *localname, const xmlChar *prefix, const xmlChar *value, const xmlChar *valueend)
Definition: SAX2.c:1852
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
if(dx< 0)
Definition: linetemp.h:194
static UINT UINT last
Definition: font.c:45
const char * uri
Definition: sec_mgr.c:1588
XML_DEPRECATED XMLPUBFUN int nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
Definition: parser.c:1956
const xmlChar * xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name)
Definition: dict.c:894
xmlRegisterNodeFunc xmlRegisterNodeDefaultValue
Definition: globals.c:364
#define XML_COMPLETE_ATTRS
Definition: parser.h:152
#define XML_VCTXT_DTD_VALIDATED
Definition: parser.h:12
XML_HIDDEN int xmlParserNsUpdateSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix, void *saxData)
Definition: parser.c:1601
XML_HIDDEN void * xmlParserNsLookupSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix)
Definition: parser.c:1569
XML_HIDDEN int __xmlRegisterCallbacks
Definition: tree.c:50
#define memset(x, y, z)
Definition: compat.h:39
Definition: mxnamespace.c:38
@ XML_DTD_NO_DTD
Definition: xmlerror.h:242
@ XML_NS_ERR_UNDEFINED_NAMESPACE
Definition: xmlerror.h:215

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2UnparsedEntityDecl()

XMLPUBFUN void xmlSAX2UnparsedEntityDecl ( void ctx,
const xmlChar name,
const xmlChar publicId,
const xmlChar systemId,
const xmlChar notationName 
)

Definition at line 813 of file SAX2.c.

816{
817 xmlEntityPtr ent;
818 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
819 if (ctx == NULL) return;
820 if (ctxt->inSubset == 1) {
821 ent = xmlAddDocEntity(ctxt->myDoc, name,
823 publicId, systemId, notationName);
824 if ((ent == NULL) && (ctxt->pedantic) &&
825 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
826 ctxt->sax->warning(ctxt->userData,
827 "Entity(%s) already defined in the internal subset\n", name);
828 if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
829 xmlChar *URI;
830 const char *base = NULL;
831
832 if (ctxt->input != NULL)
833 base = ctxt->input->filename;
834 if (base == NULL)
835 base = ctxt->directory;
836
837 URI = xmlBuildURI(systemId, (const xmlChar *) base);
838 ent->URI = URI;
839 }
840 } else if (ctxt->inSubset == 2) {
841 ent = xmlAddDtdEntity(ctxt->myDoc, name,
843 publicId, systemId, notationName);
844 if ((ent == NULL) && (ctxt->pedantic) &&
845 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
846 ctxt->sax->warning(ctxt->userData,
847 "Entity(%s) already defined in the external subset\n", name);
848 if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
849 xmlChar *URI;
850 const char *base = NULL;
851
852 if (ctxt->input != NULL)
853 base = ctxt->input->filename;
854 if (base == NULL)
855 base = ctxt->directory;
856
857 URI = xmlBuildURI(systemId, (const xmlChar *) base);
858 ent->URI = URI;
859 }
860 } else {
861 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
862 "SAX.xmlSAX2UnparsedEntityDecl(%s) called while not in subset\n",
863 name, NULL);
864 }
865}
@ XML_EXTERNAL_GENERAL_UNPARSED_ENTITY
Definition: entities.h:29

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAXVersion()

XMLPUBFUN int xmlSAXVersion ( xmlSAXHandler *  hdlr,
int  version 
)

xmlSAXVersion: @hdlr: the SAX handler

Version
: the version, 1 or 2

Initialize the default XML SAX handler according to the version

Returns 0 in case of success and -1 in case of error.

Definition at line 2704 of file SAX2.c.

2705{
2706 if (hdlr == NULL) return(-1);
2707 if (version == 2) {
2708 hdlr->startElementNs = xmlSAX2StartElementNs;
2709 hdlr->endElementNs = xmlSAX2EndElementNs;
2710 hdlr->serror = NULL;
2711 hdlr->initialized = XML_SAX2_MAGIC;
2712#ifdef LIBXML_SAX1_ENABLED
2713 } else if (version == 1) {
2714 hdlr->initialized = 1;
2715#endif /* LIBXML_SAX1_ENABLED */
2716 } else
2717 return(-1);
2718#ifdef LIBXML_SAX1_ENABLED
2719 hdlr->startElement = xmlSAX2StartElement;
2720 hdlr->endElement = xmlSAX2EndElement;
2721#else
2722 hdlr->startElement = NULL;
2723 hdlr->endElement = NULL;
2724#endif /* LIBXML_SAX1_ENABLED */
2725 hdlr->internalSubset = xmlSAX2InternalSubset;
2726 hdlr->externalSubset = xmlSAX2ExternalSubset;
2727 hdlr->isStandalone = xmlSAX2IsStandalone;
2728 hdlr->hasInternalSubset = xmlSAX2HasInternalSubset;
2729 hdlr->hasExternalSubset = xmlSAX2HasExternalSubset;
2730 hdlr->resolveEntity = xmlSAX2ResolveEntity;
2731 hdlr->getEntity = xmlSAX2GetEntity;
2732 hdlr->getParameterEntity = xmlSAX2GetParameterEntity;
2733 hdlr->entityDecl = xmlSAX2EntityDecl;
2734 hdlr->attributeDecl = xmlSAX2AttributeDecl;
2735 hdlr->elementDecl = xmlSAX2ElementDecl;
2736 hdlr->notationDecl = xmlSAX2NotationDecl;
2737 hdlr->unparsedEntityDecl = xmlSAX2UnparsedEntityDecl;
2738 hdlr->setDocumentLocator = xmlSAX2SetDocumentLocator;
2739 hdlr->startDocument = xmlSAX2StartDocument;
2740 hdlr->endDocument = xmlSAX2EndDocument;
2741 hdlr->reference = xmlSAX2Reference;
2742 hdlr->characters = xmlSAX2Characters;
2743 hdlr->cdataBlock = xmlSAX2CDataBlock;
2744 hdlr->ignorableWhitespace = xmlSAX2Characters;
2745 hdlr->processingInstruction = xmlSAX2ProcessingInstruction;
2746 hdlr->comment = xmlSAX2Comment;
2747 hdlr->warning = xmlParserWarning;
2748 hdlr->error = xmlParserError;
2749 hdlr->fatalError = xmlParserError;
2750
2751 return(0);
2752}
int xmlSAX2HasInternalSubset(void *ctx)
Definition: SAX2.c:291
void xmlSAX2NotationDecl(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
Definition: SAX2.c:764
void xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
Definition: SAX2.c:357
xmlParserInputPtr xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
Definition: SAX2.c:486
void xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
Definition: SAX2.c:813
xmlEntityPtr xmlSAX2GetParameterEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:564
void xmlSAX2EndDocument(void *ctx)
Definition: SAX2.c:944
void xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Definition: SAX2.c:588
void xmlSAX2Comment(void *ctx, const xmlChar *value)
Definition: SAX2.c:2614
void xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
Definition: SAX2.c:2660
int xmlSAX2HasExternalSubset(void *ctx)
Definition: SAX2.c:307
void xmlSAX2InternalSubset(void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
Definition: SAX2.c:324
void xmlSAX2SetDocumentLocator(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
Definition: SAX2.c:876
void xmlSAX2ElementDecl(void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)
Definition: SAX2.c:720
void xmlSAX2StartElementNs(void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)
Definition: SAX2.c:2077
void xmlSAX2StartDocument(void *ctx)
Definition: SAX2.c:887
void xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
Definition: SAX2.c:2539
xmlEntityPtr xmlSAX2GetEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:518
void xmlSAX2Reference(void *ctx, const xmlChar *name)
Definition: SAX2.c:2379
void xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target, const xmlChar *data)
Definition: SAX2.c:2567
void xmlSAX2EndElementNs(void *ctx, const xmlChar *localname ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED, const xmlChar *URI ATTRIBUTE_UNUSED)
Definition: SAX2.c:2348
void xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
Definition: SAX2.c:653
int xmlSAX2IsStandalone(void *ctx)
Definition: SAX2.c:275
static const WCHAR version[]
Definition: asmname.c:66
#define XML_SAX2_MAGIC
Definition: parser.h:687
XMLPUBFUN void xmlParserError(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2

Referenced by xmlInitSAXParserCtxt(), and xmlSAX2InitDefaultSAXHandler().