ReactOS  0.4.15-dev-994-ga9f6032
SAX2.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/xlink.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)
 
XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit (void)
 

Function Documentation

◆ xmlDefaultSAXHandlerInit()

XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit ( void  )

xmlDefaultSAXHandlerInit:

Initialize the default SAX2 handler

Definition at line 2941 of file SAX2.c.

2942 {
2943 #ifdef LIBXML_SAX1_ENABLED
2945 #endif /* LIBXML_SAX1_ENABLED */
2946 }
int xmlSAXVersion(xmlSAXHandler *hdlr, int version)
Definition: SAX2.c:2868
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler
Definition: globals.h:321

Referenced by xmlInitParser(), xmlInitParserCtxt(), and xmlParseExtParsedEnt().

◆ 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 734 of file SAX2.c.

737 {
740  xmlChar *name = NULL, *prefix = NULL;
741 
742  if ((ctxt == NULL) || (ctxt->myDoc == NULL))
743  return;
744 
745 #ifdef DEBUG_SAX
747  "SAX.xmlSAX2AttributeDecl(%s, %s, %d, %d, %s, ...)\n",
748  elem, fullname, type, def, defaultValue);
749 #endif
750  if ((xmlStrEqual(fullname, BAD_CAST "xml:id")) &&
751  (type != XML_ATTRIBUTE_ID)) {
752  /*
753  * Raise the error but keep the validity flag
754  */
755  int tmp = ctxt->valid;
756  xmlErrValid(ctxt, XML_DTD_XMLID_TYPE,
757  "xml:id : attribute type should be ID\n", NULL, NULL);
758  ctxt->valid = tmp;
759  }
760  /* TODO: optimize name/prefix allocation */
761  name = xmlSplitQName(ctxt, fullname, &prefix);
762  ctxt->vctxt.valid = 1;
763  if (ctxt->inSubset == 1)
764  attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem,
765  name, prefix, (xmlAttributeType) type,
766  (xmlAttributeDefault) def, defaultValue, tree);
767  else if (ctxt->inSubset == 2)
768  attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, elem,
769  name, prefix, (xmlAttributeType) type,
770  (xmlAttributeDefault) def, defaultValue, tree);
771  else {
772  xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
773  "SAX.xmlSAX2AttributeDecl(%s) called while not in subset\n",
774  name, NULL);
776  return;
777  }
778 #ifdef LIBXML_VALID_ENABLED
779  if (ctxt->vctxt.valid == 0)
780  ctxt->valid = 0;
781  if ((attr != NULL) && (ctxt->validate) && (ctxt->wellFormed) &&
782  (ctxt->myDoc->intSubset != NULL))
783  ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc,
784  attr);
785 #endif /* LIBXML_VALID_ENABLED */
786  if (prefix != NULL)
787  xmlFree(prefix);
788  if (name != NULL)
789  xmlFree(name);
790 }
struct _xmlDtd * intSubset
Definition: tree.h:570
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static size_t elem
Definition: string.c:68
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix)
Definition: parser.c:2907
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
int validate
Definition: parser.h:220
int wellFormed
Definition: parser.h:188
xmlAttributeDefault
Definition: tree.h:225
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
Definition: cookie.c:201
xmlDocPtr myDoc
Definition: parser.h:187
__u8 attr
Definition: mkdosfs.c:359
const char * fullname
Definition: shader.c:1766
unsigned char xmlChar
Definition: xmlstring.h:28
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:1981
int inSubset
Definition: parser.h:238
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
struct _xmlDtd * extSubset
Definition: tree.h:571
Definition: name.c:38
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
xmlValidCtxt vctxt
Definition: parser.h:221
int valid
Definition: valid.h:95
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1831
xmlAttributeType
Definition: tree.h:206
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 2806 of file SAX2.c.

2807 {
2809  xmlNodePtr ret, lastChild;
2810 
2811  if (ctx == NULL) return;
2812 #ifdef DEBUG_SAX
2814  "SAX.pcdata(%.10s, %d)\n", value, len);
2815 #endif
2816  lastChild = xmlGetLastChild(ctxt->node);
2817 #ifdef DEBUG_SAX_TREE
2819  "add chars to %s \n", ctxt->node->name);
2820 #endif
2821  if ((lastChild != NULL) &&
2822  (lastChild->type == XML_CDATA_SECTION_NODE)) {
2823  xmlTextConcat(lastChild, value, len);
2824  } else {
2825  ret = xmlNewCDataBlock(ctxt->myDoc, value, len);
2826  if (xmlAddChild(ctxt->node, ret) == NULL)
2827  xmlFreeNode(ret);
2828  }
2829 }
const xmlChar * name
Definition: tree.h:492
XMLPUBFUN xmlNodePtr XMLCALL xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len)
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlNodePtr XMLCALL xmlGetLastChild(const xmlNode *parent)
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
xmlNodePtr node
Definition: parser.h:205
Definition: tree.h:489
int ret
xmlDocPtr myDoc
Definition: parser.h:187
GLenum GLsizei len
Definition: glext.h:6722
xmlElementType type
Definition: tree.h:491
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
XMLPUBFUN int XMLCALL xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len)
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 2534 of file SAX2.c.

2535 {
2537  xmlNodePtr lastChild;
2538 
2539  if (ctx == NULL) return;
2540 #ifdef DEBUG_SAX
2542  "SAX.xmlSAX2Characters(%.30s, %d)\n", ch, len);
2543 #endif
2544  /*
2545  * Handle the data if any. If there is no child
2546  * add it as content, otherwise if the last child is text,
2547  * concatenate it, else create a new node of type text.
2548  */
2549 
2550  if (ctxt->node == NULL) {
2551 #ifdef DEBUG_SAX_TREE
2553  "add chars: ctxt->node == NULL !\n");
2554 #endif
2555  return;
2556  }
2557  lastChild = ctxt->node->last;
2558 #ifdef DEBUG_SAX_TREE
2560  "add chars to %s \n", ctxt->node->name);
2561 #endif
2562 
2563  /*
2564  * Here we needed an accelerator mechanism in case of very large
2565  * elements. Use an attribute in the structure !!!
2566  */
2567  if (lastChild == NULL) {
2568  lastChild = xmlSAX2TextNode(ctxt, ch, len);
2569  if (lastChild != NULL) {
2570  ctxt->node->children = lastChild;
2571  ctxt->node->last = lastChild;
2572  lastChild->parent = ctxt->node;
2573  lastChild->doc = ctxt->node->doc;
2574  ctxt->nodelen = len;
2575  ctxt->nodemem = len + 1;
2576  } else {
2577  xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2578  return;
2579  }
2580  } else {
2581  int coalesceText = (lastChild != NULL) &&
2582  (lastChild->type == XML_TEXT_NODE) &&
2583  (lastChild->name == xmlStringText);
2584  if ((coalesceText) && (ctxt->nodemem != 0)) {
2585  /*
2586  * The whole point of maintaining nodelen and nodemem,
2587  * xmlTextConcat is too costly, i.e. compute length,
2588  * reallocate a new buffer, move data, append ch. Here
2589  * We try to minimize realloc() uses and avoid copying
2590  * and recomputing length over and over.
2591  */
2592  if (lastChild->content == (xmlChar *)&(lastChild->properties)) {
2593  lastChild->content = xmlStrdup(lastChild->content);
2594  lastChild->properties = NULL;
2595  } else if ((ctxt->nodemem == ctxt->nodelen + 1) &&
2596  (xmlDictOwns(ctxt->dict, lastChild->content))) {
2597  lastChild->content = xmlStrdup(lastChild->content);
2598  }
2599  if (lastChild->content == NULL) {
2600  xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
2601  return;
2602  }
2603  if (((size_t)ctxt->nodelen + (size_t)len > XML_MAX_TEXT_LENGTH) &&
2604  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
2605  xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
2606  return;
2607  }
2608  if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len ||
2609  (size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) {
2610  xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
2611  return;
2612  }
2613  if (ctxt->nodelen + len >= ctxt->nodemem) {
2614  xmlChar *newbuf;
2615  size_t size;
2616 
2617  size = ctxt->nodemem + len;
2618  size *= 2;
2619  newbuf = (xmlChar *) xmlRealloc(lastChild->content,size);
2620  if (newbuf == NULL) {
2621  xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2622  return;
2623  }
2624  ctxt->nodemem = size;
2625  lastChild->content = newbuf;
2626  }
2627  memcpy(&lastChild->content[ctxt->nodelen], ch, len);
2628  ctxt->nodelen += len;
2629  lastChild->content[ctxt->nodelen] = 0;
2630  } else if (coalesceText) {
2631  if (xmlTextConcat(lastChild, ch, len)) {
2632  xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2633  }
2634  if (ctxt->node->children != NULL) {
2635  ctxt->nodelen = xmlStrlen(lastChild->content);
2636  ctxt->nodemem = ctxt->nodelen + 1;
2637  }
2638  } else {
2639  /* Mixed content, first time */
2640  lastChild = xmlSAX2TextNode(ctxt, ch, len);
2641  if (lastChild != NULL) {
2642  xmlAddChild(ctxt->node, lastChild);
2643  if (ctxt->node->children != NULL) {
2644  ctxt->nodelen = len;
2645  ctxt->nodemem = len + 1;
2646  }
2647  }
2648  }
2649  }
2650 }
const xmlChar * name
Definition: tree.h:492
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
#define XML_MAX_TEXT_LENGTH
struct _xmlDoc * doc
Definition: tree.h:498
static xmlNodePtr xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len)
Definition: SAX2.c:1857
XMLPUBVAR const xmlChar xmlStringText[]
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
struct _xmlNode * last
Definition: tree.h:494
smooth NULL
Definition: ftsmooth.c:416
xmlDictPtr dict
Definition: parser.h:263
#define SIZE_T_MAX
Definition: SAX2.c:33
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
struct _xmlNode * parent
Definition: tree.h:495
GLsizeiptr size
Definition: glext.h:5919
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
xmlNodePtr node
Definition: parser.h:205
xmlChar * content
Definition: tree.h:502
Definition: tree.h:489
unsigned char xmlChar
Definition: xmlstring.h:28
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
struct _xmlAttr * properties
Definition: tree.h:503
xmlElementType type
Definition: tree.h:491
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1218
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
XMLPUBFUN int XMLCALL xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len)
struct _xmlNode * children
Definition: tree.h:493
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 2744 of file SAX2.c.

2745 {
2747  xmlNodePtr ret;
2749 
2750  if (ctx == NULL) return;
2751  parent = ctxt->node;
2752 #ifdef DEBUG_SAX
2753  xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2Comment(%s)\n", value);
2754 #endif
2755  ret = xmlNewDocComment(ctxt->myDoc, value);
2756  if (ret == NULL) return;
2757  if (ctxt->linenumbers) {
2758  if (ctxt->input != NULL) {
2759  if (ctxt->input->line < 65535)
2760  ret->line = (short) ctxt->input->line;
2761  else
2762  ret->line = 65535;
2763  }
2764  }
2765 
2766  if (ctxt->inSubset == 1) {
2768  return;
2769  } else if (ctxt->inSubset == 2) {
2771  return;
2772  }
2773  if (parent == NULL) {
2774 #ifdef DEBUG_SAX_TREE
2776  "Setting xmlSAX2Comment as root\n");
2777 #endif
2779  return;
2780  }
2781  if (parent->type == XML_ELEMENT_NODE) {
2782 #ifdef DEBUG_SAX_TREE
2784  "adding xmlSAX2Comment child to %s\n", parent->name);
2785 #endif
2787  } else {
2788 #ifdef DEBUG_SAX_TREE
2790  "adding xmlSAX2Comment sibling to ");
2791  xmlDebugDumpOneNode(stderr, parent, 0);
2792 #endif
2794  }
2795 }
struct _xmlDtd * intSubset
Definition: tree.h:570
XMLPUBFUN xmlNodePtr XMLCALL xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem)
xmlParserInputPtr input
Definition: parser.h:199
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
int linenumbers
Definition: parser.h:259
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
xmlNodePtr node
Definition: parser.h:205
r parent
Definition: btrfs.c:2944
Definition: tree.h:489
int ret
xmlDocPtr myDoc
Definition: parser.h:187
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocComment(xmlDocPtr doc, const xmlChar *content)
int inSubset
Definition: parser.h:238
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
struct _xmlDtd * extSubset
Definition: tree.h:571
FILE * stderr
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlSAXVersion().

◆ xmlSAX2ElementDecl()

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

Definition at line 802 of file SAX2.c.

804 {
807 
808  if ((ctxt == NULL) || (ctxt->myDoc == NULL))
809  return;
810 
811 #ifdef DEBUG_SAX
813  "SAX.xmlSAX2ElementDecl(%s, %d, ...)\n", name, type);
814 #endif
815 
816  if (ctxt->inSubset == 1)
817  elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset,
819  else if (ctxt->inSubset == 2)
820  elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->extSubset,
822  else {
823  xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
824  "SAX.xmlSAX2ElementDecl(%s) called while not in subset\n",
825  name, NULL);
826  return;
827  }
828 #ifdef LIBXML_VALID_ENABLED
829  if (elem == NULL)
830  ctxt->valid = 0;
831  if (ctxt->validate && ctxt->wellFormed &&
832  ctxt->myDoc && ctxt->myDoc->intSubset)
833  ctxt->valid &=
834  xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem);
835 #endif /* LIBXML_VALID_ENABLED */
836 }
struct _xmlDtd * intSubset
Definition: tree.h:570
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
xmlElementTypeVal
Definition: tree.h:322
static size_t elem
Definition: string.c:68
content
Definition: atl_ax.c:993
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
int validate
Definition: parser.h:220
int wellFormed
Definition: parser.h:188
xmlDocPtr myDoc
Definition: parser.h:187
XMLPUBFUN xmlElementPtr XMLCALL xmlAddElementDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlElementTypeVal type, xmlElementContentPtr content)
Definition: valid.c:1430
int inSubset
Definition: parser.h:238
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
struct _xmlDtd * extSubset
Definition: tree.h:571
Definition: name.c:38
xmlValidCtxt vctxt
Definition: parser.h:221
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 1048 of file SAX2.c.

1049 {
1051 #ifdef DEBUG_SAX
1053  "SAX.xmlSAX2EndDocument()\n");
1054 #endif
1055  if (ctx == NULL) return;
1056 #ifdef LIBXML_VALID_ENABLED
1057  if (ctxt->validate && ctxt->wellFormed &&
1058  ctxt->myDoc && ctxt->myDoc->intSubset)
1059  ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc);
1060 #endif /* LIBXML_VALID_ENABLED */
1061 
1062  /*
1063  * Grab the encoding if it was added on-the-fly
1064  */
1065  if ((ctxt->encoding != NULL) && (ctxt->myDoc != NULL) &&
1066  (ctxt->myDoc->encoding == NULL)) {
1067  ctxt->myDoc->encoding = ctxt->encoding;
1068  ctxt->encoding = NULL;
1069  }
1070  if ((ctxt->inputTab != NULL) &&
1071  (ctxt->inputNr > 0) && (ctxt->inputTab[0] != NULL) &&
1072  (ctxt->inputTab[0]->encoding != NULL) && (ctxt->myDoc != NULL) &&
1073  (ctxt->myDoc->encoding == NULL)) {
1074  ctxt->myDoc->encoding = xmlStrdup(ctxt->inputTab[0]->encoding);
1075  }
1076  if ((ctxt->charset != XML_CHAR_ENCODING_NONE) && (ctxt->myDoc != NULL) &&
1077  (ctxt->myDoc->charset == XML_CHAR_ENCODING_NONE)) {
1078  ctxt->myDoc->charset = ctxt->charset;
1079  }
1080 }
xmlParserInputPtr * inputTab
Definition: parser.h:202
struct _xmlDtd * intSubset
Definition: tree.h:570
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
int validate
Definition: parser.h:220
int wellFormed
Definition: parser.h:188
xmlDocPtr myDoc
Definition: parser.h:187
const xmlChar * encoding
Definition: parser.h:191
const xmlChar * encoding
Definition: tree.h:574
int charset
Definition: tree.h:578
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
const xmlChar * encoding
Definition: parser.h:73
xmlValidCtxt vctxt
Definition: parser.h:221
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 664 of file SAX2.c.

666 {
667  xmlEntityPtr ent;
669 
670  if (ctx == NULL) return;
671 #ifdef DEBUG_SAX
673  "SAX.xmlSAX2EntityDecl(%s, %d, %s, %s, %s)\n",
674  name, type, publicId, systemId, content);
675 #endif
676  if (ctxt->inSubset == 1) {
677  ent = xmlAddDocEntity(ctxt->myDoc, name, type, publicId,
678  systemId, content);
679  if ((ent == NULL) && (ctxt->pedantic))
680  xmlWarnMsg(ctxt, XML_WAR_ENTITY_REDEFINED,
681  "Entity(%s) already defined in the internal subset\n",
682  name);
683  if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
684  xmlChar *URI;
685  const char *base = NULL;
686 
687  if (ctxt->input != NULL)
688  base = ctxt->input->filename;
689  if (base == NULL)
690  base = ctxt->directory;
691 
692  URI = xmlBuildURI(systemId, (const xmlChar *) base);
693  ent->URI = URI;
694  }
695  } else if (ctxt->inSubset == 2) {
696  ent = xmlAddDtdEntity(ctxt->myDoc, name, type, publicId,
697  systemId, content);
698  if ((ent == NULL) && (ctxt->pedantic) &&
699  (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
700  ctxt->sax->warning(ctxt->userData,
701  "Entity(%s) already defined in the external subset\n", name);
702  if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
703  xmlChar *URI;
704  const char *base = NULL;
705 
706  if (ctxt->input != NULL)
707  base = ctxt->input->filename;
708  if (base == NULL)
709  base = ctxt->directory;
710 
711  URI = xmlBuildURI(systemId, (const xmlChar *) base);
712  ent->URI = URI;
713  }
714  } else {
715  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
716  "SAX.xmlSAX2EntityDecl(%s) called while not in subset\n",
717  name, NULL);
718  }
719 }
int pedantic
Definition: parser.h:255
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
const xmlChar * URI
Definition: entities.h:57
xmlParserInputPtr input
Definition: parser.h:199
content
Definition: atl_ax.c:993
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1884
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlEntityPtr XMLCALL xmlAddDtdEntity(xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content)
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
const char * filename
Definition: parser.h:58
int inSubset
Definition: parser.h:238
XMLPUBFUN xmlEntityPtr XMLCALL xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content)
char * directory
Definition: parser.h:226
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
Definition: name.c:38
void * userData
Definition: parser.h:186
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlParseEntityDecl(), and xmlSAXVersion().

◆ xmlSAX2ExternalSubset()

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

Definition at line 392 of file SAX2.c.

394 {
396  if (ctx == NULL) return;
397 #ifdef DEBUG_SAX
399  "SAX.xmlSAX2ExternalSubset(%s, %s, %s)\n",
400  name, ExternalID, SystemID);
401 #endif
402  if (((ExternalID != NULL) || (SystemID != NULL)) &&
403  (((ctxt->validate) || (ctxt->loadsubset != 0)) &&
404  (ctxt->wellFormed && ctxt->myDoc))) {
405  /*
406  * Try to fetch and parse the external subset.
407  */
408  xmlParserInputPtr oldinput;
409  int oldinputNr;
410  int oldinputMax;
411  xmlParserInputPtr *oldinputTab;
413  xmlCharEncoding enc;
414  int oldcharset;
415  const xmlChar *oldencoding;
416 
417  /*
418  * Ask the Entity resolver to load the damn thing
419  */
420  if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL))
421  input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID,
422  SystemID);
423  if (input == NULL) {
424  return;
425  }
426 
427  xmlNewDtd(ctxt->myDoc, name, ExternalID, SystemID);
428 
429  /*
430  * make sure we won't destroy the main document context
431  */
432  oldinput = ctxt->input;
433  oldinputNr = ctxt->inputNr;
434  oldinputMax = ctxt->inputMax;
435  oldinputTab = ctxt->inputTab;
436  oldcharset = ctxt->charset;
437  oldencoding = ctxt->encoding;
438  ctxt->encoding = NULL;
439 
440  ctxt->inputTab = (xmlParserInputPtr *)
441  xmlMalloc(5 * sizeof(xmlParserInputPtr));
442  if (ctxt->inputTab == NULL) {
443  xmlSAX2ErrMemory(ctxt, "xmlSAX2ExternalSubset");
444  ctxt->input = oldinput;
445  ctxt->inputNr = oldinputNr;
446  ctxt->inputMax = oldinputMax;
447  ctxt->inputTab = oldinputTab;
448  ctxt->charset = oldcharset;
449  ctxt->encoding = oldencoding;
450  return;
451  }
452  ctxt->inputNr = 0;
453  ctxt->inputMax = 5;
454  ctxt->input = NULL;
455  xmlPushInput(ctxt, input);
456 
457  /*
458  * On the fly encoding conversion if needed
459  */
460  if (ctxt->input->length >= 4) {
461  enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
462  xmlSwitchEncoding(ctxt, enc);
463  }
464 
465  if (input->filename == NULL)
466  input->filename = (char *) xmlCanonicPath(SystemID);
467  input->line = 1;
468  input->col = 1;
469  input->base = ctxt->input->cur;
470  input->cur = ctxt->input->cur;
471  input->free = NULL;
472 
473  /*
474  * let's parse that entity knowing it's an external subset.
475  */
476  xmlParseExternalSubset(ctxt, ExternalID, SystemID);
477 
478  /*
479  * Free up the external entities
480  */
481 
482  while (ctxt->inputNr > 1)
483  xmlPopInput(ctxt);
484  xmlFreeInputStream(ctxt->input);
485  xmlFree(ctxt->inputTab);
486 
487  /*
488  * Restore the parsing context of the main entity
489  */
490  ctxt->input = oldinput;
491  ctxt->inputNr = oldinputNr;
492  ctxt->inputMax = oldinputMax;
493  ctxt->inputTab = oldinputTab;
494  ctxt->charset = oldcharset;
495  if ((ctxt->encoding != NULL) &&
496  ((ctxt->dict == NULL) ||
497  (!xmlDictOwns(ctxt->dict, ctxt->encoding))))
498  xmlFree((xmlChar *) ctxt->encoding);
499  ctxt->encoding = oldencoding;
500  /* ctxt->wellFormed = oldwellFormed; */
501  }
502 }
XMLPUBFUN xmlDtdPtr XMLCALL xmlNewDtd(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
xmlParserInputPtr * inputTab
Definition: parser.h:202
XMLPUBFUN int XMLCALL xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
Definition: parser.c:2255
const xmlChar * cur
Definition: parser.h:61
xmlCharEncoding
Definition: encoding.h:58
xmlParserInputPtr input
Definition: parser.h:199
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2372
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
xmlDictPtr dict
Definition: parser.h:263
XMLPUBFUN xmlChar XMLCALL xmlPopInput(xmlParserCtxtPtr ctxt)
Definition: parser.c:2230
int validate
Definition: parser.h:220
int inputMax
Definition: parser.h:201
XMLPUBFUN void XMLCALL xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID)
Definition: parser.c:6927
int wellFormed
Definition: parser.h:188
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:932
xmlDocPtr myDoc
Definition: parser.h:187
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
int loadsubset
Definition: parser.h:258
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1218
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
Definition: name.c:38
void * userData
Definition: parser.h:186
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 289 of file SAX2.c.

290 {
292  if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
293  return(ctxt->input->col);
294 }
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39

Referenced by xmlInitializeGlobalState().

◆ xmlSAX2GetEntity()

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

Definition at line 556 of file SAX2.c.

557 {
560 
561  if (ctx == NULL) return(NULL);
562 #ifdef DEBUG_SAX
564  "SAX.xmlSAX2GetEntity(%s)\n", name);
565 #endif
566 
567  if (ctxt->inSubset == 0) {
569  if (ret != NULL)
570  return(ret);
571  }
572  if ((ctxt->myDoc != NULL) && (ctxt->myDoc->standalone == 1)) {
573  if (ctxt->inSubset == 2) {
574  ctxt->myDoc->standalone = 0;
575  ret = xmlGetDocEntity(ctxt->myDoc, name);
576  ctxt->myDoc->standalone = 1;
577  } else {
578  ret = xmlGetDocEntity(ctxt->myDoc, name);
579  if (ret == NULL) {
580  ctxt->myDoc->standalone = 0;
581  ret = xmlGetDocEntity(ctxt->myDoc, name);
582  if (ret != NULL) {
583  xmlFatalErrMsg(ctxt, XML_ERR_NOT_STANDALONE,
584  "Entity(%s) document marked standalone but requires external subset\n",
585  name, NULL);
586  }
587  ctxt->myDoc->standalone = 1;
588  }
589  }
590  } else {
591  ret = xmlGetDocEntity(ctxt->myDoc, name);
592  }
593  if ((ret != NULL) &&
594  ((ctxt->validate) || (ctxt->replaceEntities)) &&
595  (ret->children == NULL) &&
597  int val;
598 
599  /*
600  * for validation purposes we really need to fetch and
601  * parse the external entity
602  */
603  xmlNodePtr children;
604  unsigned long oldnbent = ctxt->nbentities;
605 
606  val = xmlParseCtxtExternalEntity(ctxt, ret->URI,
607  ret->ExternalID, &children);
608  if (val == 0) {
609  xmlAddChildList((xmlNodePtr) ret, children);
610  } else {
611  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_PROCESSING,
612  "Failure to process entity %s\n", name, NULL);
613  ctxt->validate = 0;
614  return(NULL);
615  }
616  ret->owner = 1;
617  if (ret->checked == 0) {
618  ret->checked = (ctxt->nbentities - oldnbent + 1) * 2;
619  if ((ret->content != NULL) && (xmlStrchr(ret->content, '<')))
620  ret->checked |= 1;
621  }
622  }
623  return(ret);
624 }
XMLPUBFUN int XMLCALL xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL, const xmlChar *ID, xmlNodePtr *lst)
Definition: parser.c:12896
XMLPUBFUN const xmlChar *XMLCALL xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:321
int standalone
Definition: tree.h:564
int replaceEntities
Definition: parser.h:189
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
int validate
Definition: parser.h:220
GLuint GLfloat * val
Definition: glext.h:7180
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetPredefinedEntity(const xmlChar *name)
Definition: tree.h:489
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name)
int ret
xmlDocPtr myDoc
Definition: parser.h:187
int inSubset
Definition: parser.h:238
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
Definition: name.c:38
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur)
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362
unsigned long nbentities
Definition: parser.h:303

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 273 of file SAX2.c.

274 {
276  if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
277  return(ctxt->input->line);
278 }
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39

Referenced by xmlInitializeGlobalState().

◆ xmlSAX2GetParameterEntity()

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

Definition at line 636 of file SAX2.c.

637 {
640 
641  if (ctx == NULL) return(NULL);
642 #ifdef DEBUG_SAX
644  "SAX.xmlSAX2GetParameterEntity(%s)\n", name);
645 #endif
646 
648  return(ret);
649 }
XMLPUBFUN xmlEntityPtr XMLCALL xmlGetParameterEntity(xmlDocPtr doc, const xmlChar *name)
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
int ret
xmlDocPtr myDoc
Definition: parser.h:187
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
Definition: name.c:38
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 257 of file SAX2.c.

258 {
260  if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);
261  return((const xmlChar *) ctxt->input->filename);
262 }
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
unsigned char xmlChar
Definition: xmlstring.h:28
const char * filename
Definition: parser.h:58
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39

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 337 of file SAX2.c.

338 {
340  if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0);
341  return(ctxt->myDoc->extSubset != NULL);
342 }
smooth NULL
Definition: ftsmooth.c:416
xmlDocPtr myDoc
Definition: parser.h:187
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
struct _xmlDtd * extSubset
Definition: tree.h:571

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 321 of file SAX2.c.

322 {
324  if ((ctxt == NULL) || (ctxt->myDoc == NULL)) return(0);
325  return(ctxt->myDoc->intSubset != NULL);
326 }
struct _xmlDtd * intSubset
Definition: tree.h:570
smooth NULL
Definition: ftsmooth.c:416
xmlDocPtr myDoc
Definition: parser.h:187
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39

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 2923 of file SAX2.c.

2924 {
2925  if ((hdlr == NULL) || (hdlr->initialized != 0))
2926  return;
2927 
2929  if (warning == 0)
2930  hdlr->warning = NULL;
2931  else
2932  hdlr->warning = xmlParserWarning;
2933 }
int xmlSAXVersion(xmlSAXHandler *hdlr, int version)
Definition: SAX2.c:2868
warningSAXFunc warning
Definition: parser.h:741
unsigned int initialized
Definition: parser.h:747
static int xmlSAX2DefaultVersionValue
Definition: SAX2.c:2831
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
#define warning(s)
Definition: debug.h:83

◆ xmlSAX2InternalSubset()

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

Definition at line 354 of file SAX2.c.

356 {
358  xmlDtdPtr dtd;
359  if (ctx == NULL) return;
360 #ifdef DEBUG_SAX
362  "SAX.xmlSAX2InternalSubset(%s, %s, %s)\n",
363  name, ExternalID, SystemID);
364 #endif
365 
366  if (ctxt->myDoc == NULL)
367  return;
368  dtd = xmlGetIntSubset(ctxt->myDoc);
369  if (dtd != NULL) {
370  if (ctxt->html)
371  return;
372  xmlUnlinkNode((xmlNodePtr) dtd);
373  xmlFreeDtd(dtd);
374  ctxt->myDoc->intSubset = NULL;
375  }
376  ctxt->myDoc->intSubset =
377  xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
378  if (ctxt->myDoc->intSubset == NULL)
379  xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset");
380 }
struct _xmlDtd * intSubset
Definition: tree.h:570
Definition: tree.h:406
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlFreeDtd(xmlDtdPtr cur)
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
Definition: tree.h:489
xmlDocPtr myDoc
Definition: parser.h:187
XMLPUBFUN xmlDtdPtr XMLCALL xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
XMLPUBFUN xmlDtdPtr XMLCALL xmlGetIntSubset(const xmlDoc *doc)
Definition: name.c:38
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 305 of file SAX2.c.

306 {
308  if ((ctx == NULL) || (ctxt->myDoc == NULL)) return(0);
309  return(ctxt->myDoc->standalone == 1);
310 }
int standalone
Definition: tree.h:564
smooth NULL
Definition: ftsmooth.c:416
xmlDocPtr myDoc
Definition: parser.h:187
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39

Referenced by xmlSAXVersion().

◆ xmlSAX2NotationDecl()

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

Definition at line 848 of file SAX2.c.

850 {
852  xmlNotationPtr nota = NULL;
853 
854  if ((ctxt == NULL) || (ctxt->myDoc == NULL))
855  return;
856 
857 #ifdef DEBUG_SAX
859  "SAX.xmlSAX2NotationDecl(%s, %s, %s)\n", name, publicId, systemId);
860 #endif
861 
862  if ((publicId == NULL) && (systemId == NULL)) {
863  xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
864  "SAX.xmlSAX2NotationDecl(%s) externalID or PublicID missing\n",
865  name, NULL);
866  return;
867  } else if (ctxt->inSubset == 1)
868  nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name,
869  publicId, systemId);
870  else if (ctxt->inSubset == 2)
871  nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, name,
872  publicId, systemId);
873  else {
874  xmlFatalErrMsg(ctxt, XML_ERR_NOTATION_PROCESSING,
875  "SAX.xmlSAX2NotationDecl(%s) called while not in subset\n",
876  name, NULL);
877  return;
878  }
879 #ifdef LIBXML_VALID_ENABLED
880  if (nota == NULL) ctxt->valid = 0;
881  if ((ctxt->validate) && (ctxt->wellFormed) &&
882  (ctxt->myDoc->intSubset != NULL))
883  ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc,
884  nota);
885 #endif /* LIBXML_VALID_ENABLED */
886 }
XMLPUBFUN xmlNotationPtr XMLCALL xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, const xmlChar *PublicID, const xmlChar *SystemID)
Definition: valid.c:2408
struct _xmlDtd * intSubset
Definition: tree.h:570
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
int validate
Definition: parser.h:220
int wellFormed
Definition: parser.h:188
xmlDocPtr myDoc
Definition: parser.h:187
int inSubset
Definition: parser.h:238
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
struct _xmlDtd * extSubset
Definition: tree.h:571
Definition: name.c:38
xmlValidCtxt vctxt
Definition: parser.h:221
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 2680 of file SAX2.c.

2682 {
2684  xmlNodePtr ret;
2686 
2687  if (ctx == NULL) return;
2688  parent = ctxt->node;
2689 #ifdef DEBUG_SAX
2691  "SAX.xmlSAX2ProcessingInstruction(%s, %s)\n", target, data);
2692 #endif
2693 
2694  ret = xmlNewDocPI(ctxt->myDoc, target, data);
2695  if (ret == NULL) return;
2696 
2697  if (ctxt->linenumbers) {
2698  if (ctxt->input != NULL) {
2699  if (ctxt->input->line < 65535)
2700  ret->line = (short) ctxt->input->line;
2701  else
2702  ret->line = 65535;
2703  }
2704  }
2705  if (ctxt->inSubset == 1) {
2707  return;
2708  } else if (ctxt->inSubset == 2) {
2710  return;
2711  }
2712  if (parent == NULL) {
2713 #ifdef DEBUG_SAX_TREE
2715  "Setting PI %s as root\n", target);
2716 #endif
2718  return;
2719  }
2720  if (parent->type == XML_ELEMENT_NODE) {
2721 #ifdef DEBUG_SAX_TREE
2723  "adding PI %s child to %s\n", target, parent->name);
2724 #endif
2726  } else {
2727 #ifdef DEBUG_SAX_TREE
2729  "adding PI %s sibling to ", target);
2730  xmlDebugDumpOneNode(stderr, parent, 0);
2731 #endif
2733  }
2734 }
struct _xmlDtd * intSubset
Definition: tree.h:570
XMLPUBFUN xmlNodePtr XMLCALL xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem)
xmlParserInputPtr input
Definition: parser.h:199
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
int linenumbers
Definition: parser.h:259
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
xmlNodePtr node
Definition: parser.h:205
r parent
Definition: btrfs.c:2944
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocPI(xmlDocPtr doc, const xmlChar *name, const xmlChar *content)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: tree.h:489
int ret
xmlDocPtr myDoc
Definition: parser.h:187
int inSubset
Definition: parser.h:238
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
struct _xmlDtd * extSubset
Definition: tree.h:571
GLenum target
Definition: glext.h:7315
FILE * stderr
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlSAXVersion().

◆ xmlSAX2Reference()

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

Definition at line 2502 of file SAX2.c.

2503 {
2505  xmlNodePtr ret;
2506 
2507  if (ctx == NULL) return;
2508 #ifdef DEBUG_SAX
2510  "SAX.xmlSAX2Reference(%s)\n", name);
2511 #endif
2512  if (name[0] == '#')
2513  ret = xmlNewCharRef(ctxt->myDoc, name);
2514  else
2515  ret = xmlNewReference(ctxt->myDoc, name);
2516 #ifdef DEBUG_SAX_TREE
2518  "add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
2519 #endif
2520  if (xmlAddChild(ctxt->node, ret) == NULL) {
2521  xmlFreeNode(ret);
2522  }
2523 }
const xmlChar * name
Definition: tree.h:492
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
xmlNodePtr node
Definition: parser.h:205
Definition: tree.h:489
int ret
xmlDocPtr myDoc
Definition: parser.h:187
XMLPUBFUN xmlNodePtr XMLCALL xmlNewCharRef(xmlDocPtr doc, const xmlChar *name)
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
Definition: name.c:38
XMLPUBFUN xmlNodePtr XMLCALL xmlNewReference(const xmlDoc *doc, const xmlChar *name)
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 519 of file SAX2.c.

520 {
523  xmlChar *URI;
524  const char *base = NULL;
525 
526  if (ctx == NULL) return(NULL);
527  if (ctxt->input != NULL)
528  base = ctxt->input->filename;
529  if (base == NULL)
530  base = ctxt->directory;
531 
532  URI = xmlBuildURI(systemId, (const xmlChar *) base);
533 
534 #ifdef DEBUG_SAX
536  "SAX.xmlSAX2ResolveEntity(%s, %s)\n", publicId, systemId);
537 #endif
538 
539  ret = xmlLoadExternalEntity((const char *) URI,
540  (const char *) publicId, ctxt);
541  if (URI != NULL)
542  xmlFree(URI);
543  return(ret);
544 }
xmlParserInputPtr input
Definition: parser.h:199
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1884
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
const char * filename
Definition: parser.h:58
char * directory
Definition: parser.h:226
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 983 of file SAX2.c.

984 {
986  xmlDocPtr doc;
987 
988  if (ctx == NULL) return;
989 
990 #ifdef DEBUG_SAX
992  "SAX.xmlSAX2StartDocument()\n");
993 #endif
994  if (ctxt->html) {
995 #ifdef LIBXML_HTML_ENABLED
996  if (ctxt->myDoc == NULL)
997  ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
998  if (ctxt->myDoc == NULL) {
999  xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
1000  return;
1001  }
1002  ctxt->myDoc->properties = XML_DOC_HTML;
1003  ctxt->myDoc->parseFlags = ctxt->options;
1004 #else
1006  "libxml2 built without HTML support\n");
1007  ctxt->errNo = XML_ERR_INTERNAL_ERROR;
1008  ctxt->instate = XML_PARSER_EOF;
1009  ctxt->disableSAX = 1;
1010  return;
1011 #endif
1012  } else {
1013  doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
1014  if (doc != NULL) {
1015  doc->properties = 0;
1016  if (ctxt->options & XML_PARSE_OLD10)
1017  doc->properties |= XML_DOC_OLD10;
1018  doc->parseFlags = ctxt->options;
1019  if (ctxt->encoding != NULL)
1020  doc->encoding = xmlStrdup(ctxt->encoding);
1021  else
1022  doc->encoding = NULL;
1023  doc->standalone = ctxt->standalone;
1024  } else {
1025  xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
1026  return;
1027  }
1028  if ((ctxt->dictNames) && (doc != NULL)) {
1029  doc->dict = ctxt->dict;
1030  xmlDictReference(doc->dict);
1031  }
1032  }
1033  if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) &&
1034  (ctxt->input != NULL) && (ctxt->input->filename != NULL)) {
1035  ctxt->myDoc->URL = xmlPathToURI((const xmlChar *)ctxt->input->filename);
1036  if (ctxt->myDoc->URL == NULL)
1037  xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
1038  }
1039 }
XMLPUBFUN xmlChar *XMLCALL xmlPathToURI(const xmlChar *path)
Definition: uri.c:2513
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:645
xmlParserInputState instate
Definition: parser.h:223
int properties
Definition: tree.h:584
const xmlChar * URL
Definition: tree.h:577
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
int standalone
Definition: tree.h:564
int standalone
Definition: parser.h:192
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
xmlDictPtr dict
Definition: parser.h:263
xmlDocPtr myDoc
Definition: parser.h:187
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
const xmlChar * version
Definition: parser.h:190
int dictNames
Definition: parser.h:292
const xmlChar * encoding
Definition: tree.h:574
const char * filename
Definition: parser.h:58
int parseFlags
Definition: tree.h:582
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
Definition: tree.h:551
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
struct _xmlDict * dict
Definition: tree.h:580
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 informations for the element, as well as the new namespace declarations on the element.

Definition at line 2210 of file SAX2.c.

2219 {
2221  xmlNodePtr ret;
2223  xmlNsPtr last = NULL, ns;
2224  const xmlChar *uri, *pref;
2225  xmlChar *lname = NULL;
2226  int i, j;
2227 
2228  if (ctx == NULL) return;
2229  parent = ctxt->node;
2230  /*
2231  * First check on validity:
2232  */
2233  if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
2234  ((ctxt->myDoc->intSubset == NULL) ||
2235  ((ctxt->myDoc->intSubset->notations == NULL) &&
2236  (ctxt->myDoc->intSubset->elements == NULL) &&
2237  (ctxt->myDoc->intSubset->attributes == NULL) &&
2238  (ctxt->myDoc->intSubset->entities == NULL)))) {
2239  xmlErrValid(ctxt, XML_DTD_NO_DTD,
2240  "Validation failed: no DTD found !", NULL, NULL);
2241  ctxt->validate = 0;
2242  }
2243 
2244  /*
2245  * Take care of the rare case of an undefined namespace prefix
2246  */
2247  if ((prefix != NULL) && (URI == NULL)) {
2248  if (ctxt->dictNames) {
2249  const xmlChar *fullname;
2250 
2251  fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
2252  if (fullname != NULL)
2253  localname = fullname;
2254  } else {
2255  lname = xmlBuildQName(localname, prefix, NULL, 0);
2256  }
2257  }
2258  /*
2259  * allocate the node
2260  */
2261  if (ctxt->freeElems != NULL) {
2262  ret = ctxt->freeElems;
2263  ctxt->freeElems = ret->next;
2264  ctxt->freeElemsNr--;
2265  memset(ret, 0, sizeof(xmlNode));
2266  ret->doc = ctxt->myDoc;
2267  ret->type = XML_ELEMENT_NODE;
2268 
2269  if (ctxt->dictNames)
2270  ret->name = localname;
2271  else {
2272  if (lname == NULL)
2273  ret->name = xmlStrdup(localname);
2274  else
2275  ret->name = lname;
2276  if (ret->name == NULL) {
2277  xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2278  return;
2279  }
2280  }
2283  } else {
2284  if (ctxt->dictNames)
2286  (xmlChar *) localname, NULL);
2287  else if (lname == NULL)
2288  ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
2289  else
2291  (xmlChar *) lname, NULL);
2292  if (ret == NULL) {
2293  xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2294  return;
2295  }
2296  }
2297  if (ctxt->linenumbers) {
2298  if (ctxt->input != NULL) {
2299  if (ctxt->input->line < 65535)
2300  ret->line = (short) ctxt->input->line;
2301  else
2302  ret->line = 65535;
2303  }
2304  }
2305 
2306  if (parent == NULL) {
2308  }
2309  /*
2310  * Build the namespace list
2311  */
2312  for (i = 0,j = 0;j < nb_namespaces;j++) {
2313  pref = namespaces[i++];
2314  uri = namespaces[i++];
2315  ns = xmlNewNs(NULL, uri, pref);
2316  if (ns != NULL) {
2317  if (last == NULL) {
2318  ret->nsDef = last = ns;
2319  } else {
2320  last->next = ns;
2321  last = ns;
2322  }
2323  if ((URI != NULL) && (prefix == pref))
2324  ret->ns = ns;
2325  } else {
2326  /*
2327  * any out of memory error would already have been raised
2328  * but we can't be guaranteed it's the actual error due to the
2329  * API, best is to skip in this case
2330  */
2331  continue;
2332  }
2333 #ifdef LIBXML_VALID_ENABLED
2334  if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
2335  ctxt->myDoc && ctxt->myDoc->intSubset) {
2336  ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
2337  ret, prefix, ns, uri);
2338  }
2339 #endif /* LIBXML_VALID_ENABLED */
2340  }
2341  ctxt->nodemem = -1;
2342 
2343  /*
2344  * We are parsing a new node.
2345  */
2346  if (nodePush(ctxt, ret) < 0) {
2347  xmlUnlinkNode(ret);
2348  xmlFreeNode(ret);
2349  return;
2350  }
2351 
2352  /*
2353  * Link the child element
2354  */
2355  if (parent != NULL) {
2356  if (parent->type == XML_ELEMENT_NODE) {
2358  } else {
2360  }
2361  }
2362 
2363  /*
2364  * Insert the defaulted attributes from the DTD only if requested:
2365  */
2366  if ((nb_defaulted != 0) &&
2367  ((ctxt->loadsubset & XML_COMPLETE_ATTRS) == 0))
2368  nb_attributes -= nb_defaulted;
2369 
2370  /*
2371  * Search the namespace if it wasn't already found
2372  * Note that, if prefix is NULL, this searches for the default Ns
2373  */
2374  if ((URI != NULL) && (ret->ns == NULL)) {
2375  ret->ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
2376  if ((ret->ns == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
2377  ret->ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
2378  }
2379  if (ret->ns == NULL) {
2380  ns = xmlNewNs(ret, NULL, prefix);
2381  if (ns == NULL) {
2382 
2383  xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
2384  return;
2385  }
2386  if (prefix != NULL)
2387  xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
2388  "Namespace prefix %s was not found\n",
2389  prefix, NULL);
2390  else
2391  xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
2392  "Namespace default prefix was not found\n",
2393  NULL, NULL);
2394  }
2395  }
2396 
2397  /*
2398  * process all the other attributes
2399  */
2400  if (nb_attributes > 0) {
2401  for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
2402  /*
2403  * Handle the rare case of an undefined attribute prefix
2404  */
2405  if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
2406  if (ctxt->dictNames) {
2407  const xmlChar *fullname;
2408 
2409  fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
2410  attributes[j]);
2411  if (fullname != NULL) {
2413  attributes[j+3], attributes[j+4]);
2414  continue;
2415  }
2416  } else {
2417  lname = xmlBuildQName(attributes[j], attributes[j+1],
2418  NULL, 0);
2419  if (lname != NULL) {
2420  xmlSAX2AttributeNs(ctxt, lname, NULL,
2421  attributes[j+3], attributes[j+4]);
2422  xmlFree(lname);
2423  continue;
2424  }
2425  }
2426  }
2427  xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
2428  attributes[j+3], attributes[j+4]);
2429  }
2430  }
2431 
2432 #ifdef LIBXML_VALID_ENABLED
2433  /*
2434  * If it's the Document root, finish the DTD validation and
2435  * check the document root element for validity
2436  */
2437  if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
2438  int chk;
2439 
2440  chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
2441  if (chk <= 0)
2442  ctxt->valid = 0;
2443  if (chk < 0)
2444  ctxt->wellFormed = 0;
2445  ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
2446  ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
2447  }
2448 #endif /* LIBXML_VALID_ENABLED */
2449 }
XMLPUBFUN xmlChar *XMLCALL xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len)
struct _xmlDtd * intSubset
Definition: tree.h:570
unsigned int finishDtd
Definition: valid.h:93
POINT last
Definition: font.c:46
const char * uri
Definition: sec_mgr.c:1588
Definition: tree.h:389
static void xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt, const xmlChar *localname, const xmlChar *prefix, const xmlChar *value, const xmlChar *valueend)
Definition: SAX2.c:1980
XMLPUBFUN xmlNodePtr XMLCALL xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem)
XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue
Definition: globals.h:476
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns, xmlChar *name, const xmlChar *content)
xmlParserInputPtr input
Definition: parser.h:199
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
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
int linenumbers
Definition: parser.h:259
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
int __xmlRegisterCallbacks
Definition: tree.c:53
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
xmlDictPtr dict
Definition: parser.h:263
int validate
Definition: parser.h:220
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
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
int wellFormed
Definition: parser.h:188
xmlNodePtr node
Definition: parser.h:205
r parent
Definition: btrfs.c:2944
int freeElemsNr
Definition: parser.h:293
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN int XMLCALL nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
Definition: parser.c:1776
Definition: tree.h:489
int ret
xmlDocPtr myDoc
Definition: parser.h:187
const char * fullname
Definition: shader.c:1766
Definition: mxnamespace.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
int loadsubset
Definition: parser.h:258
XMLPUBFUN const xmlChar *XMLCALL xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name)
Definition: dict.c:1113
int dictNames
Definition: parser.h:292
XMLPUBFUN xmlNsPtr XMLCALL xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix)
#define XML_COMPLETE_ATTRS
Definition: parser.h:148
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content)
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
struct _xmlDtd * extSubset
Definition: tree.h:571
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
xmlValidCtxt vctxt
Definition: parser.h:221
#define memset(x, y, z)
Definition: compat.h:39
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
xmlNodePtr freeElems
Definition: parser.h:294

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 899 of file SAX2.c.

902 {
903  xmlEntityPtr ent;
905  if (ctx == NULL) return;
906 #ifdef DEBUG_SAX
908  "SAX.xmlSAX2UnparsedEntityDecl(%s, %s, %s, %s)\n",
909  name, publicId, systemId, notationName);
910 #endif
911  if (ctxt->inSubset == 1) {
912  ent = xmlAddDocEntity(ctxt->myDoc, name,
914  publicId, systemId, notationName);
915  if ((ent == NULL) && (ctxt->pedantic) &&
916  (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
917  ctxt->sax->warning(ctxt->userData,
918  "Entity(%s) already defined in the internal subset\n", name);
919  if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
920  xmlChar *URI;
921  const char *base = NULL;
922 
923  if (ctxt->input != NULL)
924  base = ctxt->input->filename;
925  if (base == NULL)
926  base = ctxt->directory;
927 
928  URI = xmlBuildURI(systemId, (const xmlChar *) base);
929  ent->URI = URI;
930  }
931  } else if (ctxt->inSubset == 2) {
932  ent = xmlAddDtdEntity(ctxt->myDoc, name,
934  publicId, systemId, notationName);
935  if ((ent == NULL) && (ctxt->pedantic) &&
936  (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
937  ctxt->sax->warning(ctxt->userData,
938  "Entity(%s) already defined in the external subset\n", name);
939  if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
940  xmlChar *URI;
941  const char *base = NULL;
942 
943  if (ctxt->input != NULL)
944  base = ctxt->input->filename;
945  if (base == NULL)
946  base = ctxt->directory;
947 
948  URI = xmlBuildURI(systemId, (const xmlChar *) base);
949  ent->URI = URI;
950  }
951  } else {
952  xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
953  "SAX.xmlSAX2UnparsedEntityDecl(%s) called while not in subset\n",
954  name, NULL);
955  }
956 }
int pedantic
Definition: parser.h:255
const xmlChar * URI
Definition: entities.h:57
xmlParserInputPtr input
Definition: parser.h:199
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1884
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlEntityPtr XMLCALL xmlAddDtdEntity(xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content)
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
const char * filename
Definition: parser.h:58
int inSubset
Definition: parser.h:238
XMLPUBFUN xmlEntityPtr XMLCALL xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content)
char * directory
Definition: parser.h:226
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
Definition: name.c:38
void * userData
Definition: parser.h:186
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 2868 of file SAX2.c.

2869 {
2870  if (hdlr == NULL) return(-1);
2871  if (version == 2) {
2872  hdlr->startElement = NULL;
2873  hdlr->endElement = NULL;
2876  hdlr->serror = NULL;
2877  hdlr->initialized = XML_SAX2_MAGIC;
2878 #ifdef LIBXML_SAX1_ENABLED
2879  } else if (version == 1) {
2880  hdlr->startElement = xmlSAX2StartElement;
2881  hdlr->endElement = xmlSAX2EndElement;
2882  hdlr->initialized = 1;
2883 #endif /* LIBXML_SAX1_ENABLED */
2884  } else
2885  return(-1);
2892  hdlr->getEntity = xmlSAX2GetEntity;
2894  hdlr->entityDecl = xmlSAX2EntityDecl;
2902  hdlr->reference = xmlSAX2Reference;
2903  hdlr->characters = xmlSAX2Characters;
2904  hdlr->cdataBlock = xmlSAX2CDataBlock;
2907  hdlr->comment = xmlSAX2Comment;
2908  hdlr->warning = xmlParserWarning;
2909  hdlr->error = xmlParserError;
2910  hdlr->fatalError = xmlParserError;
2911 
2912  return(0);
2913 }
internalSubsetSAXFunc internalSubset
Definition: parser.h:720
processingInstructionSAXFunc processingInstruction
Definition: parser.h:739
endElementNsSAX2Func endElementNs
Definition: parser.h:751
xmlEntityPtr xmlSAX2GetEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:556
xmlParserInputPtr xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
Definition: SAX2.c:519
void xmlSAX2EndElementNs(void *ctx, const xmlChar *localname ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED, const xmlChar *URI ATTRIBUTE_UNUSED)
Definition: SAX2.c:2462
endDocumentSAXFunc endDocument
Definition: parser.h:733
#define XML_SAX2_MAGIC
Definition: parser.h:671
setDocumentLocatorSAXFunc setDocumentLocator
Definition: parser.h:731
entityDeclSAXFunc entityDecl
Definition: parser.h:726
void xmlSAX2NotationDecl(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
Definition: SAX2.c:848
void xmlSAX2SetDocumentLocator(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
Definition: SAX2.c:967
void xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
Definition: SAX2.c:2806
int xmlSAX2IsStandalone(void *ctx)
Definition: SAX2.c:305
warningSAXFunc warning
Definition: parser.h:741
resolveEntitySAXFunc resolveEntity
Definition: parser.h:724
unsigned int initialized
Definition: parser.h:747
isStandaloneSAXFunc isStandalone
Definition: parser.h:721
void xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
Definition: SAX2.c:734
void xmlSAX2ElementDecl(void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)
Definition: SAX2.c:802
startElementSAXFunc startElement
Definition: parser.h:734
void xmlSAX2Comment(void *ctx, const xmlChar *value)
Definition: SAX2.c:2744
attributeDeclSAXFunc attributeDecl
Definition: parser.h:728
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:66
void xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
Definition: SAX2.c:392
cdataBlockSAXFunc cdataBlock
Definition: parser.h:745
endElementSAXFunc endElement
Definition: parser.h:735
void xmlSAX2Reference(void *ctx, const xmlChar *name)
Definition: SAX2.c:2502
ignorableWhitespaceSAXFunc ignorableWhitespace
Definition: parser.h:738
void xmlSAX2InternalSubset(void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
Definition: SAX2.c:354
hasInternalSubsetSAXFunc hasInternalSubset
Definition: parser.h:722
XMLPUBFUN void XMLCDECL xmlParserError(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
unparsedEntityDeclSAXFunc unparsedEntityDecl
Definition: parser.h:730
void xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
Definition: SAX2.c:2534
void xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Definition: SAX2.c:664
void xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target, const xmlChar *data)
Definition: SAX2.c:2680
void xmlSAX2EndDocument(void *ctx)
Definition: SAX2.c:1048
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:2210
void xmlSAX2StartDocument(void *ctx)
Definition: SAX2.c:983
xmlEntityPtr xmlSAX2GetParameterEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:636
xmlStructuredErrorFunc serror
Definition: parser.h:752
fatalErrorSAXFunc fatalError
Definition: parser.h:743
errorSAXFunc error
Definition: parser.h:742
getEntitySAXFunc getEntity
Definition: parser.h:725
notationDeclSAXFunc notationDecl
Definition: parser.h:727
elementDeclSAXFunc elementDecl
Definition: parser.h:729
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
externalSubsetSAXFunc externalSubset
Definition: parser.h:746
startDocumentSAXFunc startDocument
Definition: parser.h:732
getParameterEntitySAXFunc getParameterEntity
Definition: parser.h:744
commentSAXFunc comment
Definition: parser.h:740
charactersSAXFunc characters
Definition: parser.h:737
int xmlSAX2HasInternalSubset(void *ctx)
Definition: SAX2.c:321
int xmlSAX2HasExternalSubset(void *ctx)
Definition: SAX2.c:337
hasExternalSubsetSAXFunc hasExternalSubset
Definition: parser.h:723
void xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
Definition: SAX2.c:899
referenceSAXFunc reference
Definition: parser.h:736
startElementNsSAX2Func startElementNs
Definition: parser.h:750

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