ReactOS 0.4.15-dev-7670-g69b08be
SAX2.h File Reference
#include <stdio.h>
#include <stdlib.h>
#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 xmlChar *XMLCALL xmlSAX2GetPublicId (void *ctx)
 
XMLPUBFUN const xmlChar *XMLCALL xmlSAX2GetSystemId (void *ctx)
 
XMLPUBFUN void XMLCALL xmlSAX2SetDocumentLocator (void *ctx, xmlSAXLocatorPtr loc)
 
XMLPUBFUN int XMLCALL xmlSAX2GetLineNumber (void *ctx)
 
XMLPUBFUN int XMLCALL xmlSAX2GetColumnNumber (void *ctx)
 
XMLPUBFUN int XMLCALL xmlSAX2IsStandalone (void *ctx)
 
XMLPUBFUN int XMLCALL xmlSAX2HasInternalSubset (void *ctx)
 
XMLPUBFUN int XMLCALL xmlSAX2HasExternalSubset (void *ctx)
 
XMLPUBFUN void XMLCALL xmlSAX2InternalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
XMLPUBFUN void XMLCALL xmlSAX2ExternalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetEntity (void *ctx, const xmlChar *name)
 
XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetParameterEntity (void *ctx, const xmlChar *name)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlSAX2ResolveEntity (void *ctx, const xmlChar *publicId, const xmlChar *systemId)
 
XMLPUBFUN void XMLCALL xmlSAX2EntityDecl (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
 
XMLPUBFUN void XMLCALL xmlSAX2AttributeDecl (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
 
XMLPUBFUN void XMLCALL xmlSAX2ElementDecl (void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)
 
XMLPUBFUN void XMLCALL xmlSAX2NotationDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 
XMLPUBFUN void XMLCALL xmlSAX2UnparsedEntityDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
 
XMLPUBFUN void XMLCALL xmlSAX2StartDocument (void *ctx)
 
XMLPUBFUN void XMLCALL xmlSAX2EndDocument (void *ctx)
 
XMLPUBFUN void XMLCALL 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 XMLCALL xmlSAX2EndElementNs (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
 
XMLPUBFUN void XMLCALL xmlSAX2Reference (void *ctx, const xmlChar *name)
 
XMLPUBFUN void XMLCALL xmlSAX2Characters (void *ctx, const xmlChar *ch, int len)
 
XMLPUBFUN void XMLCALL xmlSAX2IgnorableWhitespace (void *ctx, const xmlChar *ch, int len)
 
XMLPUBFUN void XMLCALL xmlSAX2ProcessingInstruction (void *ctx, const xmlChar *target, const xmlChar *data)
 
XMLPUBFUN void XMLCALL xmlSAX2Comment (void *ctx, const xmlChar *value)
 
XMLPUBFUN void XMLCALL xmlSAX2CDataBlock (void *ctx, const xmlChar *value, int len)
 
XMLPUBFUN int XMLCALL xmlSAXVersion (xmlSAXHandler *hdlr, int version)
 
XMLPUBFUN void XMLCALL xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, int warning)
 
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit (void)
 

Function Documentation

◆ xmlDefaultSAXHandlerInit()

XML_DEPRECATED XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit ( void  )

xmlDefaultSAXHandlerInit:

DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.

Initialize the default SAX2 handler

Definition at line 2934 of file SAX2.c.

2935{
2936#ifdef LIBXML_SAX1_ENABLED
2938#endif /* LIBXML_SAX1_ENABLED */
2939}
int xmlSAXVersion(xmlSAXHandler *hdlr, int version)
Definition: SAX2.c:2858
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler
Definition: globals.h:312

Referenced by xmlInitParser().

◆ xmlSAX2AttributeDecl()

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

Definition at line 674 of file SAX2.c.

677{
680 xmlChar *name = NULL, *prefix = NULL;
681
682 /* Avoid unused variable warning if features are disabled. */
683 (void) attr;
684
685 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
686 return;
687
688#ifdef DEBUG_SAX
690 "SAX.xmlSAX2AttributeDecl(%s, %s, %d, %d, %s, ...)\n",
691 elem, fullname, type, def, defaultValue);
692#endif
693 if ((xmlStrEqual(fullname, BAD_CAST "xml:id")) &&
694 (type != XML_ATTRIBUTE_ID)) {
695 /*
696 * Raise the error but keep the validity flag
697 */
698 int tmp = ctxt->valid;
699 xmlErrValid(ctxt, XML_DTD_XMLID_TYPE,
700 "xml:id : attribute type should be ID\n", NULL, NULL);
701 ctxt->valid = tmp;
702 }
703 /* TODO: optimize name/prefix allocation */
704 name = xmlSplitQName(ctxt, fullname, &prefix);
705 ctxt->vctxt.valid = 1;
706 if (ctxt->inSubset == 1)
708 name, prefix, (xmlAttributeType) type,
709 (xmlAttributeDefault) def, defaultValue, tree);
710 else if (ctxt->inSubset == 2)
712 name, prefix, (xmlAttributeType) type,
713 (xmlAttributeDefault) def, defaultValue, tree);
714 else {
715 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
716 "SAX.xmlSAX2AttributeDecl(%s) called while not in subset\n",
717 name, NULL);
718 xmlFree(name);
720 return;
721 }
722#ifdef LIBXML_VALID_ENABLED
723 if (ctxt->vctxt.valid == 0)
724 ctxt->valid = 0;
725 if ((attr != NULL) && (ctxt->validate) && (ctxt->wellFormed) &&
726 (ctxt->myDoc->intSubset != NULL))
727 ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc,
728 attr);
729#endif /* LIBXML_VALID_ENABLED */
730 if (prefix != NULL)
731 xmlFree(prefix);
732 if (name != NULL)
733 xmlFree(name);
734}
#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:68
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix)
Definition: parser.c:2946
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
xmlAttributeType
Definition: tree.h:206
@ XML_ATTRIBUTE_ID
Definition: tree.h:208
xmlAttributeDefault
Definition: tree.h:225
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
struct _xmlDtd * intSubset
Definition: tree.h:570
struct _xmlDtd * extSubset
Definition: tree.h:571
xmlValidCtxt vctxt
Definition: parser.h:221
int wellFormed
Definition: parser.h:188
xmlDocPtr myDoc
Definition: parser.h:187
int inSubset
Definition: parser.h:238
int validate
Definition: parser.h:220
Definition: cookie.c:202
Definition: name.c:39
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1817
XMLPUBFUN xmlAttributePtr XMLCALL 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:1967
@ XML_DTD_XMLID_TYPE
Definition: xmlerror.h:259
@ XML_ERR_INTERNAL_ERROR
Definition: xmlerror.h:101
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xmlSAXVersion().

◆ xmlSAX2CDataBlock()

XMLPUBFUN void XMLCALL 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 2816 of file SAX2.c.

2817{
2819}
static void xmlSAX2Text(xmlParserCtxtPtr ctxt, const xmlChar *ch, int len, xmlElementType type)
Definition: SAX2.c:2521
GLenum GLsizei len
Definition: glext.h:6722
@ XML_CDATA_SECTION_NODE
Definition: tree.h:163
Definition: pdh_main.c:94

Referenced by xmlSAXVersion().

◆ xmlSAX2Characters()

XMLPUBFUN void XMLCALL 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 2657 of file SAX2.c.

2658{
2660}
@ XML_TEXT_NODE
Definition: tree.h:162

Referenced by xmlSAXVersion().

◆ xmlSAX2Comment()

XMLPUBFUN void XMLCALL 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 2754 of file SAX2.c.

2755{
2759
2760 if (ctx == NULL) return;
2761 parent = ctxt->node;
2762#ifdef DEBUG_SAX
2763 xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2Comment(%s)\n", value);
2764#endif
2765 ret = xmlNewDocComment(ctxt->myDoc, value);
2766 if (ret == NULL) return;
2767 if (ctxt->linenumbers) {
2768 if (ctxt->input != NULL) {
2769 if (ctxt->input->line < USHRT_MAX)
2770 ret->line = (unsigned short) ctxt->input->line;
2771 else
2772 ret->line = USHRT_MAX;
2773 }
2774 }
2775
2776 if (ctxt->inSubset == 1) {
2778 return;
2779 } else if (ctxt->inSubset == 2) {
2781 return;
2782 }
2783 if (parent == NULL) {
2784#ifdef DEBUG_SAX_TREE
2786 "Setting xmlSAX2Comment as root\n");
2787#endif
2789 return;
2790 }
2791 if (parent->type == XML_ELEMENT_NODE) {
2792#ifdef DEBUG_SAX_TREE
2794 "adding xmlSAX2Comment child to %s\n", parent->name);
2795#endif
2797 } else {
2798#ifdef DEBUG_SAX_TREE
2800 "adding xmlSAX2Comment sibling to ");
2801 xmlDebugDumpOneNode(stderr, parent, 0);
2802#endif
2804 }
2805}
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
r parent
Definition: btrfs.c:3010
#define USHRT_MAX
Definition: limits.h:38
#define stderr
Definition: stdio.h:100
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
@ XML_ELEMENT_NODE
Definition: tree.h:160
XMLPUBFUN xmlNodePtr XMLCALL xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocComment(xmlDocPtr doc, const xmlChar *content)
Definition: tree.h:489
int linenumbers
Definition: parser.h:259
xmlNodePtr node
Definition: parser.h:205
xmlParserInputPtr input
Definition: parser.h:199
int ret

Referenced by xmlSAXVersion().

◆ xmlSAX2ElementDecl()

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

Definition at line 746 of file SAX2.c.

748{
751
752 /* Avoid unused variable warning if features are disabled. */
753 (void) elem;
754
755 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
756 return;
757
758#ifdef DEBUG_SAX
760 "SAX.xmlSAX2ElementDecl(%s, %d, ...)\n", name, type);
761#endif
762
763 if (ctxt->inSubset == 1)
764 elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset,
766 else if (ctxt->inSubset == 2)
767 elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->extSubset,
769 else {
770 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
771 "SAX.xmlSAX2ElementDecl(%s) called while not in subset\n",
772 name, NULL);
773 return;
774 }
775#ifdef LIBXML_VALID_ENABLED
776 if (elem == NULL)
777 ctxt->valid = 0;
778 if (ctxt->validate && ctxt->wellFormed &&
779 ctxt->myDoc && ctxt->myDoc->intSubset)
780 ctxt->valid &=
781 xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem);
782#endif /* LIBXML_VALID_ENABLED */
783}
content
Definition: atl_ax.c:994
xmlElementTypeVal
Definition: tree.h:322
XMLPUBFUN xmlElementPtr XMLCALL xmlAddElementDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlElementTypeVal type, xmlElementContentPtr content)
Definition: valid.c:1418

Referenced by xmlSAXVersion().

◆ xmlSAX2EndDocument()

XMLPUBFUN void XMLCALL xmlSAX2EndDocument ( void ctx)

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

called when the document end has been detected.

Definition at line 998 of file SAX2.c.

999{
1001#ifdef DEBUG_SAX
1003 "SAX.xmlSAX2EndDocument()\n");
1004#endif
1005 if (ctx == NULL) return;
1006#ifdef LIBXML_VALID_ENABLED
1007 if (ctxt->validate && ctxt->wellFormed &&
1008 ctxt->myDoc && ctxt->myDoc->intSubset)
1009 ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc);
1010#endif /* LIBXML_VALID_ENABLED */
1011
1012 /*
1013 * Grab the encoding if it was added on-the-fly
1014 */
1015 if ((ctxt->encoding != NULL) && (ctxt->myDoc != NULL) &&
1016 (ctxt->myDoc->encoding == NULL)) {
1017 ctxt->myDoc->encoding = ctxt->encoding;
1018 ctxt->encoding = NULL;
1019 }
1020 if ((ctxt->inputTab != NULL) &&
1021 (ctxt->inputNr > 0) && (ctxt->inputTab[0] != NULL) &&
1022 (ctxt->inputTab[0]->encoding != NULL) && (ctxt->myDoc != NULL) &&
1023 (ctxt->myDoc->encoding == NULL)) {
1024 ctxt->myDoc->encoding = xmlStrdup(ctxt->inputTab[0]->encoding);
1025 }
1026 if ((ctxt->charset != XML_CHAR_ENCODING_NONE) && (ctxt->myDoc != NULL) &&
1027 (ctxt->myDoc->charset == XML_CHAR_ENCODING_NONE)) {
1028 ctxt->myDoc->charset = ctxt->charset;
1029 }
1030}
@ XML_CHAR_ENCODING_NONE
Definition: encoding.h:58
int charset
Definition: tree.h:578
const xmlChar * encoding
Definition: tree.h:574
const xmlChar * encoding
Definition: parser.h:191
xmlParserInputPtr * inputTab
Definition: parser.h:202
const xmlChar * encoding
Definition: parser.h:71
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67

Referenced by xmlSAXVersion().

◆ xmlSAX2EndElementNs()

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

◆ xmlSAX2EntityDecl()

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

Definition at line 604 of file SAX2.c.

606{
607 xmlEntityPtr ent;
609
610 if (ctx == NULL) return;
611#ifdef DEBUG_SAX
613 "SAX.xmlSAX2EntityDecl(%s, %d, %s, %s, %s)\n",
614 name, type, publicId, systemId, content);
615#endif
616 if (ctxt->inSubset == 1) {
617 ent = xmlAddDocEntity(ctxt->myDoc, name, type, publicId,
618 systemId, content);
619 if ((ent == NULL) && (ctxt->pedantic))
620 xmlWarnMsg(ctxt, XML_WAR_ENTITY_REDEFINED,
621 "Entity(%s) already defined in the internal subset\n",
622 name);
623 if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
624 xmlChar *URI;
625 const char *base = NULL;
626
627 if (ctxt->input != NULL)
628 base = ctxt->input->filename;
629 if (base == NULL)
630 base = ctxt->directory;
631
632 URI = xmlBuildURI(systemId, (const xmlChar *) base);
633 ent->URI = URI;
634 }
635 } else if (ctxt->inSubset == 2) {
636 ent = xmlAddDtdEntity(ctxt->myDoc, name, type, publicId,
637 systemId, content);
638 if ((ent == NULL) && (ctxt->pedantic) &&
639 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
640 ctxt->sax->warning(ctxt->userData,
641 "Entity(%s) already defined in the external subset\n", name);
642 if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
643 xmlChar *URI;
644 const char *base = NULL;
645
646 if (ctxt->input != NULL)
647 base = ctxt->input->filename;
648 if (base == NULL)
649 base = ctxt->directory;
650
651 URI = xmlBuildURI(systemId, (const xmlChar *) base);
652 ent->URI = URI;
653 }
654 } else {
655 xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
656 "SAX.xmlSAX2EntityDecl(%s) called while not in subset\n",
657 name, NULL);
658 }
659}
XMLPUBFUN xmlEntityPtr XMLCALL xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content)
XMLPUBFUN xmlEntityPtr XMLCALL xmlAddDtdEntity(xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content)
const xmlChar * URI
Definition: entities.h:57
char * directory
Definition: parser.h:226
struct _xmlSAXHandler * sax
Definition: parser.h:185
int pedantic
Definition: parser.h:255
void * userData
Definition: parser.h:186
const char * filename
Definition: parser.h:56
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1892
@ XML_WAR_ENTITY_REDEFINED
Definition: xmlerror.h:207
@ XML_ERR_ENTITY_PROCESSING
Definition: xmlerror.h:204

Referenced by xmlParseEntityDecl(), and xmlSAXVersion().

◆ xmlSAX2ExternalSubset()

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

Definition at line 362 of file SAX2.c.

364{
366 if (ctx == NULL) return;
367#ifdef DEBUG_SAX
369 "SAX.xmlSAX2ExternalSubset(%s, %s, %s)\n",
370 name, ExternalID, SystemID);
371#endif
372 if (((ExternalID != NULL) || (SystemID != NULL)) &&
373 (((ctxt->validate) || (ctxt->loadsubset != 0)) &&
374 (ctxt->wellFormed && ctxt->myDoc))) {
375 /*
376 * Try to fetch and parse the external subset.
377 */
378 xmlParserInputPtr oldinput;
379 int oldinputNr;
380 int oldinputMax;
381 xmlParserInputPtr *oldinputTab;
383 xmlCharEncoding enc;
384 int oldcharset;
385 const xmlChar *oldencoding;
386
387 /*
388 * Ask the Entity resolver to load the damn thing
389 */
390 if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL))
391 input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID,
392 SystemID);
393 if (input == NULL) {
394 return;
395 }
396
397 xmlNewDtd(ctxt->myDoc, name, ExternalID, SystemID);
398
399 /*
400 * make sure we won't destroy the main document context
401 */
402 oldinput = ctxt->input;
403 oldinputNr = ctxt->inputNr;
404 oldinputMax = ctxt->inputMax;
405 oldinputTab = ctxt->inputTab;
406 oldcharset = ctxt->charset;
407 oldencoding = ctxt->encoding;
408 ctxt->encoding = NULL;
409
410 ctxt->inputTab = (xmlParserInputPtr *)
411 xmlMalloc(5 * sizeof(xmlParserInputPtr));
412 if (ctxt->inputTab == NULL) {
413 xmlSAX2ErrMemory(ctxt, "xmlSAX2ExternalSubset");
414 ctxt->input = oldinput;
415 ctxt->inputNr = oldinputNr;
416 ctxt->inputMax = oldinputMax;
417 ctxt->inputTab = oldinputTab;
418 ctxt->charset = oldcharset;
419 ctxt->encoding = oldencoding;
420 return;
421 }
422 ctxt->inputNr = 0;
423 ctxt->inputMax = 5;
424 ctxt->input = NULL;
425 xmlPushInput(ctxt, input);
426
427 /*
428 * On the fly encoding conversion if needed
429 */
430 if (ctxt->input->length >= 4) {
431 enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
432 xmlSwitchEncoding(ctxt, enc);
433 }
434
435 if (input->filename == NULL)
436 input->filename = (char *) xmlCanonicPath(SystemID);
437 input->line = 1;
438 input->col = 1;
439 input->base = ctxt->input->cur;
440 input->cur = ctxt->input->cur;
441 input->free = NULL;
442
443 /*
444 * let's parse that entity knowing it's an external subset.
445 */
446 xmlParseExternalSubset(ctxt, ExternalID, SystemID);
447
448 /*
449 * Free up the external entities
450 */
451
452 while (ctxt->inputNr > 1)
453 xmlPopInput(ctxt);
455 xmlFree(ctxt->inputTab);
456
457 /*
458 * Restore the parsing context of the main entity
459 */
460 ctxt->input = oldinput;
461 ctxt->inputNr = oldinputNr;
462 ctxt->inputMax = oldinputMax;
463 ctxt->inputTab = oldinputTab;
464 ctxt->charset = oldcharset;
465 if ((ctxt->encoding != NULL) &&
466 ((ctxt->dict == NULL) ||
467 (!xmlDictOwns(ctxt->dict, ctxt->encoding))))
468 xmlFree((xmlChar *) ctxt->encoding);
469 ctxt->encoding = oldencoding;
470 /* ctxt->wellFormed = oldwellFormed; */
471 }
472}
xmlCharEncoding
Definition: encoding.h:56
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:952
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN void XMLCALL xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID)
Definition: parser.c:6998
XMLPUBFUN xmlChar XMLCALL xmlPopInput(xmlParserCtxtPtr ctxt)
Definition: parser.c:2265
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBFUN int XMLCALL xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
Definition: parser.c:2290
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1220
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
XMLPUBFUN xmlDtdPtr XMLCALL xmlNewDtd(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
int inputMax
Definition: parser.h:201
int loadsubset
Definition: parser.h:258
xmlDictPtr dict
Definition: parser.h:263
const xmlChar * cur
Definition: parser.h:59
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2380

Referenced by xmlSAXVersion().

◆ xmlSAX2GetColumnNumber()

XMLPUBFUN int XMLCALL 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{
262 if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
263 return(ctxt->input->col);
264}

Referenced by xmlInitializeGlobalState().

◆ xmlSAX2GetEntity()

XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetEntity ( void ctx,
const xmlChar name 
)

Definition at line 526 of file SAX2.c.

527{
530
531 if (ctx == NULL) return(NULL);
532#ifdef DEBUG_SAX
534 "SAX.xmlSAX2GetEntity(%s)\n", name);
535#endif
536
537 if (ctxt->inSubset == 0) {
539 if (ret != NULL)
540 return(ret);
541 }
542 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->standalone == 1)) {
543 if (ctxt->inSubset == 2) {
544 ctxt->myDoc->standalone = 0;
545 ret = xmlGetDocEntity(ctxt->myDoc, name);
546 ctxt->myDoc->standalone = 1;
547 } else {
548 ret = xmlGetDocEntity(ctxt->myDoc, name);
549 if (ret == NULL) {
550 ctxt->myDoc->standalone = 0;
551 ret = xmlGetDocEntity(ctxt->myDoc, name);
552 if (ret != NULL) {
553 xmlFatalErrMsg(ctxt, XML_ERR_NOT_STANDALONE,
554 "Entity(%s) document marked standalone but requires external subset\n",
555 name, NULL);
556 }
557 ctxt->myDoc->standalone = 1;
558 }
559 }
560 } else {
561 ret = xmlGetDocEntity(ctxt->myDoc, name);
562 }
563 return(ret);
564}
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name)
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetPredefinedEntity(const xmlChar *name)
int standalone
Definition: tree.h:564
@ XML_ERR_NOT_STANDALONE
Definition: xmlerror.h:203

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

◆ xmlSAX2GetLineNumber()

XMLPUBFUN int XMLCALL 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{
246 if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
247 return(ctxt->input->line);
248}

Referenced by xmlInitializeGlobalState().

◆ xmlSAX2GetParameterEntity()

XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetParameterEntity ( void ctx,
const xmlChar name 
)

Definition at line 576 of file SAX2.c.

577{
580
581 if (ctx == NULL) return(NULL);
582#ifdef DEBUG_SAX
584 "SAX.xmlSAX2GetParameterEntity(%s)\n", name);
585#endif
586
588 return(ret);
589}
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetParameterEntity(xmlDocPtr doc, const xmlChar *name)

Referenced by xmlSAXVersion().

◆ xmlSAX2GetPublicId()

XMLPUBFUN const xmlChar *XMLCALL xmlSAX2GetPublicId ( void ctx)

◆ xmlSAX2GetSystemId()

XMLPUBFUN const xmlChar *XMLCALL 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{
230 if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);
231 return((const xmlChar *) ctxt->input->filename);
232}

Referenced by xmlInitializeGlobalState().

◆ xmlSAX2HasExternalSubset()

XMLPUBFUN int XMLCALL 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{
310 if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0);
311 return(ctxt->myDoc->extSubset != NULL);
312}

Referenced by xmlSAXVersion().

◆ xmlSAX2HasInternalSubset()

XMLPUBFUN int XMLCALL 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{
294 if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0);
295 return(ctxt->myDoc->intSubset != NULL);
296}

Referenced by xmlSAXVersion().

◆ xmlSAX2IgnorableWhitespace()

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

◆ xmlSAX2InitDefaultSAXHandler()

XMLPUBFUN void XMLCALL 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 2913 of file SAX2.c.

2914{
2915 if ((hdlr == NULL) || (hdlr->initialized != 0))
2916 return;
2917
2919 if (warning == 0)
2920 hdlr->warning = NULL;
2921 else
2922 hdlr->warning = xmlParserWarning;
2923}
static int xmlSAX2DefaultVersionValue
Definition: SAX2.c:2821
#define warning(s)
Definition: debug.h:83
warningSAXFunc warning
Definition: parser.h:741
unsigned int initialized
Definition: parser.h:747
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2

◆ xmlSAX2InternalSubset()

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

Definition at line 324 of file SAX2.c.

326{
328 xmlDtdPtr dtd;
329 if (ctx == NULL) return;
330#ifdef DEBUG_SAX
332 "SAX.xmlSAX2InternalSubset(%s, %s, %s)\n",
333 name, ExternalID, SystemID);
334#endif
335
336 if (ctxt->myDoc == NULL)
337 return;
338 dtd = xmlGetIntSubset(ctxt->myDoc);
339 if (dtd != NULL) {
340 if (ctxt->html)
341 return;
343 xmlFreeDtd(dtd);
344 ctxt->myDoc->intSubset = NULL;
345 }
346 ctxt->myDoc->intSubset =
347 xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
348 if (ctxt->myDoc->intSubset == NULL)
349 xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset");
350}
XMLPUBFUN xmlDtdPtr XMLCALL xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
XMLPUBFUN void XMLCALL xmlFreeDtd(xmlDtdPtr cur)
XMLPUBFUN xmlDtdPtr XMLCALL xmlGetIntSubset(const xmlDoc *doc)
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
Definition: tree.h:406

Referenced by xmlSAXVersion().

◆ xmlSAX2IsStandalone()

XMLPUBFUN int XMLCALL 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{
278 if ((ctx == NULL) || (ctxt->myDoc == NULL)) return(0);
279 return(ctxt->myDoc->standalone == 1);
280}

Referenced by xmlSAXVersion().

◆ xmlSAX2NotationDecl()

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

Definition at line 795 of file SAX2.c.

797{
799 xmlNotationPtr nota = NULL;
800
801 /* Avoid unused variable warning if features are disabled. */
802 (void) nota;
803
804 if ((ctxt == NULL) || (ctxt->myDoc == NULL))
805 return;
806
807#ifdef DEBUG_SAX
809 "SAX.xmlSAX2NotationDecl(%s, %s, %s)\n", name, publicId, systemId);
810#endif
811
812 if ((publicId == NULL) && (systemId == NULL)) {
813 xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
814 "SAX.xmlSAX2NotationDecl(%s) externalID or PublicID missing\n",
815 name, NULL);
816 return;
817 } else if (ctxt->inSubset == 1)
818 nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name,
819 publicId, systemId);
820 else if (ctxt->inSubset == 2)
821 nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, name,
822 publicId, systemId);
823 else {
824 xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
825 "SAX.xmlSAX2NotationDecl(%s) called while not in subset\n",
826 name, NULL);
827 return;
828 }
829#ifdef LIBXML_VALID_ENABLED
830 if (nota == NULL) ctxt->valid = 0;
831 if ((ctxt->validate) && (ctxt->wellFormed) &&
832 (ctxt->myDoc->intSubset != NULL))
833 ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc,
834 nota);
835#endif /* LIBXML_VALID_ENABLED */
836}
XMLPUBFUN xmlNotationPtr XMLCALL xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, const xmlChar *PublicID, const xmlChar *SystemID)
Definition: valid.c:2394
@ XML_ERR_NOTATION_PROCESSING
Definition: xmlerror.h:205

Referenced by xmlSAXVersion().

◆ xmlSAX2ProcessingInstruction()

XMLPUBFUN void XMLCALL 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 2690 of file SAX2.c.

2692{
2696
2697 if (ctx == NULL) return;
2698 parent = ctxt->node;
2699#ifdef DEBUG_SAX
2701 "SAX.xmlSAX2ProcessingInstruction(%s, %s)\n", target, data);
2702#endif
2703
2704 ret = xmlNewDocPI(ctxt->myDoc, target, data);
2705 if (ret == NULL) return;
2706
2707 if (ctxt->linenumbers) {
2708 if (ctxt->input != NULL) {
2709 if (ctxt->input->line < USHRT_MAX)
2710 ret->line = (unsigned short) ctxt->input->line;
2711 else
2712 ret->line = USHRT_MAX;
2713 }
2714 }
2715 if (ctxt->inSubset == 1) {
2717 return;
2718 } else if (ctxt->inSubset == 2) {
2720 return;
2721 }
2722 if (parent == NULL) {
2723#ifdef DEBUG_SAX_TREE
2725 "Setting PI %s as root\n", target);
2726#endif
2728 return;
2729 }
2730 if (parent->type == XML_ELEMENT_NODE) {
2731#ifdef DEBUG_SAX_TREE
2733 "adding PI %s child to %s\n", target, parent->name);
2734#endif
2736 } else {
2737#ifdef DEBUG_SAX_TREE
2739 "adding PI %s sibling to ", target);
2740 xmlDebugDumpOneNode(stderr, parent, 0);
2741#endif
2743 }
2744}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum target
Definition: glext.h:7315
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content)

Referenced by xmlSAXVersion().

◆ xmlSAX2Reference()

XMLPUBFUN void XMLCALL xmlSAX2Reference ( void ctx,
const xmlChar name 
)

Definition at line 2488 of file SAX2.c.

2489{
2492
2493 if (ctx == NULL) return;
2494#ifdef DEBUG_SAX
2496 "SAX.xmlSAX2Reference(%s)\n", name);
2497#endif
2498 if (name[0] == '#')
2499 ret = xmlNewCharRef(ctxt->myDoc, name);
2500 else
2501 ret = xmlNewReference(ctxt->myDoc, name);
2502#ifdef DEBUG_SAX_TREE
2504 "add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
2505#endif
2506 if (xmlAddChild(ctxt->node, ret) == NULL) {
2508 }
2509}
XMLPUBFUN xmlNodePtr XMLCALL xmlNewReference(const xmlDoc *doc, const xmlChar *name)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewCharRef(xmlDocPtr doc, const xmlChar *name)
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
const xmlChar * name
Definition: tree.h:492

Referenced by xmlSAXVersion().

◆ xmlSAX2ResolveEntity()

XMLPUBFUN xmlParserInputPtr XMLCALL 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 489 of file SAX2.c.

490{
493 xmlChar *URI;
494 const char *base = NULL;
495
496 if (ctx == NULL) return(NULL);
497 if (ctxt->input != NULL)
498 base = ctxt->input->filename;
499 if (base == NULL)
500 base = ctxt->directory;
501
502 URI = xmlBuildURI(systemId, (const xmlChar *) base);
503
504#ifdef DEBUG_SAX
506 "SAX.xmlSAX2ResolveEntity(%s, %s)\n", publicId, systemId);
507#endif
508
509 ret = xmlLoadExternalEntity((const char *) URI,
510 (const char *) publicId, ctxt);
511 if (URI != NULL)
512 xmlFree(URI);
513 return(ret);
514}
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)

Referenced by xmlSAXVersion().

◆ xmlSAX2SetDocumentLocator()

XMLPUBFUN void XMLCALL xmlSAX2SetDocumentLocator ( void ctx,
xmlSAXLocatorPtr  loc 
)

◆ xmlSAX2StartDocument()

XMLPUBFUN void XMLCALL xmlSAX2StartDocument ( void ctx)

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

called when the document start being processed.

Definition at line 933 of file SAX2.c.

934{
936 xmlDocPtr doc;
937
938 if (ctx == NULL) return;
939
940#ifdef DEBUG_SAX
942 "SAX.xmlSAX2StartDocument()\n");
943#endif
944 if (ctxt->html) {
945#ifdef LIBXML_HTML_ENABLED
946 if (ctxt->myDoc == NULL)
947 ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
948 if (ctxt->myDoc == NULL) {
949 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
950 return;
951 }
953 ctxt->myDoc->parseFlags = ctxt->options;
954#else
956 "libxml2 built without HTML support\n");
958 ctxt->instate = XML_PARSER_EOF;
959 ctxt->disableSAX = 1;
960 return;
961#endif
962 } else {
963 doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
964 if (doc != NULL) {
965 doc->properties = 0;
966 if (ctxt->options & XML_PARSE_OLD10)
968 doc->parseFlags = ctxt->options;
969 if (ctxt->encoding != NULL)
970 doc->encoding = xmlStrdup(ctxt->encoding);
971 else
972 doc->encoding = NULL;
973 doc->standalone = ctxt->standalone;
974 } else {
975 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
976 return;
977 }
978 if ((ctxt->dictNames) && (doc != NULL)) {
979 doc->dict = ctxt->dict;
981 }
982 }
983 if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) &&
984 (ctxt->input != NULL) && (ctxt->input->filename != NULL)) {
985 ctxt->myDoc->URL = xmlPathToURI((const xmlChar *)ctxt->input->filename);
986 if (ctxt->myDoc->URL == NULL)
987 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
988 }
989}
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:647
@ XML_PARSER_EOF
Definition: parser.h:111
@ XML_PARSE_OLD10
Definition: parser.h:1112
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
@ XML_DOC_HTML
Definition: tree.h:541
@ XML_DOC_OLD10
Definition: tree.h:535
Definition: tree.h:551
const xmlChar * URL
Definition: tree.h:577
int parseFlags
Definition: tree.h:582
int properties
Definition: tree.h:584
struct _xmlDict * dict
Definition: tree.h:580
int disableSAX
Definition: parser.h:237
int dictNames
Definition: parser.h:292
xmlParserInputState instate
Definition: parser.h:223
const xmlChar * version
Definition: parser.h:190
int standalone
Definition: parser.h:192
XMLPUBFUN xmlChar *XMLCALL xmlPathToURI(const xmlChar *path)
Definition: uri.c:2521

Referenced by xmlSAXVersion().

◆ xmlSAX2StartElementNs()

XMLPUBFUN void XMLCALL 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 2195 of file SAX2.c.

2204{
2208 xmlNsPtr last = NULL, ns;
2209 const xmlChar *uri, *pref;
2210 xmlChar *lname = NULL;
2211 int i, j;
2212
2213 if (ctx == NULL) return;
2214 parent = ctxt->node;
2215 /*
2216 * First check on validity:
2217 */
2218 if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
2219 ((ctxt->myDoc->intSubset == NULL) ||
2220 ((ctxt->myDoc->intSubset->notations == NULL) &&
2221 (ctxt->myDoc->intSubset->elements == NULL) &&
2222 (ctxt->myDoc->intSubset->attributes == NULL) &&
2223 (ctxt->myDoc->intSubset->entities == NULL)))) {
2224 xmlErrValid(ctxt, XML_DTD_NO_DTD,
2225 "Validation failed: no DTD found !", NULL, NULL);
2226 ctxt->validate = 0;
2227 }
2228
2229 /*
2230 * Take care of the rare case of an undefined namespace prefix
2231 */
2232 if ((prefix != NULL) && (URI == NULL)) {
2233 if (ctxt->dictNames) {
2234 const xmlChar *fullname;
2235
2236 fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
2237 if (fullname != NULL)
2238 localname = fullname;
2239 } else {
2240 lname = xmlBuildQName(localname, prefix, NULL, 0);
2241 }
2242 }
2243 /*
2244 * allocate the node
2245 */
2246 if (ctxt->freeElems != NULL) {
2247 ret = ctxt->freeElems;
2248 ctxt->freeElems = ret->next;
2249 ctxt->freeElemsNr--;
2250 memset(ret, 0, sizeof(xmlNode));
2251 ret->doc = ctxt->myDoc;
2252 ret->type = XML_ELEMENT_NODE;
2253
2254 if (ctxt->dictNames)
2255 ret->name = localname;
2256 else {
2257 if (lname == NULL)
2258 ret->name = xmlStrdup(localname);
2259 else
2260 ret->name = lname;
2261 if (ret->name == NULL) {
2262 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2263 return;
2264 }
2265 }
2268 } else {
2269 if (ctxt->dictNames)
2271 (xmlChar *) localname, NULL);
2272 else if (lname == NULL)
2273 ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
2274 else
2276 (xmlChar *) lname, NULL);
2277 if (ret == NULL) {
2278 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2279 return;
2280 }
2281 }
2282 if (ctxt->linenumbers) {
2283 if (ctxt->input != NULL) {
2284 if (ctxt->input->line < USHRT_MAX)
2285 ret->line = (unsigned short) ctxt->input->line;
2286 else
2287 ret->line = USHRT_MAX;
2288 }
2289 }
2290
2291 if (parent == NULL) {
2293 }
2294 /*
2295 * Build the namespace list
2296 */
2297 for (i = 0,j = 0;j < nb_namespaces;j++) {
2298 pref = namespaces[i++];
2299 uri = namespaces[i++];
2300 ns = xmlNewNs(NULL, uri, pref);
2301 if (ns != NULL) {
2302 if (last == NULL) {
2303 ret->nsDef = last = ns;
2304 } else {
2305 last->next = ns;
2306 last = ns;
2307 }
2308 if ((URI != NULL) && (prefix == pref))
2309 ret->ns = ns;
2310 } else {
2311 /*
2312 * any out of memory error would already have been raised
2313 * but we can't be guaranteed it's the actual error due to the
2314 * API, best is to skip in this case
2315 */
2316 continue;
2317 }
2318#ifdef LIBXML_VALID_ENABLED
2319 if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
2320 ctxt->myDoc && ctxt->myDoc->intSubset) {
2321 ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
2322 ret, prefix, ns, uri);
2323 }
2324#endif /* LIBXML_VALID_ENABLED */
2325 }
2326 ctxt->nodemem = -1;
2327
2328 /*
2329 * We are parsing a new node.
2330 */
2331 if (nodePush(ctxt, ret) < 0) {
2334 return;
2335 }
2336
2337 /*
2338 * Link the child element
2339 */
2340 if (parent != NULL) {
2341 if (parent->type == XML_ELEMENT_NODE) {
2343 } else {
2345 }
2346 }
2347
2348 /*
2349 * Insert the defaulted attributes from the DTD only if requested:
2350 */
2351 if ((nb_defaulted != 0) &&
2352 ((ctxt->loadsubset & XML_COMPLETE_ATTRS) == 0))
2353 nb_attributes -= nb_defaulted;
2354
2355 /*
2356 * Search the namespace if it wasn't already found
2357 * Note that, if prefix is NULL, this searches for the default Ns
2358 */
2359 if ((URI != NULL) && (ret->ns == NULL)) {
2360 ret->ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
2361 if ((ret->ns == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
2362 ret->ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
2363 }
2364 if (ret->ns == NULL) {
2365 ns = xmlNewNs(ret, NULL, prefix);
2366 if (ns == NULL) {
2367
2368 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2369 return;
2370 }
2371 if (prefix != NULL)
2372 xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
2373 "Namespace prefix %s was not found\n",
2374 prefix, NULL);
2375 else
2376 xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
2377 "Namespace default prefix was not found\n",
2378 NULL, NULL);
2379 }
2380 }
2381
2382 /*
2383 * process all the other attributes
2384 */
2385 if (nb_attributes > 0) {
2386 for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
2387 /*
2388 * Handle the rare case of an undefined attribute prefix
2389 */
2390 if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
2391 if (ctxt->dictNames) {
2392 const xmlChar *fullname;
2393
2394 fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
2395 attributes[j]);
2396 if (fullname != NULL) {
2398 attributes[j+3], attributes[j+4]);
2399 continue;
2400 }
2401 } else {
2402 lname = xmlBuildQName(attributes[j], attributes[j+1],
2403 NULL, 0);
2404 if (lname != NULL) {
2405 xmlSAX2AttributeNs(ctxt, lname, NULL,
2406 attributes[j+3], attributes[j+4]);
2407 xmlFree(lname);
2408 continue;
2409 }
2410 }
2411 }
2412 xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
2413 attributes[j+3], attributes[j+4]);
2414 }
2415 }
2416
2417#ifdef LIBXML_VALID_ENABLED
2418 /*
2419 * If it's the Document root, finish the DTD validation and
2420 * check the document root element for validity
2421 */
2422 if ((ctxt->validate) &&
2423 ((ctxt->vctxt.flags & XML_VCTXT_DTD_VALIDATED) == 0)) {
2424 int chk;
2425
2426 chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
2427 if (chk <= 0)
2428 ctxt->valid = 0;
2429 if (chk < 0)
2430 ctxt->wellFormed = 0;
2431 ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
2432 ctxt->vctxt.flags |= XML_VCTXT_DTD_VALIDATED;
2433 }
2434#endif /* LIBXML_VALID_ENABLED */
2435}
static void xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt, const xmlChar *localname, const xmlChar *prefix, const xmlChar *value, const xmlChar *valueend)
Definition: SAX2.c:1967
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
int __xmlRegisterCallbacks
Definition: tree.c:50
static UINT UINT last
Definition: font.c:45
const char * uri
Definition: sec_mgr.c:1588
XMLPUBFUN int XMLCALL nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
Definition: parser.c:1801
XMLPUBFUN const xmlChar *XMLCALL xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name)
Definition: dict.c:1115
XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue
Definition: globals.h:467
#define XML_COMPLETE_ATTRS
Definition: parser.h:146
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content)
XMLPUBFUN xmlChar *XMLCALL xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns, xmlChar *name, const xmlChar *content)
XMLPUBFUN xmlNsPtr XMLCALL xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix)
#define memset(x, y, z)
Definition: compat.h:39
Definition: tree.h:389
int freeElemsNr
Definition: parser.h:293
xmlNodePtr freeElems
Definition: parser.h:294
Definition: mxnamespace.c:45
@ XML_DTD_NO_DTD
Definition: xmlerror.h:241
@ XML_NS_ERR_UNDEFINED_NAMESPACE
Definition: xmlerror.h:214

Referenced by xmlSAXVersion().

◆ xmlSAX2UnparsedEntityDecl()

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

Definition at line 849 of file SAX2.c.

852{
853 xmlEntityPtr ent;
855 if (ctx == NULL) return;
856#ifdef DEBUG_SAX
858 "SAX.xmlSAX2UnparsedEntityDecl(%s, %s, %s, %s)\n",
859 name, publicId, systemId, notationName);
860#endif
861 if (ctxt->inSubset == 1) {
862 ent = xmlAddDocEntity(ctxt->myDoc, name,
864 publicId, systemId, notationName);
865 if ((ent == NULL) && (ctxt->pedantic) &&
866 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
867 ctxt->sax->warning(ctxt->userData,
868 "Entity(%s) already defined in the internal subset\n", name);
869 if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
870 xmlChar *URI;
871 const char *base = NULL;
872
873 if (ctxt->input != NULL)
874 base = ctxt->input->filename;
875 if (base == NULL)
876 base = ctxt->directory;
877
878 URI = xmlBuildURI(systemId, (const xmlChar *) base);
879 ent->URI = URI;
880 }
881 } else if (ctxt->inSubset == 2) {
882 ent = xmlAddDtdEntity(ctxt->myDoc, name,
884 publicId, systemId, notationName);
885 if ((ent == NULL) && (ctxt->pedantic) &&
886 (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
887 ctxt->sax->warning(ctxt->userData,
888 "Entity(%s) already defined in the external subset\n", name);
889 if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
890 xmlChar *URI;
891 const char *base = NULL;
892
893 if (ctxt->input != NULL)
894 base = ctxt->input->filename;
895 if (base == NULL)
896 base = ctxt->directory;
897
898 URI = xmlBuildURI(systemId, (const xmlChar *) base);
899 ent->URI = URI;
900 }
901 } else {
902 xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
903 "SAX.xmlSAX2UnparsedEntityDecl(%s) called while not in subset\n",
904 name, NULL);
905 }
906}
@ XML_EXTERNAL_GENERAL_UNPARSED_ENTITY
Definition: entities.h:27

Referenced by xmlSAXVersion().

◆ xmlSAXVersion()

XMLPUBFUN int XMLCALL 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 2858 of file SAX2.c.

2859{
2860 if (hdlr == NULL) return(-1);
2861 if (version == 2) {
2862 hdlr->startElement = NULL;
2863 hdlr->endElement = NULL;
2866 hdlr->serror = NULL;
2868#ifdef LIBXML_SAX1_ENABLED
2869 } else if (version == 1) {
2870 hdlr->startElement = xmlSAX2StartElement;
2871 hdlr->endElement = xmlSAX2EndElement;
2872 hdlr->initialized = 1;
2873#endif /* LIBXML_SAX1_ENABLED */
2874 } else
2875 return(-1);
2897 hdlr->comment = xmlSAX2Comment;
2898 hdlr->warning = xmlParserWarning;
2899 hdlr->error = xmlParserError;
2900 hdlr->fatalError = xmlParserError;
2901
2902 return(0);
2903}
int xmlSAX2HasInternalSubset(void *ctx)
Definition: SAX2.c:291
void xmlSAX2NotationDecl(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
Definition: SAX2.c:795
void xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
Definition: SAX2.c:362
xmlParserInputPtr xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
Definition: SAX2.c:489
void xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
Definition: SAX2.c:849
xmlEntityPtr xmlSAX2GetParameterEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:576
void xmlSAX2EndDocument(void *ctx)
Definition: SAX2.c:998
void xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Definition: SAX2.c:604
void xmlSAX2Comment(void *ctx, const xmlChar *value)
Definition: SAX2.c:2754
void xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
Definition: SAX2.c:2816
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:917
void xmlSAX2ElementDecl(void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)
Definition: SAX2.c:746
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:2195
void xmlSAX2StartDocument(void *ctx)
Definition: SAX2.c:933
void xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
Definition: SAX2.c:2657
xmlEntityPtr xmlSAX2GetEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:526
void xmlSAX2Reference(void *ctx, const xmlChar *name)
Definition: SAX2.c:2488
void xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target, const xmlChar *data)
Definition: SAX2.c:2690
void xmlSAX2EndElementNs(void *ctx, const xmlChar *localname ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED, const xmlChar *URI ATTRIBUTE_UNUSED)
Definition: SAX2.c:2448
void xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
Definition: SAX2.c:674
int xmlSAX2IsStandalone(void *ctx)
Definition: SAX2.c:275
static const WCHAR version[]
Definition: asmname.c:66
#define XML_SAX2_MAGIC
Definition: parser.h:671
unparsedEntityDeclSAXFunc unparsedEntityDecl
Definition: parser.h:730
hasExternalSubsetSAXFunc hasExternalSubset
Definition: parser.h:723
setDocumentLocatorSAXFunc setDocumentLocator
Definition: parser.h:731
getEntitySAXFunc getEntity
Definition: parser.h:725
commentSAXFunc comment
Definition: parser.h:740
errorSAXFunc error
Definition: parser.h:742
attributeDeclSAXFunc attributeDecl
Definition: parser.h:728
referenceSAXFunc reference
Definition: parser.h:736
startElementNsSAX2Func startElementNs
Definition: parser.h:750
externalSubsetSAXFunc externalSubset
Definition: parser.h:746
internalSubsetSAXFunc internalSubset
Definition: parser.h:720
endElementSAXFunc endElement
Definition: parser.h:735
isStandaloneSAXFunc isStandalone
Definition: parser.h:721
endDocumentSAXFunc endDocument
Definition: parser.h:733
fatalErrorSAXFunc fatalError
Definition: parser.h:743
hasInternalSubsetSAXFunc hasInternalSubset
Definition: parser.h:722
notationDeclSAXFunc notationDecl
Definition: parser.h:727
resolveEntitySAXFunc resolveEntity
Definition: parser.h:724
getParameterEntitySAXFunc getParameterEntity
Definition: parser.h:744
endElementNsSAX2Func endElementNs
Definition: parser.h:751
cdataBlockSAXFunc cdataBlock
Definition: parser.h:745
startElementSAXFunc startElement
Definition: parser.h:734
xmlStructuredErrorFunc serror
Definition: parser.h:752
entityDeclSAXFunc entityDecl
Definition: parser.h:726
processingInstructionSAXFunc processingInstruction
Definition: parser.h:739
charactersSAXFunc characters
Definition: parser.h:737
startDocumentSAXFunc startDocument
Definition: parser.h:732
elementDeclSAXFunc elementDecl
Definition: parser.h:729
ignorableWhitespaceSAXFunc ignorableWhitespace
Definition: parser.h:738
XMLPUBFUN void XMLCDECL xmlParserError(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2

Referenced by xmlDefaultSAXHandlerInit(), xmlInitParserCtxt(), and xmlSAX2InitDefaultSAXHandler().