ReactOS 0.4.16-dev-2207-geb15453
SAX2.c File Reference
#include "libxml.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <stddef.h>
#include <libxml/SAX2.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/valid.h>
#include <libxml/entities.h>
#include <libxml/xmlerror.h>
#include <libxml/debugXML.h>
#include <libxml/xmlIO.h>
#include <libxml/uri.h>
#include <libxml/HTMLtree.h>
#include "private/error.h"
#include "private/parser.h"
#include "private/tree.h"
Include dependency graph for SAX2.c:

Go to the source code of this file.

Macros

#define IN_LIBXML
 
#define TODO
 

Functions

static void LIBXML_ATTR_FORMAT (2, 0)
 
static void LIBXML_ATTR_FORMAT (3, 0)
 
const xmlCharxmlSAX2GetPublicId (void *ctx ATTRIBUTE_UNUSED)
 
const xmlCharxmlSAX2GetSystemId (void *ctx)
 
int xmlSAX2GetLineNumber (void *ctx)
 
int xmlSAX2GetColumnNumber (void *ctx)
 
int xmlSAX2IsStandalone (void *ctx)
 
int xmlSAX2HasInternalSubset (void *ctx)
 
int xmlSAX2HasExternalSubset (void *ctx)
 
: the root element name

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

@ExternalID: the external ID @SystemID: the SYSTEM ID (e.g. filename or URL)

Callback on external subset declaration.

void xmlSAX2InternalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
void xmlSAX2ExternalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
xmlParserInputPtr xmlSAX2ResolveEntity (void *ctx, const xmlChar *publicId, const xmlChar *systemId)
 
: The entity name

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

Get a parameter entity by name

Returns the xmlEntityPtr if found.

xmlEntityPtr xmlSAX2GetEntity (void *ctx, const xmlChar *name)
 
xmlEntityPtr xmlSAX2GetParameterEntity (void *ctx, const xmlChar *name)
 
: the element name

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

@type: the element type @content: the element value tree

An element definition has been parsed

void xmlSAX2ElementDecl (void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)
 
: The name of the notation

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

@publicId: The public ID of the entity @systemId: The system ID of the entity

What to do when a notation declaration has been parsed.

void xmlSAX2NotationDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 
: The name of the entity

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

@publicId: The public ID of the entity @systemId: The system ID of the entity @notationName: the name of the notation

What to do when an unparsed entity declaration is parsed

void xmlSAX2UnparsedEntityDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
 
void xmlSAX2SetDocumentLocator (void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
 
void xmlSAX2StartDocument (void *ctx)
 
void xmlSAX2EndDocument (void *ctx)
 
static xmlNodePtr xmlSAX2TextNode (xmlParserCtxtPtr ctxt, const xmlChar *str, int len)
 
static xmlAttrPtr xmlSAX2AttributeNs (xmlParserCtxtPtr ctxt, const xmlChar *localname, const xmlChar *prefix, const xmlChar *value, const xmlChar *valueend)
 
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)
 
void xmlSAX2EndElementNs (void *ctx, const xmlChar *localname ATTRIBUTE_UNUSED, const xmlChar *prefix ATTRIBUTE_UNUSED, const xmlChar *URI ATTRIBUTE_UNUSED)
 

: the entity name

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

called when an entity xmlSAX2Reference is detected.

static int xmlSAX2DefaultVersionValue = 2
 
void xmlSAX2EntityDecl (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
 
void xmlSAX2AttributeDecl (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
 
void xmlSAX2Reference (void *ctx, const xmlChar *name)
 
static void xmlSAX2Text (xmlParserCtxtPtr ctxt, const xmlChar *ch, int len, xmlElementType type)
 
void xmlSAX2Characters (void *ctx, const xmlChar *ch, int len)
 
void xmlSAX2IgnorableWhitespace (void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED)
 
void xmlSAX2ProcessingInstruction (void *ctx, const xmlChar *target, const xmlChar *data)
 
void xmlSAX2Comment (void *ctx, const xmlChar *value)
 
void xmlSAX2CDataBlock (void *ctx, const xmlChar *value, int len)
 
int xmlSAXVersion (xmlSAXHandler *hdlr, int version)
 
void xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, int warning)
 
void xmlDefaultSAXHandlerInit (void)
 

Macro Definition Documentation

◆ IN_LIBXML

#define IN_LIBXML

Definition at line 10 of file SAX2.c.

◆ TODO

#define TODO
Value:
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
void * xmlGenericErrorContext
Definition: globals.c:410
xmlGenericErrorFunc xmlGenericError
Definition: globals.c:396

TODO:

macro to flag unimplemented blocks XML_CATALOG_PREFER user env to select between system/public preferred option. C.f. Richard Tobin richa.nosp@m.rd@c.nosp@m.ogsci.nosp@m..ed..nosp@m.ac.uk

‍Just FYI, I am using an environment variable XML_CATALOG_PREFER with values "system" and "public". I have made the default be "system" to match yours.

Definition at line 44 of file SAX2.c.

Function Documentation

◆ LIBXML_ATTR_FORMAT() [1/2]

static void LIBXML_ATTR_FORMAT ( ,
 
)
static

Definition at line 54 of file SAX2.c.

55 {
57 const char *str1 = "out of memory\n";
58
59 if (ctxt != NULL) {
60 ctxt->errNo = XML_ERR_NO_MEMORY;
61 if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
62 schannel = ctxt->sax->serror;
63 __xmlRaiseError(schannel,
64 ctxt->vctxt.error, ctxt->vctxt.userData,
66 XML_ERR_ERROR, NULL, 0, (const char *) str1,
67 NULL, NULL, 0, 0,
68 msg, (const char *) str1, NULL);
69 ctxt->errNo = XML_ERR_NO_MEMORY;
70 ctxt->instate = XML_PARSER_EOF;
71 ctxt->disableSAX = 1;
72 } else {
73 __xmlRaiseError(schannel,
74 NULL, NULL,
76 XML_ERR_ERROR, NULL, 0, (const char *) str1,
77 NULL, NULL, 0, 0,
78 msg, (const char *) str1, NULL);
79 }
80}
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
@ XML_PARSER_EOF
Definition: parser.h:116
#define XML_SAX2_MAGIC
Definition: parser.h:687
XML_HIDDEN void __xmlRaiseError(xmlStructuredErrorFunc schannel, xmlGenericErrorFunc channel, void *data, void *ctx, void *nod, int domain, int code, xmlErrorLevel level, const char *file, int line, const char *str1, const char *str2, const char *str3, int int1, int col, const char *msg,...) LIBXML_ATTR_FORMAT(16
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35
void(*) typedef void(* xmlStructuredErrorFunc)(void *userData, const xmlError *error)
Definition: xmlerror.h:859
@ XML_ERR_ERROR
Definition: xmlerror.h:27
@ XML_FROM_PARSER
Definition: xmlerror.h:38
@ XML_ERR_NO_MEMORY
Definition: xmlerror.h:102

◆ LIBXML_ATTR_FORMAT() [2/2]

static void LIBXML_ATTR_FORMAT ( ,
 
)
static

xmlValidError: @ctxt: an XML validation parser context @error: the error number @msg: the error message @str1: extra data @str2: extra data

Handle a validation error

xmlFatalErrMsg: @ctxt: an XML parser context @error: the error number @msg: the error message @str1: an error string @str2: an error string

Handle a fatal parser error, i.e. violating Well-Formedness constraints

xmlWarnMsg: @ctxt: an XML parser context @error: the error number @msg: the error message @str1: an error string @str2: an error string

Handle a parser warning

xmlNsWarnMsg: @ctxt: an XML parser context @error: the error number @msg: the error message @str1: an error string

Handle a namespace warning

Definition at line 92 of file SAX2.c.

95{
97
98 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
99 (ctxt->instate == XML_PARSER_EOF))
100 return;
101 if (ctxt != NULL) {
102 ctxt->errNo = error;
103 if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
104 schannel = ctxt->sax->serror;
105 __xmlRaiseError(schannel,
106 ctxt->vctxt.error, ctxt->vctxt.userData,
107 ctxt, NULL, XML_FROM_DTD, error,
108 XML_ERR_ERROR, NULL, 0, (const char *) str1,
109 (const char *) str2, NULL, 0, 0,
110 msg, (const char *) str1, (const char *) str2);
111 ctxt->valid = 0;
112 } else {
113 __xmlRaiseError(schannel,
114 NULL, NULL,
115 ctxt, NULL, XML_FROM_DTD, error,
116 XML_ERR_ERROR, NULL, 0, (const char *) str1,
117 (const char *) str2, NULL, 0, 0,
118 msg, (const char *) str1, (const char *) str2);
119 }
120}
#define error(str)
Definition: mkdosfs.c:1605
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
@ XML_FROM_DTD
Definition: xmlerror.h:41

◆ xmlDefaultSAXHandlerInit()

void xmlDefaultSAXHandlerInit ( void  )

xmlDefaultSAXHandlerInit:

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

Initialize the default SAX2 handler

Definition at line 2783 of file SAX2.c.

2784{
2785}

◆ xmlSAX2AttributeDecl()

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

Definition at line 653 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2AttributeNs()

static xmlAttrPtr xmlSAX2AttributeNs ( xmlParserCtxtPtr  ctxt,
const xmlChar localname,
const xmlChar prefix,
const xmlChar value,
const xmlChar valueend 
)
static

xmlSAX2AttributeNs: @ctx: the user data (XML parser context) @localname: the local name of the attribute @prefix: the attribute namespace prefix if available @URI: the attribute namespace name if available @value: Start of the attribute value @valueend: end of the attribute value

Handle an attribute that has been read by the parser. The default handling is to convert the attribute into an DOM subtree and past it in a new xmlAttr element added to the element.

Returns the new attribute or NULL in case of error.

Definition at line 1852 of file SAX2.c.

1857{
1858 xmlAttrPtr ret;
1859 xmlNsPtr namespace = NULL;
1860 xmlChar *dup = NULL;
1861
1862 /*
1863 * Note: if prefix == NULL, the attribute is not in the default namespace
1864 */
1865 if (prefix != NULL) {
1866 namespace = xmlParserNsLookupSax(ctxt, prefix);
1867 if ((namespace == NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
1868 namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, prefix);
1869 }
1870 }
1871
1872 /*
1873 * allocate the node
1874 */
1875 if (ctxt->freeAttrs != NULL) {
1876 ret = ctxt->freeAttrs;
1877 ctxt->freeAttrs = ret->next;
1878 ctxt->freeAttrsNr--;
1879 } else {
1880 ret = xmlMalloc(sizeof(*ret));
1881 if (ret == NULL) {
1882 xmlSAX2ErrMemory(ctxt, NULL);
1883 return(NULL);
1884 }
1885 }
1886
1887 memset(ret, 0, sizeof(xmlAttr));
1888 ret->type = XML_ATTRIBUTE_NODE;
1889
1890 /*
1891 * xmlParseBalancedChunkMemoryRecover had a bug that could result in
1892 * a mismatch between ctxt->node->doc and ctxt->myDoc. We use
1893 * ctxt->node->doc here, but we should somehow make sure that the
1894 * document pointers match.
1895 */
1896
1897 /* assert(ctxt->node->doc == ctxt->myDoc); */
1898
1899 ret->parent = ctxt->node;
1900 ret->doc = ctxt->node->doc;
1901 ret->ns = namespace;
1902
1903 if (ctxt->dictNames)
1904 ret->name = localname;
1905 else
1906 ret->name = xmlStrdup(localname);
1907
1909 xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
1910
1911 if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
1912 xmlNodePtr tmp;
1913
1914 /*
1915 * We know that if there is an entity reference, then
1916 * the string has been dup'ed and terminates with 0
1917 * otherwise with ' or "
1918 */
1919 if (*valueend != 0) {
1920 tmp = xmlSAX2TextNode(ctxt, value, valueend - value);
1921 ret->children = tmp;
1922 ret->last = tmp;
1923 if (tmp != NULL) {
1924 tmp->doc = ret->doc;
1925 tmp->parent = (xmlNodePtr) ret;
1926 }
1927 } else {
1928 ret->children = xmlStringLenGetNodeList(ctxt->myDoc, value,
1929 valueend - value);
1930 tmp = ret->children;
1931 while (tmp != NULL) {
1932 tmp->doc = ret->doc;
1933 tmp->parent = (xmlNodePtr) ret;
1934 if (tmp->next == NULL)
1935 ret->last = tmp;
1936 tmp = tmp->next;
1937 }
1938 }
1939 } else if (value != NULL) {
1940 xmlNodePtr tmp;
1941
1942 tmp = xmlSAX2TextNode(ctxt, value, valueend - value);
1943 ret->children = tmp;
1944 ret->last = tmp;
1945 if (tmp != NULL) {
1946 tmp->doc = ret->doc;
1947 tmp->parent = (xmlNodePtr) ret;
1948 }
1949 }
1950
1951#ifdef LIBXML_VALID_ENABLED
1952 if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
1953 ctxt->myDoc && ctxt->myDoc->intSubset) {
1954 /*
1955 * If we don't substitute entities, the validation should be
1956 * done on a value with replaced entities anyway.
1957 */
1958 if (!ctxt->replaceEntities) {
1959 dup = xmlSAX2DecodeAttrEntities(ctxt, value, valueend);
1960 if (dup == NULL) {
1961 if (*valueend == 0) {
1962 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
1963 ctxt->myDoc, ctxt->node, ret, value);
1964 } else {
1965 /*
1966 * That should already be normalized.
1967 * cheaper to finally allocate here than duplicate
1968 * entry points in the full validation code
1969 */
1970 dup = xmlStrndup(value, valueend - value);
1971
1972 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
1973 ctxt->myDoc, ctxt->node, ret, dup);
1974 }
1975 } else {
1976 /*
1977 * dup now contains a string of the flattened attribute
1978 * content with entities substituted. Check if we need to
1979 * apply an extra layer of normalization.
1980 * It need to be done twice ... it's an extra burden related
1981 * to the ability to keep references in attributes
1982 */
1983 if (ctxt->attsSpecial != NULL) {
1984 xmlChar *nvalnorm;
1985 xmlChar fn[50];
1987
1988 fullname = xmlBuildQName(localname, prefix, fn, 50);
1989 if (fullname != NULL) {
1990 ctxt->vctxt.valid = 1;
1991 nvalnorm = xmlValidCtxtNormalizeAttributeValue(
1992 &ctxt->vctxt, ctxt->myDoc,
1993 ctxt->node, fullname, dup);
1994 if (ctxt->vctxt.valid != 1)
1995 ctxt->valid = 0;
1996
1997 if ((fullname != fn) && (fullname != localname))
1999 if (nvalnorm != NULL) {
2000 xmlFree(dup);
2001 dup = nvalnorm;
2002 }
2003 }
2004 }
2005
2006 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
2007 ctxt->myDoc, ctxt->node, ret, dup);
2008 }
2009 } else {
2010 /*
2011 * if entities already have been substituted, then
2012 * the attribute as passed is already normalized
2013 */
2014 dup = xmlStrndup(value, valueend - value);
2015
2016 ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
2017 ctxt->myDoc, ctxt->node, ret, dup);
2018 }
2019 } else
2020#endif /* LIBXML_VALID_ENABLED */
2021 if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
2022 (((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
2023 ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0))) &&
2024 /* Don't create IDs containing entity references */
2025 (ret->children != NULL) &&
2026 (ret->children->type == XML_TEXT_NODE) &&
2027 (ret->children->next == NULL)) {
2028 xmlChar *content = ret->children->content;
2029 /*
2030 * when validating, the ID registration is done at the attribute
2031 * validation level. Otherwise we have to do specific handling here.
2032 */
2033 if ((prefix == ctxt->str_xml) &&
2034 (localname[0] == 'i') && (localname[1] == 'd') &&
2035 (localname[2] == 0)) {
2036 /*
2037 * Add the xml:id value
2038 *
2039 * Open issue: normalization of the value.
2040 */
2041 if (xmlValidateNCName(content, 1) != 0) {
2042 xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
2043 "xml:id : attribute value %s is not an NCName\n",
2044 (const char *) content, NULL);
2045 }
2046 xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
2047 } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
2048 xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
2049 } else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) {
2050 xmlAddRef(&ctxt->vctxt, ctxt->myDoc, content, ret);
2051 }
2052 }
2053 if (dup != NULL)
2054 xmlFree(dup);
2055
2056 return(ret);
2057}
static xmlNodePtr xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len)
Definition: SAX2.c:1739
content
Definition: atl_ax.c:994
return ret
Definition: mutex.c:146
#define dup
Definition: syshdrs.h:51
xmlRegisterNodeFunc xmlRegisterNodeDefaultValue
Definition: globals.c:364
xmlMallocFunc xmlMalloc
Definition: globals.c:193
#define XML_SKIP_IDS
Definition: parser.h:160
XML_HIDDEN void * xmlParserNsLookupSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix)
Definition: parser.c:1569
XML_HIDDEN int __xmlRegisterCallbacks
Definition: tree.c:50
#define memset(x, y, z)
Definition: compat.h:39
Definition: dlist.c:348
Definition: pdh_main.c:96
XMLPUBFUN xmlIDPtr xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr)
Definition: valid.c:2517
XML_DEPRECATED XMLPUBFUN int xmlIsRef(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
Definition: valid.c:2967
XMLPUBFUN int xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
Definition: valid.c:2619
XML_DEPRECATED XMLPUBFUN xmlRefPtr xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr)
Definition: valid.c:2848
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
@ XML_DTD_XMLID_VALUE
Definition: xmlerror.h:259
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:45
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69

Referenced by xmlSAX2StartElementNs().

◆ xmlSAX2CDataBlock()

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

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

called when a pcdata block has been parsed

Definition at line 2660 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2Characters()

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

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

receiving some chars from the parser.

Definition at line 2539 of file SAX2.c.

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

Referenced by sax_characters(), and xmlSAXVersion().

◆ xmlSAX2Comment()

void xmlSAX2Comment ( void ctx,
const xmlChar value 
)

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

A xmlSAX2Comment has been parsed.

Definition at line 2614 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2ElementDecl()

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

Definition at line 720 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2EndDocument()

void xmlSAX2EndDocument ( void ctx)

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

called when the document end has been detected.

Definition at line 944 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2EndElementNs()

void xmlSAX2EndElementNs ( void ctx,
const xmlChar *localname  ATTRIBUTE_UNUSED,
const xmlChar *prefix  ATTRIBUTE_UNUSED,
const xmlChar *URI  ATTRIBUTE_UNUSED 
)

xmlSAX2EndElementNs: @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

SAX2 callback when an element end has been detected by the parser. It provides the namespace information for the element.

Definition at line 2348 of file SAX2.c.

2352{
2353 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
2354
2355 if (ctx == NULL) return;
2356 ctxt->nodemem = -1;
2357
2358#ifdef LIBXML_VALID_ENABLED
2359 if (ctxt->validate && ctxt->wellFormed &&
2360 ctxt->myDoc && ctxt->myDoc->intSubset)
2361 ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc,
2362 ctxt->node);
2363#endif /* LIBXML_VALID_ENABLED */
2364
2365 /*
2366 * end of parsing of this node.
2367 */
2368 nodePop(ctxt);
2369}
XML_DEPRECATED XMLPUBFUN xmlNodePtr nodePop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1996

Referenced by xmlSAXVersion().

◆ xmlSAX2EntityDecl()

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

Definition at line 588 of file SAX2.c.

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

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

◆ xmlSAX2ExternalSubset()

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

Definition at line 357 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2GetColumnNumber()

int xmlSAX2GetColumnNumber ( void ctx)

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

Provide the column number of the current parsing point.

Returns an int

Definition at line 259 of file SAX2.c.

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

Referenced by update_position().

◆ xmlSAX2GetEntity()

xmlEntityPtr xmlSAX2GetEntity ( void ctx,
const xmlChar name 
)

Definition at line 518 of file SAX2.c.

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

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

◆ xmlSAX2GetLineNumber()

int xmlSAX2GetLineNumber ( void ctx)

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

Provide the line number of the current parsing point.

Returns an int

Definition at line 243 of file SAX2.c.

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

Referenced by update_position().

◆ xmlSAX2GetParameterEntity()

xmlEntityPtr xmlSAX2GetParameterEntity ( void ctx,
const xmlChar name 
)

Definition at line 564 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2GetPublicId()

const xmlChar * xmlSAX2GetPublicId ( void *ctx  ATTRIBUTE_UNUSED)

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

Provides the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"

Returns a xmlChar *

Definition at line 211 of file SAX2.c.

212{
213 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
214 return(NULL);
215}

◆ xmlSAX2GetSystemId()

const xmlChar * xmlSAX2GetSystemId ( void ctx)

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

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

Returns a xmlChar *

Definition at line 227 of file SAX2.c.

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

Referenced by isaxlocator_getSystemId().

◆ xmlSAX2HasExternalSubset()

int xmlSAX2HasExternalSubset ( void ctx)

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

Does this document has an external subset

Returns 1 if true

Definition at line 307 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2HasInternalSubset()

int xmlSAX2HasInternalSubset ( void ctx)

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

Does this document has an internal subset

Returns 1 if true

Definition at line 291 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2IgnorableWhitespace()

void xmlSAX2IgnorableWhitespace ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar *ch  ATTRIBUTE_UNUSED,
int len  ATTRIBUTE_UNUSED 
)

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

receiving some ignorable whitespaces from the parser. UNUSED: by default the DOM building will use xmlSAX2Characters

Definition at line 2554 of file SAX2.c.

2555{
2556}

◆ xmlSAX2InitDefaultSAXHandler()

void xmlSAX2InitDefaultSAXHandler ( xmlSAXHandler *  hdlr,
int  warning 
)

xmlSAX2InitDefaultSAXHandler: @hdlr: the SAX handler

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

Initialize the default XML SAX2 handler

Definition at line 2762 of file SAX2.c.

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

◆ xmlSAX2InternalSubset()

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

Definition at line 324 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2IsStandalone()

int xmlSAX2IsStandalone ( void ctx)

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

Is this document tagged standalone ?

Returns 1 if true

Definition at line 275 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2NotationDecl()

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

Definition at line 764 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2ProcessingInstruction()

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

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

A processing instruction has been parsed.

Definition at line 2567 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2Reference()

void xmlSAX2Reference ( void ctx,
const xmlChar name 
)

Definition at line 2379 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2ResolveEntity()

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

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

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

Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.

Definition at line 486 of file SAX2.c.

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

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

◆ xmlSAX2SetDocumentLocator()

void xmlSAX2SetDocumentLocator ( void *ctx  ATTRIBUTE_UNUSED,
xmlSAXLocatorPtr loc  ATTRIBUTE_UNUSED 
)

xmlSAX2SetDocumentLocator: @ctx: the user data (XML parser context) @loc: A SAX Locator

Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case.

Definition at line 876 of file SAX2.c.

877{
878}

Referenced by xmlSAXVersion().

◆ xmlSAX2StartDocument()

void xmlSAX2StartDocument ( void ctx)

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

called when the document start being processed.

Definition at line 887 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2StartElementNs()

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

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

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

Definition at line 2077 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAX2Text()

static void xmlSAX2Text ( xmlParserCtxtPtr  ctxt,
const xmlChar ch,
int  len,
xmlElementType  type 
)
static

xmlSAX2Text: @ctx: the user data (XML parser context) @ch: a xmlChar string @len: the number of xmlChar @type: text or cdata

Append characters.

Definition at line 2401 of file SAX2.c.

2403{
2404 xmlNodePtr lastChild;
2405
2406 if (ctxt == NULL) return;
2407 /*
2408 * Handle the data if any. If there is no child
2409 * add it as content, otherwise if the last child is text,
2410 * concatenate it, else create a new node of type text.
2411 */
2412
2413 if (ctxt->node == NULL) {
2414 return;
2415 }
2416 lastChild = ctxt->node->last;
2417
2418 /*
2419 * Here we needed an accelerator mechanism in case of very large
2420 * elements. Use an attribute in the structure !!!
2421 */
2422 if (lastChild == NULL) {
2423 if (type == XML_TEXT_NODE)
2424 lastChild = xmlSAX2TextNode(ctxt, ch, len);
2425 else
2426 lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len);
2427 if (lastChild != NULL) {
2428 ctxt->node->children = lastChild;
2429 ctxt->node->last = lastChild;
2430 lastChild->parent = ctxt->node;
2431 lastChild->doc = ctxt->node->doc;
2432 ctxt->nodelen = len;
2433 ctxt->nodemem = len + 1;
2434 } else {
2435 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2436 return;
2437 }
2438 } else {
2439 int coalesceText = (lastChild != NULL) &&
2440 (lastChild->type == type) &&
2441 ((type != XML_TEXT_NODE) ||
2442 (lastChild->name == xmlStringText));
2443 if ((coalesceText) && (ctxt->nodemem != 0)) {
2444 /*
2445 * The whole point of maintaining nodelen and nodemem,
2446 * xmlTextConcat is too costly, i.e. compute length,
2447 * reallocate a new buffer, move data, append ch. Here
2448 * We try to minimize realloc() uses and avoid copying
2449 * and recomputing length over and over.
2450 */
2451 if (lastChild->content == (xmlChar *)&(lastChild->properties)) {
2452 lastChild->content = xmlStrdup(lastChild->content);
2453 lastChild->properties = NULL;
2454 } else if ((ctxt->nodemem == ctxt->nodelen + 1) &&
2455 (xmlDictOwns(ctxt->dict, lastChild->content))) {
2456 lastChild->content = xmlStrdup(lastChild->content);
2457 }
2458 if (lastChild->content == NULL) {
2459 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
2460 return;
2461 }
2462 if (ctxt->nodelen > INT_MAX - len) {
2463 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
2464 return;
2465 }
2466 if ((ctxt->nodelen + len > XML_MAX_TEXT_LENGTH) &&
2467 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
2468 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
2469 return;
2470 }
2471 if (ctxt->nodelen + len >= ctxt->nodemem) {
2472 xmlChar *newbuf;
2473 int size;
2474
2475 size = ctxt->nodemem > INT_MAX - len ?
2476 INT_MAX :
2477 ctxt->nodemem + len;
2478 size = size > INT_MAX / 2 ? INT_MAX : size * 2;
2479 newbuf = (xmlChar *) xmlRealloc(lastChild->content,size);
2480 if (newbuf == NULL) {
2481 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2482 return;
2483 }
2484 ctxt->nodemem = size;
2485 lastChild->content = newbuf;
2486 }
2487 memcpy(&lastChild->content[ctxt->nodelen], ch, len);
2488 ctxt->nodelen += len;
2489 lastChild->content[ctxt->nodelen] = 0;
2490 } else if (coalesceText) {
2491 if (xmlTextConcat(lastChild, ch, len)) {
2492 xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters");
2493 }
2494 if (ctxt->node->children != NULL) {
2495 ctxt->nodelen = xmlStrlen(lastChild->content);
2496 ctxt->nodemem = ctxt->nodelen + 1;
2497 }
2498 } else {
2499 /* Mixed content, first time */
2500 if (type == XML_TEXT_NODE) {
2501 lastChild = xmlSAX2TextNode(ctxt, ch, len);
2502 if (lastChild != NULL)
2503 lastChild->doc = ctxt->myDoc;
2504 } else
2505 lastChild = xmlNewCDataBlock(ctxt->myDoc, ch, len);
2506 if (lastChild != NULL) {
2507 xmlAddChild(ctxt->node, lastChild);
2508 if (ctxt->node->children != NULL) {
2509 ctxt->nodelen = len;
2510 ctxt->nodemem = len + 1;
2511 }
2512 }
2513 }
2514 }
2515
2516 if ((lastChild != NULL) &&
2517 (type == XML_TEXT_NODE) &&
2518 (ctxt->linenumbers) &&
2519 (ctxt->input != NULL)) {
2520 if ((unsigned) ctxt->input->line < (unsigned) USHRT_MAX)
2521 lastChild->line = ctxt->input->line;
2522 else {
2523 lastChild->line = USHRT_MAX;
2524 if (ctxt->options & XML_PARSE_BIG_LINES)
2525 lastChild->psvi = (void *) (ptrdiff_t) ctxt->input->line;
2526 }
2527 }
2528}
int ptrdiff_t
Definition: corecrt.h:194
#define INT_MAX
Definition: limits.h:26
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define XML_MAX_TEXT_LENGTH
XMLPUBVAR const xmlChar xmlStringText[]
xmlReallocFunc xmlRealloc
Definition: globals.c:214
@ XML_PARSE_HUGE
Definition: parser.h:1251
@ XML_PARSE_BIG_LINES
Definition: parser.h:1254
XMLPUBFUN int xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:428

Referenced by xmlSAX2CDataBlock(), and xmlSAX2Characters().

◆ xmlSAX2TextNode()

static xmlNodePtr xmlSAX2TextNode ( xmlParserCtxtPtr  ctxt,
const xmlChar str,
int  len 
)
static

Definition at line 1739 of file SAX2.c.

1739 {
1740 xmlNodePtr ret;
1741 const xmlChar *intern = NULL;
1742
1743 /*
1744 * Allocate
1745 */
1746 if (ctxt->freeElems != NULL) {
1747 ret = ctxt->freeElems;
1748 ctxt->freeElems = ret->next;
1749 ctxt->freeElemsNr--;
1750 } else {
1751 ret = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
1752 }
1753 if (ret == NULL) {
1754 xmlErrMemory(ctxt, "xmlSAX2Characters");
1755 return(NULL);
1756 }
1757 memset(ret, 0, sizeof(xmlNode));
1758 /*
1759 * intern the formatting blanks found between tags, or the
1760 * very short strings
1761 */
1762 if (ctxt->dictNames) {
1763 xmlChar cur = str[len];
1764
1765 if ((len < (int) (2 * sizeof(void *))) &&
1766 (ctxt->options & XML_PARSE_COMPACT)) {
1767 /* store the string in the node overriding properties and nsDef */
1768 xmlChar *tmp = (xmlChar *) &(ret->properties);
1769 memcpy(tmp, str, len);
1770 tmp[len] = 0;
1771 intern = tmp;
1772 } else if ((len <= 3) && ((cur == '"') || (cur == '\'') ||
1773 ((cur == '<') && (str[len + 1] != '!')))) {
1774 intern = xmlDictLookup(ctxt->dict, str, len);
1775 } else if (IS_BLANK_CH(*str) && (len < 60) && (cur == '<') &&
1776 (str[len + 1] != '!')) {
1777 int i;
1778
1779 for (i = 1;i < len;i++) {
1780 if (!IS_BLANK_CH(str[i])) goto skip;
1781 }
1782 intern = xmlDictLookup(ctxt->dict, str, len);
1783 }
1784 }
1785skip:
1786 ret->type = XML_TEXT_NODE;
1787
1788 ret->name = xmlStringText;
1789 if (intern == NULL) {
1790 ret->content = xmlStrndup(str, len);
1791 if (ret->content == NULL) {
1792 xmlSAX2ErrMemory(ctxt, "xmlSAX2TextNode");
1793 xmlFree(ret);
1794 return(NULL);
1795 }
1796 } else
1797 ret->content = (xmlChar *) intern;
1798
1801 return(ret);
1802}
#define skip(...)
Definition: atltest.h:64
FxCollectionEntry * cur
#define IS_BLANK_CH(c)
const WCHAR * str
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
@ XML_PARSE_COMPACT
Definition: parser.h:1246
XML_HIDDEN void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)

Referenced by xmlSAX2AttributeNs(), and xmlSAX2Text().

◆ xmlSAX2UnparsedEntityDecl()

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

Definition at line 813 of file SAX2.c.

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

Referenced by doparse(), and xmlSAXVersion().

◆ xmlSAXVersion()

int xmlSAXVersion ( xmlSAXHandler *  hdlr,
int  version 
)

xmlSAXVersion: @hdlr: the SAX handler

Version
: the version, 1 or 2

Initialize the default XML SAX handler according to the version

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

Definition at line 2704 of file SAX2.c.

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

Referenced by xmlInitSAXParserCtxt(), and xmlSAX2InitDefaultSAXHandler().

Variable Documentation

◆ xmlSAX2DefaultVersionValue

int xmlSAX2DefaultVersionValue = 2
static

Definition at line 2665 of file SAX2.c.

Referenced by xmlSAX2InitDefaultSAXHandler().