ReactOS  0.4.14-dev-608-gd495a4f
parser.h File Reference
#include <stdarg.h>
#include <libxml/xmlversion.h>
#include <libxml/tree.h>
#include <libxml/dict.h>
#include <libxml/hash.h>
#include <libxml/valid.h>
#include <libxml/entities.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlstring.h>
#include <libxml/encoding.h>
#include <libxml/xmlIO.h>
#include <libxml/globals.h>
Include dependency graph for parser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _xmlParserInput
 
struct  _xmlParserNodeInfo
 
struct  _xmlParserNodeInfoSeq
 
struct  _xmlParserCtxt
 
struct  _xmlSAXLocator
 
struct  _xmlSAXHandler
 
struct  _xmlSAXHandlerV1
 

Macros

#define XML_DEFAULT_VERSION   "1.0"
 
#define XML_DETECT_IDS   2
 
#define XML_COMPLETE_ATTRS   4
 
#define XML_SKIP_IDS   8
 

Typedefs

typedef void(* xmlParserInputDeallocate) (xmlChar *str)
 
typedef struct _xmlParserNodeInfo xmlParserNodeInfo
 
typedef xmlParserNodeInfoxmlParserNodeInfoPtr
 
typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq
 
typedef xmlParserNodeInfoSeqxmlParserNodeInfoSeqPtr
 
typedef xmlParserInputPtr(* resolveEntitySAXFunc) (void *ctx, const xmlChar *publicId, const xmlChar *systemId)
 
: the root element name

externalSubsetSAXFunc: @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.

typedef void(* internalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
typedef void(* externalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
: The entity name

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

Get a parameter entity by name.

Returns the xmlEntityPtr if found.

typedef xmlEntityPtr(* getEntitySAXFunc) (void *ctx, const xmlChar *name)
 
typedef xmlEntityPtr(* getParameterEntitySAXFunc) (void *ctx, const xmlChar *name)
 
: The name of the notation

notationDeclSAXFunc: @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.

typedef void(* notationDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 
typedef void(* attributeDeclSAXFunc) (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
 
: The element name

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

Called when the end of an element has been detected.

typedef void(* elementDeclSAXFunc) (void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)
 
typedef void(* endElementSAXFunc) (void *ctx, const xmlChar *name)
 
: The name of the entity

unparsedEntityDeclSAXFunc: @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.

typedef void(* unparsedEntityDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
 
typedef void(* setDocumentLocatorSAXFunc) (void *ctx, xmlSAXLocatorPtr loc)
 
typedef void(* startDocumentSAXFunc) (void *ctx)
 
typedef void(* endDocumentSAXFunc) (void *ctx)
 
: The element name, including namespace prefix

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

@atts: An array of name/value attributes pairs, NULL terminated

Called when an opening tag has been processed.

typedef void(* startElementSAXFunc) (void *ctx, const xmlChar *name, const xmlChar **atts)
 
: The attribute name, including namespace prefix

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

@value: 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.

typedef void(* attributeSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *value)
 

Enumerations

enum  xmlParserInputState {
  XML_PARSER_EOF = -1, XML_PARSER_START = 0, XML_PARSER_MISC, XML_PARSER_PI,
  XML_PARSER_DTD, XML_PARSER_PROLOG, XML_PARSER_COMMENT, XML_PARSER_START_TAG,
  XML_PARSER_CONTENT, XML_PARSER_CDATA_SECTION, XML_PARSER_END_TAG, XML_PARSER_ENTITY_DECL,
  XML_PARSER_ENTITY_VALUE, XML_PARSER_ATTRIBUTE_VALUE, XML_PARSER_SYSTEM_LITERAL, XML_PARSER_EPILOG,
  XML_PARSER_IGNORE, XML_PARSER_PUBLIC_LITERAL
}
 
enum  xmlParserMode {
  XML_PARSE_UNKNOWN = 0, XML_PARSE_DOM = 1, XML_PARSE_SAX = 2, XML_PARSE_PUSH_DOM = 3,
  XML_PARSE_PUSH_SAX = 4, XML_PARSE_READER = 5
}
 

: The entity name

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

Called when an entity reference is detected.

#define XML_SAX2_MAGIC   0xDEEDBEAF
 
enum  xmlParserOption {
  XML_PARSE_RECOVER = 1<<0, XML_PARSE_NOENT = 1<<1, XML_PARSE_DTDLOAD = 1<<2, XML_PARSE_DTDATTR = 1<<3,
  XML_PARSE_DTDVALID = 1<<4, XML_PARSE_NOERROR = 1<<5, XML_PARSE_NOWARNING = 1<<6, XML_PARSE_PEDANTIC = 1<<7,
  XML_PARSE_NOBLANKS = 1<<8, XML_PARSE_SAX1 = 1<<9, XML_PARSE_XINCLUDE = 1<<10, XML_PARSE_NONET = 1<<11,
  XML_PARSE_NODICT = 1<<12, XML_PARSE_NSCLEAN = 1<<13, XML_PARSE_NOCDATA = 1<<14, XML_PARSE_NOXINCNODE = 1<<15,
  XML_PARSE_COMPACT = 1<<16, XML_PARSE_OLD10 = 1<<17, XML_PARSE_NOBASEFIX = 1<<18, XML_PARSE_HUGE = 1<<19,
  XML_PARSE_OLDSAX = 1<<20, XML_PARSE_IGNORE_ENC = 1<<21, XML_PARSE_BIG_LINES = 1<<22
}
 
enum  xmlFeature {
  XML_WITH_THREAD = 1, XML_WITH_TREE = 2, XML_WITH_OUTPUT = 3, XML_WITH_PUSH = 4,
  XML_WITH_READER = 5, XML_WITH_PATTERN = 6, XML_WITH_WRITER = 7, XML_WITH_SAX1 = 8,
  XML_WITH_FTP = 9, XML_WITH_HTTP = 10, XML_WITH_VALID = 11, XML_WITH_HTML = 12,
  XML_WITH_LEGACY = 13, XML_WITH_C14N = 14, XML_WITH_CATALOG = 15, XML_WITH_XPATH = 16,
  XML_WITH_XPTR = 17, XML_WITH_XINCLUDE = 18, XML_WITH_ICONV = 19, XML_WITH_ISO8859X = 20,
  XML_WITH_UNICODE = 21, XML_WITH_REGEXP = 22, XML_WITH_AUTOMATA = 23, XML_WITH_EXPR = 24,
  XML_WITH_SCHEMAS = 25, XML_WITH_SCHEMATRON = 26, XML_WITH_MODULES = 27, XML_WITH_DEBUG = 28,
  XML_WITH_DEBUG_MEM = 29, XML_WITH_DEBUG_RUN = 30, XML_WITH_ZLIB = 31, XML_WITH_ICU = 32,
  XML_WITH_LZMA = 33, XML_WITH_NONE = 99999
}
 
typedef void(* entityDeclSAXFunc) (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
 
typedef void(* referenceSAXFunc) (void *ctx, const xmlChar *name)
 
typedef void(* charactersSAXFunc) (void *ctx, const xmlChar *ch, int len)
 
typedef void(* ignorableWhitespaceSAXFunc) (void *ctx, const xmlChar *ch, int len)
 
typedef void(* processingInstructionSAXFunc) (void *ctx, const xmlChar *target, const xmlChar *data)
 
typedef void(* commentSAXFunc) (void *ctx, const xmlChar *value)
 
typedef void(* cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len)
 
typedef void(XMLCDECLwarningSAXFunc) (void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
 
typedef void(XMLCDECL *) typede void) (XMLCDECL *errorSAXFunc) (void *ctx
 
typedef void(XMLCDECL *) typedef const char msg)
 
typedef void(XMLCDECL *) typedef const cha LIBXML_ATTR_FORMAT) (2, 3)
 
typedef void(XMLCDECLfatalErrorSAXFunc) (void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
 
typedef void(XMLCDECL *) typedef int(* isStandaloneSAXFunc) (void *ctx)
 
typedef int(* hasInternalSubsetSAXFunc) (void *ctx)
 
typedef int(* hasExternalSubsetSAXFunc) (void *ctx)
 
typedef void(* startElementNsSAX2Func) (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)
 
typedef void(* endElementNsSAX2Func) (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
 
typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1
 
typedef xmlSAXHandlerV1xmlSAXHandlerV1Ptr
 
typedef xmlParserInputPtr(* xmlExternalEntityLoader) (const char *URL, const char *ID, xmlParserCtxtPtr context)
 
XMLPUBFUN void XMLCALL xmlInitParser (void)
 
XMLPUBFUN void XMLCALL xmlCleanupParser (void)
 
XMLPUBFUN int XMLCALL xmlParserInputRead (xmlParserInputPtr in, int len)
 
XMLPUBFUN int XMLCALL xmlParserInputGrow (xmlParserInputPtr in, int len)
 
XMLPUBFUN int XMLCALL xmlSubstituteEntitiesDefault (int val)
 
XMLPUBFUN int XMLCALL xmlKeepBlanksDefault (int val)
 
XMLPUBFUN void XMLCALL xmlStopParser (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlPedanticParserDefault (int val)
 
XMLPUBFUN int XMLCALL xmlLineNumbersDefault (int val)
 
XMLPUBFUN int XMLCALL xmlParseDocument (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlParserErrors XMLCALL xmlParseInNodeContext (xmlNodePtr node, const char *data, int datalen, int options, xmlNodePtr *lst)
 
XMLPUBFUN int XMLCALL xmlParseCtxtExternalEntity (xmlParserCtxtPtr ctx, const xmlChar *URL, const xmlChar *ID, xmlNodePtr *lst)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt (void)
 
XMLPUBFUN int XMLCALL xmlInitParserCtxt (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlClearParserCtxt (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlFreeParserCtxt (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateDocParserCtxt (const xmlChar *cur)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, void *user_data, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream (xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
 
XMLPUBFUN const xmlParserNodeInfo *XMLCALL xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt, const xmlNodePtr node)
 
XMLPUBFUN void XMLCALL xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq)
 
XMLPUBFUN void XMLCALL xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq)
 
XMLPUBFUN unsigned long XMLCALL xmlParserFindNodeInfoIndex (const xmlParserNodeInfoSeqPtr seq, const xmlNodePtr node)
 
XMLPUBFUN void XMLCALL xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, const xmlParserNodeInfoPtr info)
 
XMLPUBFUN void XMLCALL xmlSetExternalEntityLoader (xmlExternalEntityLoader f)
 
XMLPUBFUN xmlExternalEntityLoader XMLCALL xmlGetExternalEntityLoader (void)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity (const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
 
XMLPUBFUN long XMLCALL xmlByteConsumed (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlCtxtReset (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlCtxtResetPush (xmlParserCtxtPtr ctxt, const char *chunk, int size, const char *filename, const char *encoding)
 
XMLPUBFUN int XMLCALL xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlReadDoc (const xmlChar *cur, const char *URL, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlReadFile (const char *URL, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlReadMemory (const char *buffer, int size, const char *URL, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlReadFd (int fd, const char *URL, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlReadIO (xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, const xmlChar *cur, const char *URL, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadFile (xmlParserCtxtPtr ctxt, const char *filename, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadFd (xmlParserCtxtPtr ctxt, int fd, const char *URL, const char *encoding, int options)
 
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadIO (xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
 
XMLPUBFUN int XMLCALL xmlHasFeature (xmlFeature feature)
 

Macro Definition Documentation

◆ XML_COMPLETE_ATTRS

#define XML_COMPLETE_ATTRS   4

XML_COMPLETE_ATTRS:

Bit in the loadsubset context field to tell to do complete the elements attributes lists with the ones defaulted from the DTDs. Use it to initialize xmlLoadExtDtdDefaultValue.

Definition at line 148 of file parser.h.

◆ XML_DEFAULT_VERSION

#define XML_DEFAULT_VERSION   "1.0"

XML_DEFAULT_VERSION:

The default version of XML used: 1.0

Definition at line 33 of file parser.h.

◆ XML_DETECT_IDS

#define XML_DETECT_IDS   2

XML_DETECT_IDS:

Bit in the loadsubset context field to tell to do ID/REFs lookups. Use it to initialize xmlLoadExtDtdDefaultValue.

Definition at line 139 of file parser.h.

◆ XML_SAX2_MAGIC

#define XML_SAX2_MAGIC   0xDEEDBEAF

XML_SAX2_MAGIC:

Special constant found in SAX2 blocks initialized fields

Definition at line 671 of file parser.h.

◆ XML_SKIP_IDS

#define XML_SKIP_IDS   8

XML_SKIP_IDS:

Bit in the loadsubset context field to tell to not do ID/REFs registration. Used to initialize xmlLoadExtDtdDefaultValue in some special cases.

Definition at line 156 of file parser.h.

Typedef Documentation

◆ attributeDeclSAXFunc

typedef void(* attributeDeclSAXFunc) (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)

Definition at line 443 of file parser.h.

◆ attributeSAXFunc

typedef void(* attributeSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *value)

Definition at line 533 of file parser.h.

◆ cdataBlockSAXFunc

typedef void(* cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len)

cdataBlockSAXFunc: @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 596 of file parser.h.

◆ charactersSAXFunc

typedef void(* charactersSAXFunc) (void *ctx, const xmlChar *ch, int len)

charactersSAXFunc: @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 553 of file parser.h.

◆ commentSAXFunc

typedef void(* commentSAXFunc) (void *ctx, const xmlChar *value)

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

A comment has been parsed.

Definition at line 586 of file parser.h.

◆ elementDeclSAXFunc

typedef void(* elementDeclSAXFunc) (void *ctx, const xmlChar *name, int type, xmlElementContentPtr content)

Definition at line 459 of file parser.h.

◆ endDocumentSAXFunc

typedef void(* endDocumentSAXFunc) (void *ctx)

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

Called when the document end has been detected.

Definition at line 501 of file parser.h.

◆ endElementNsSAX2Func

typedef void(* endElementNsSAX2Func) (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)

endElementNsSAX2Func: @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 informations for the element.

Definition at line 713 of file parser.h.

◆ endElementSAXFunc

typedef void(* endElementSAXFunc) (void *ctx, const xmlChar *name)

Definition at line 520 of file parser.h.

◆ entityDeclSAXFunc

typedef void(* entityDeclSAXFunc) (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)

Definition at line 412 of file parser.h.

◆ externalSubsetSAXFunc

typedef void(* externalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)

Definition at line 375 of file parser.h.

◆ fatalErrorSAXFunc

typedef void(XMLCDECL * fatalErrorSAXFunc) (void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2

fatalErrorSAXFunc: @ctx: an XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format fatal error messages, callback. Note: so far fatalError() SAX callbacks are not used, error() get all the callbacks for errors.

Definition at line 630 of file parser.h.

◆ getEntitySAXFunc

typedef xmlEntityPtr(* getEntitySAXFunc) (void *ctx, const xmlChar *name)

Definition at line 388 of file parser.h.

◆ getParameterEntitySAXFunc

typedef xmlEntityPtr(* getParameterEntitySAXFunc) (void *ctx, const xmlChar *name)

Definition at line 399 of file parser.h.

◆ hasExternalSubsetSAXFunc

typedef int(* hasExternalSubsetSAXFunc) (void *ctx)

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

Does this document has an external subset?

Returns 1 if true

Definition at line 659 of file parser.h.

◆ hasInternalSubsetSAXFunc

typedef int(* hasInternalSubsetSAXFunc) (void *ctx)

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

Does this document has an internal subset.

Returns 1 if true

Definition at line 649 of file parser.h.

◆ ignorableWhitespaceSAXFunc

typedef void(* ignorableWhitespaceSAXFunc) (void *ctx, const xmlChar *ch, int len)

ignorableWhitespaceSAXFunc: @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 characters.

Definition at line 565 of file parser.h.

◆ internalSubsetSAXFunc

typedef void(* internalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)

Definition at line 362 of file parser.h.

◆ isStandaloneSAXFunc

typedef void(XMLCDECL *) typedef int(* isStandaloneSAXFunc) (void *ctx)

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

Is this document tagged standalone?

Returns 1 if true

Definition at line 640 of file parser.h.

◆ LIBXML_ATTR_FORMAT

static void XMLCDECL LIBXML_ATTR_FORMAT

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

Handle a warning.

xmlValidityError: @ctxt: an XML parser context @error: the error number @msg: the error message @str1: extra data

Handle a validity error.

xmlFatalErrMsgInt: @ctxt: an XML parser context @error: the error number @msg: the error message @val: an integer value

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

xmlFatalErrMsgStrIntStr: @ctxt: an XML parser context @error: the error number @msg: the error message @str1: an string info @val: an integer value @str2: an string info

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

xmlFatalErrMsgStr: @ctxt: an XML parser context @error: the error number @msg: the error message @val: a string value

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

xmlErrMsgStr: @ctxt: an XML parser context @error: the error number @msg: the error message @val: a string value

Handle a non fatal parser error

xmlNsErr: @ctxt: an XML parser context @error: the error number @msg: the message @info1: extra information string @info2: extra information string

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

xmlNsWarn @ctxt: an XML parser context @error: the error number @msg: the message @info1: extra information string @info2: extra information string

Handle a namespace warning 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

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

Handle a namespace error

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

Handle a namespace warning

xmlHTMLWarning: @ctx: an XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a warning messages, gives file, line, position and extra parameters.

xmlHTMLValidityError: @ctx: an XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format an validity error messages, gives file, line, position and extra parameters.

xmlHTMLValidityWarning: @ctx: an XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a validity warning messages, gives file, line, position and extra parameters.

warningDebug: @ctxt: An XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a warning messages, gives file, line, position and extra parameters.

errorDebug: @ctxt: An XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a error messages, gives file, line, position and extra parameters.

fatalErrorDebug: @ctxt: An XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a fatalError messages, gives file, line, position and extra parameters.

Definition at line 619 of file parser.h.

◆ msg

typedef void(XMLCDECL *) typedef const char msg)

Definition at line 619 of file parser.h.

◆ notationDeclSAXFunc

typedef void(* notationDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)

Definition at line 427 of file parser.h.

◆ processingInstructionSAXFunc

typedef void(* processingInstructionSAXFunc) (void *ctx, const xmlChar *target, const xmlChar *data)

processingInstructionSAXFunc: @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 576 of file parser.h.

◆ referenceSAXFunc

typedef void(* referenceSAXFunc) (void *ctx, const xmlChar *name)

Definition at line 543 of file parser.h.

◆ resolveEntitySAXFunc

typedef xmlParserInputPtr(* resolveEntitySAXFunc) (void *ctx, const xmlChar *publicId, const xmlChar *systemId)

xmlSAXHandler:

A SAX handler is bunch of callbacks called by the parser when processing of the input generate data or structure informations.resolveEntitySAXFunc: @ctx: the user data (XML parser context) @publicId: The public ID of the entity @systemId: The system ID of the entity

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

  • override this resolveEntity() callback in the SAX block
  • or better use the xmlSetExternalEntityLoader() function to set up it's own entity resolution routine

Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.

Definition at line 350 of file parser.h.

◆ setDocumentLocatorSAXFunc

typedef void(* setDocumentLocatorSAXFunc) (void *ctx, xmlSAXLocatorPtr loc)

setDocumentLocatorSAXFunc: @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 486 of file parser.h.

◆ startDocumentSAXFunc

typedef void(* startDocumentSAXFunc) (void *ctx)

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

Called when the document start being processed.

Definition at line 494 of file parser.h.

◆ startElementNsSAX2Func

typedef void(* startElementNsSAX2Func) (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)

startElementNsSAX2Func: @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. The defaulted ones are at the end of the array @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 692 of file parser.h.

◆ startElementSAXFunc

typedef void(* startElementSAXFunc) (void *ctx, const xmlChar *name, const xmlChar **atts)

Definition at line 510 of file parser.h.

◆ unparsedEntityDeclSAXFunc

typedef void(* unparsedEntityDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)

Definition at line 473 of file parser.h.

◆ void

typedef void(XMLCDECL *) typede void) (XMLCDECL *errorSAXFunc)(void *ctx

errorSAXFunc: @ctx: an XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format an error messages, callback.

Definition at line 618 of file parser.h.

◆ warningSAXFunc

typedef void(XMLCDECL * warningSAXFunc) (void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2

warningSAXFunc: @ctx: an XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a warning messages, callback.

Definition at line 608 of file parser.h.

◆ xmlExternalEntityLoader

typedef xmlParserInputPtr(* xmlExternalEntityLoader) (const char *URL, const char *ID, xmlParserCtxtPtr context)

xmlExternalEntityLoader: @URL: The System ID of the resource requested @ID: The Public ID of the resource requested @context: the XML parser context

External entity loaders types.

Returns the entity input parser.

Definition at line 802 of file parser.h.

◆ xmlParserInputDeallocate

typedef void(* xmlParserInputDeallocate) (xmlChar *str)

xmlParserInput:

An xmlParserInput is an input flow for the XML processor. Each entity parsed is associated an xmlParserInput (except the few predefined ones). This is the case both for internal entities

  • in which case the flow is already completely in memory - or external entities - in which case we use the buf structure for progressive reading and I18N conversions to the internal UTF-8 format.xmlParserInputDeallocate: @str: the string to deallocate

Callback for freeing some parser input allocations.

Definition at line 52 of file parser.h.

◆ xmlParserNodeInfo

xmlParserNodeInfo:

The parser can be asked to collect Node informations, i.e. at what place in the file they were detected. NOTE: This is off by default and not very well tested.

Definition at line 86 of file parser.h.

◆ xmlParserNodeInfoPtr

Definition at line 87 of file parser.h.

◆ xmlParserNodeInfoSeq

Definition at line 98 of file parser.h.

◆ xmlParserNodeInfoSeqPtr

Definition at line 99 of file parser.h.

◆ xmlSAXHandlerV1

Definition at line 758 of file parser.h.

◆ xmlSAXHandlerV1Ptr

Definition at line 759 of file parser.h.

Enumeration Type Documentation

◆ xmlFeature

xmlFeature:

Used to examine the existance of features that can be enabled or disabled at compile-time. They used to be called XML_FEATURE_xxx but this clashed with Expat

Enumerator
XML_WITH_THREAD 
XML_WITH_TREE 
XML_WITH_OUTPUT 
XML_WITH_PUSH 
XML_WITH_READER 
XML_WITH_PATTERN 
XML_WITH_WRITER 
XML_WITH_SAX1 
XML_WITH_FTP 
XML_WITH_HTTP 
XML_WITH_VALID 
XML_WITH_HTML 
XML_WITH_LEGACY 
XML_WITH_C14N 
XML_WITH_CATALOG 
XML_WITH_XPATH 
XML_WITH_XPTR 
XML_WITH_XINCLUDE 
XML_WITH_ICONV 
XML_WITH_ISO8859X 
XML_WITH_UNICODE 
XML_WITH_REGEXP 
XML_WITH_AUTOMATA 
XML_WITH_EXPR 
XML_WITH_SCHEMAS 
XML_WITH_SCHEMATRON 
XML_WITH_MODULES 
XML_WITH_DEBUG 
XML_WITH_DEBUG_MEM 
XML_WITH_DEBUG_RUN 
XML_WITH_ZLIB 
XML_WITH_ICU 
XML_WITH_LZMA 
XML_WITH_NONE 

Definition at line 1198 of file parser.h.

1198  {
1199  XML_WITH_THREAD = 1,
1200  XML_WITH_TREE = 2,
1201  XML_WITH_OUTPUT = 3,
1202  XML_WITH_PUSH = 4,
1203  XML_WITH_READER = 5,
1204  XML_WITH_PATTERN = 6,
1205  XML_WITH_WRITER = 7,
1206  XML_WITH_SAX1 = 8,
1207  XML_WITH_FTP = 9,
1208  XML_WITH_HTTP = 10,
1209  XML_WITH_VALID = 11,
1210  XML_WITH_HTML = 12,
1211  XML_WITH_LEGACY = 13,
1212  XML_WITH_C14N = 14,
1213  XML_WITH_CATALOG = 15,
1214  XML_WITH_XPATH = 16,
1215  XML_WITH_XPTR = 17,
1216  XML_WITH_XINCLUDE = 18,
1217  XML_WITH_ICONV = 19,
1218  XML_WITH_ISO8859X = 20,
1219  XML_WITH_UNICODE = 21,
1220  XML_WITH_REGEXP = 22,
1221  XML_WITH_AUTOMATA = 23,
1222  XML_WITH_EXPR = 24,
1223  XML_WITH_SCHEMAS = 25,
1224  XML_WITH_SCHEMATRON = 26,
1225  XML_WITH_MODULES = 27,
1226  XML_WITH_DEBUG = 28,
1227  XML_WITH_DEBUG_MEM = 29,
1228  XML_WITH_DEBUG_RUN = 30,
1229  XML_WITH_ZLIB = 31,
1230  XML_WITH_ICU = 32,
1231  XML_WITH_LZMA = 33,
1232  XML_WITH_NONE = 99999 /* just to be sure of allocation size */
1233 } xmlFeature;
xmlFeature
Definition: parser.h:1198

◆ xmlParserInputState

xmlParserInputState:

The parser is now working also as a state based parser. The recursive one use the state info for entities processing.

Enumerator
XML_PARSER_EOF 
XML_PARSER_START 
XML_PARSER_MISC 
XML_PARSER_PI 
XML_PARSER_DTD 
XML_PARSER_PROLOG 
XML_PARSER_COMMENT 
XML_PARSER_START_TAG 
XML_PARSER_CONTENT 
XML_PARSER_CDATA_SECTION 
XML_PARSER_END_TAG 
XML_PARSER_ENTITY_DECL 
XML_PARSER_ENTITY_VALUE 
XML_PARSER_ATTRIBUTE_VALUE 
XML_PARSER_SYSTEM_LITERAL 
XML_PARSER_EPILOG 
XML_PARSER_IGNORE 
XML_PARSER_PUBLIC_LITERAL 

Definition at line 112 of file parser.h.

112  {
113  XML_PARSER_EOF = -1, /* nothing is to be parsed */
114  XML_PARSER_START = 0, /* nothing has been parsed */
115  XML_PARSER_MISC, /* Misc* before int subset */
116  XML_PARSER_PI, /* Within a processing instruction */
117  XML_PARSER_DTD, /* within some DTD content */
118  XML_PARSER_PROLOG, /* Misc* after internal subset */
119  XML_PARSER_COMMENT, /* within a comment */
120  XML_PARSER_START_TAG, /* within a start tag */
121  XML_PARSER_CONTENT, /* within the content */
122  XML_PARSER_CDATA_SECTION, /* within a CDATA section */
123  XML_PARSER_END_TAG, /* within a closing tag */
124  XML_PARSER_ENTITY_DECL, /* within an entity declaration */
125  XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
126  XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
127  XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
128  XML_PARSER_EPILOG, /* the Misc* after the last end tag */
129  XML_PARSER_IGNORE, /* within an IGNORED section */
130  XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
xmlParserInputState
Definition: parser.h:112

◆ xmlParserMode

xmlParserMode:

A parser can operate in various modes

Enumerator
XML_PARSE_UNKNOWN 
XML_PARSE_DOM 
XML_PARSE_SAX 
XML_PARSE_PUSH_DOM 
XML_PARSE_PUSH_SAX 
XML_PARSE_READER 

Definition at line 163 of file parser.h.

◆ xmlParserOption

xmlParserOption:

This is the set of XML parser options that can be passed down to the xmlReadDoc() and similar calls.

Enumerator
XML_PARSE_RECOVER 
XML_PARSE_NOENT 
XML_PARSE_DTDLOAD 
XML_PARSE_DTDATTR 
XML_PARSE_DTDVALID 
XML_PARSE_NOERROR 
XML_PARSE_NOWARNING 
XML_PARSE_PEDANTIC 
XML_PARSE_NOBLANKS 
XML_PARSE_SAX1 
XML_PARSE_XINCLUDE 
XML_PARSE_NONET 
XML_PARSE_NODICT 
XML_PARSE_NSCLEAN 
XML_PARSE_NOCDATA 
XML_PARSE_NOXINCNODE 
XML_PARSE_COMPACT 
XML_PARSE_OLD10 
XML_PARSE_NOBASEFIX 
XML_PARSE_HUGE 
XML_PARSE_OLDSAX 
XML_PARSE_IGNORE_ENC 
XML_PARSE_BIG_LINES 

Definition at line 1089 of file parser.h.

1089  {
1090  XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1091  XML_PARSE_NOENT = 1<<1, /* substitute entities */
1092  XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1093  XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1094  XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1095  XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1096  XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1097  XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1098  XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1099  XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1100  XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
1101  XML_PARSE_NONET = 1<<11,/* Forbid network access */
1102  XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */
1103  XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1104  XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
1105  XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
1106  XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of
1107  the tree allowed afterwards (will possibly
1108  crash if you try to modify the tree) */
1109  XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
1110  XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
1111  XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */
1112  XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */
1113  XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
1114  XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
1115 } xmlParserOption;
xmlParserOption
Definition: parser.h:1089

Function Documentation

◆ xmlByteConsumed()

XMLPUBFUN long XMLCALL xmlByteConsumed ( xmlParserCtxtPtr  ctxt)

xmlByteConsumed: @ctxt: an XML parser context

This function provides the current index of the parser relative to the start of the current entity. This function is computed in bytes from the beginning starting at zero and finishing at the size in byte of the file if parsing a file. The function is of constant cost if the input is UTF-8 but can be costly if run on non-UTF-8 input.

Returns the index in bytes from the beginning of the entity or -1 in case the index could not be computed.

Definition at line 2803 of file encoding.c.

2803  {
2805 
2806  if (ctxt == NULL) return(-1);
2807  in = ctxt->input;
2808  if (in == NULL) return(-1);
2809  if ((in->buf != NULL) && (in->buf->encoder != NULL)) {
2810  unsigned int unused = 0;
2811  xmlCharEncodingHandler * handler = in->buf->encoder;
2812  /*
2813  * Encoding conversion, compute the number of unused original
2814  * bytes from the input not consumed and substract that from
2815  * the raw consumed value, this is not a cheap operation
2816  */
2817  if (in->end - in->cur > 0) {
2818  unsigned char convbuf[32000];
2819  const unsigned char *cur = (const unsigned char *)in->cur;
2820  int toconv = in->end - in->cur, written = 32000;
2821 
2822  int ret;
2823 
2824  do {
2825  toconv = in->end - cur;
2826  written = 32000;
2827  ret = xmlEncOutputChunk(handler, &convbuf[0], &written,
2828  cur, &toconv);
2829  if (ret < 0) {
2830  if (written > 0)
2831  ret = -2;
2832  else
2833  return(-1);
2834  }
2835  unused += written;
2836  cur += toconv;
2837  } while (ret == -2);
2838  }
2839  if (in->buf->rawconsumed < unused)
2840  return(-1);
2841  return(in->buf->rawconsumed - unused);
2842  }
2843  return(in->consumed + (in->cur - in->base));
2844 }
xmlParserInputPtr input
Definition: parser.h:199
static int xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
Definition: encoding.c:1946
WORD unused[29]
Definition: crypt.c:1155
smooth NULL
Definition: ftsmooth.c:416
int ret
GLuint in
Definition: glext.h:9616
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

◆ xmlCleanupParser()

XMLPUBFUN void XMLCALL xmlCleanupParser ( void  )

xmlCleanupParser:

This function name is somewhat misleading. It does not clean up parser state, it cleans up memory allocated by the library itself. It is a cleanup function for the XML library. It tries to reclaim all related global memory allocated for the library processing. It doesn't deallocate any document related memory. One should call xmlCleanupParser() only when the process has finished using the library and all XML/HTML documents built with it. See also xmlInitParser() which has the opposite function of preparing the library for operations.

WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It's sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind !

Definition at line 14764 of file parser.c.

14764  {
14765  if (!xmlParserInitialized)
14766  return;
14767 
14769 #ifdef LIBXML_CATALOG_ENABLED
14770  xmlCatalogCleanup();
14771 #endif
14772  xmlDictCleanup();
14774 #ifdef LIBXML_OUTPUT_ENABLED
14775  xmlCleanupOutputCallbacks();
14776 #endif
14777 #ifdef LIBXML_SCHEMAS_ENABLED
14778  xmlSchemaCleanupTypes();
14779  xmlRelaxNGCleanupTypes();
14780 #endif
14783  xmlCleanupThreads(); /* must be last if called not from the main thread */
14784  xmlCleanupMemory();
14786 }
XMLPUBFUN void XMLCALL xmlCleanupGlobals(void)
Definition: globals.c:58
XMLPUBFUN void XMLCALL xmlCleanupInputCallbacks(void)
XMLPUBFUN void XMLCALL xmlCleanupThreads(void)
Definition: threads.c:908
XMLPUBFUN void XMLCALL xmlCleanupCharEncodingHandlers(void)
Definition: encoding.c:1455
XMLPUBFUN void XMLCALL xmlCleanupMemory(void)
Definition: xmlmemory.c:1008
XMLPUBFUN void XMLCALL xmlResetLastError(void)
XMLPUBFUN void XMLCALL xmlDictCleanup(void)
Definition: dict.c:221
static int xmlParserInitialized
Definition: parser.c:14695

Referenced by DllMain(), and main().

◆ xmlClearNodeInfoSeq()

XMLPUBFUN void XMLCALL xmlClearNodeInfoSeq ( xmlParserNodeInfoSeqPtr  seq)

xmlClearNodeInfoSeq: @seq: a node info sequence pointer

– Clear (release memory and reinitialize) node info sequence

Definition at line 1951 of file parserInternals.c.

1952 {
1953  if (seq == NULL)
1954  return;
1955  if (seq->buffer != NULL)
1956  xmlFree(seq->buffer);
1957  xmlInitNodeInfoSeq(seq);
1958 }
xmlParserNodeInfo * buffer
Definition: parser.h:103
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)

Referenced by xmlClearParserCtxt().

◆ xmlClearParserCtxt()

XMLPUBFUN void XMLCALL xmlClearParserCtxt ( xmlParserCtxtPtr  ctxt)

xmlClearParserCtxt: @ctxt: an XML parser context

Clear (release owned resources) and reinitialize a parser context

Definition at line 1892 of file parserInternals.c.

1893 {
1894  if (ctxt==NULL)
1895  return;
1896  xmlClearNodeInfoSeq(&ctxt->node_seq);
1897  xmlCtxtReset(ctxt);
1898 }
void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
XMLPUBFUN void XMLCALL xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14813
smooth NULL
Definition: ftsmooth.c:416
xmlParserNodeInfoSeq node_seq
Definition: parser.h:211

◆ xmlCreateDocParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateDocParserCtxt ( const xmlChar cur)

xmlCreateDocParserCtxt: @cur: a pointer to an array of xmlChar

Creates a parser context for an XML in-memory document.

Returns the new parser context or NULL

Definition at line 14572 of file parser.c.

14572  {
14573  int len;
14574 
14575  if (cur == NULL)
14576  return(NULL);
14577  len = xmlStrlen(cur);
14578  return(xmlCreateMemoryParserCtxt((const char *)cur, len));
14579 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722
xmlParserCtxtPtr xmlCreateMemoryParserCtxt(const char *buffer, int size)
Definition: parser.c:14369

Referenced by xmlReadDoc().

◆ xmlCreateIOParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateIOParserCtxt ( xmlSAXHandlerPtr  sax,
void user_data,
xmlInputReadCallback  ioread,
xmlInputCloseCallback  ioclose,
void ioctx,
xmlCharEncoding  enc 
)

xmlCreateIOParserCtxt: @sax: a SAX handler @user_data: The user data returned on SAX callbacks @ioread: an I/O read function @ioclose: an I/O close function @ioctx: an I/O handler @enc: the charset encoding if known

Create a parser context for using the XML parser with an existing I/O stream

Returns the new parser context or NULL

Definition at line 12505 of file parser.c.

12507  {
12508  xmlParserCtxtPtr ctxt;
12509  xmlParserInputPtr inputStream;
12511 
12512  if (ioread == NULL) return(NULL);
12513 
12514  buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);
12515  if (buf == NULL) {
12516  if (ioclose != NULL)
12517  ioclose(ioctx);
12518  return (NULL);
12519  }
12520 
12521  ctxt = xmlNewParserCtxt();
12522  if (ctxt == NULL) {
12524  return(NULL);
12525  }
12526  if (sax != NULL) {
12527 #ifdef LIBXML_SAX1_ENABLED
12528  if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
12529 #endif /* LIBXML_SAX1_ENABLED */
12530  xmlFree(ctxt->sax);
12531  ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
12532  if (ctxt->sax == NULL) {
12533  xmlErrMemory(ctxt, NULL);
12534  xmlFreeParserCtxt(ctxt);
12535  return(NULL);
12536  }
12537  memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
12538  if (sax->initialized == XML_SAX2_MAGIC)
12539  memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
12540  else
12541  memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
12542  if (user_data != NULL)
12543  ctxt->userData = user_data;
12544  }
12545 
12546  inputStream = xmlNewIOInputStream(ctxt, buf, enc);
12547  if (inputStream == NULL) {
12548  xmlFreeParserCtxt(ctxt);
12549  return(NULL);
12550  }
12551  inputPush(ctxt, inputStream);
12552 
12553  return(ctxt);
12554 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define XML_SAX2_MAGIC
Definition: parser.h:671
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
static int sax
Definition: xmllint.c:198
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
smooth NULL
Definition: ftsmooth.c:416
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler
Definition: globals.h:321
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlSAXHandler * xmlSAXHandlerPtr
Definition: tree.h:45
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _xmlSAXHandler * sax
Definition: parser.h:185
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
#define memset(x, y, z)
Definition: compat.h:39
void * userData
Definition: parser.h:186

◆ xmlCtxtReadDoc()

XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadDoc ( xmlParserCtxtPtr  ctxt,
const xmlChar cur,
const char URL,
const char encoding,
int  options 
)

xmlCtxtReadDoc: @ctxt: an XML parser context @cur: a pointer to a zero terminated string @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context

Returns the resulting document tree

Definition at line 15389 of file parser.c.

15391 {
15393 
15394  if (cur == NULL)
15395  return (NULL);
15396  if (ctxt == NULL)
15397  return (NULL);
15398  xmlInitParser();
15399 
15400  xmlCtxtReset(ctxt);
15401 
15402  stream = xmlNewStringInputStream(ctxt, cur);
15403  if (stream == NULL) {
15404  return (NULL);
15405  }
15406  inputPush(ctxt, stream);
15407  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15408 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15180
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14813
void xmlInitParser(void)
Definition: parser.c:14706
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2839

◆ xmlCtxtReadFd()

XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadFd ( xmlParserCtxtPtr  ctxt,
int  fd,
const char URL,
const char encoding,
int  options 
)

xmlCtxtReadFd: @ctxt: an XML parser context @fd: an open file descriptor @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML from a file descriptor and build a tree. This reuses the existing @ctxt parser context NOTE that the file descriptor will not be closed when the reader is closed or reset.

Returns the resulting document tree

Definition at line 15504 of file parser.c.

15506 {
15509 
15510  if (fd < 0)
15511  return (NULL);
15512  if (ctxt == NULL)
15513  return (NULL);
15514  xmlInitParser();
15515 
15516  xmlCtxtReset(ctxt);
15517 
15518 
15520  if (input == NULL)
15521  return (NULL);
15522  input->closecallback = NULL;
15524  if (stream == NULL) {
15526  return (NULL);
15527  }
15528  inputPush(ctxt, stream);
15529  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15530 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15180
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
static int fd
Definition: io.c:51
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14813
void xmlInitParser(void)
Definition: parser.c:14706
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2839
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc)
GLenum GLenum GLenum input
Definition: glext.h:9031

◆ xmlCtxtReadFile()

XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadFile ( xmlParserCtxtPtr  ctxt,
const char filename,
const char encoding,
int  options 
)

xmlCtxtReadFile: @ctxt: an XML parser context @filename: a file or URL @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML file from the filesystem or the network. This reuses the existing @ctxt parser context

Returns the resulting document tree

Definition at line 15423 of file parser.c.

15425 {
15427 
15428  if (filename == NULL)
15429  return (NULL);
15430  if (ctxt == NULL)
15431  return (NULL);
15432  xmlInitParser();
15433 
15434  xmlCtxtReset(ctxt);
15435 
15437  if (stream == NULL) {
15438  return (NULL);
15439  }
15440  inputPush(ctxt, stream);
15441  return (xmlDoRead(ctxt, NULL, encoding, options, 1));
15442 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15180
const char * filename
Definition: ioapi.h:135
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14813
void xmlInitParser(void)
Definition: parser.c:14706
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
ed encoding
Definition: write.c:2839

Referenced by parseAndPrintFile().

◆ xmlCtxtReadIO()

XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadIO ( xmlParserCtxtPtr  ctxt,
xmlInputReadCallback  ioread,
xmlInputCloseCallback  ioclose,
void ioctx,
const char URL,
const char encoding,
int  options 
)

xmlCtxtReadIO: @ctxt: an XML parser context @ioread: an I/O read function @ioclose: an I/O close function @ioctx: an I/O handler @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML document from I/O functions and source and build a tree. This reuses the existing @ctxt parser context

Returns the resulting document tree

Definition at line 15548 of file parser.c.

15552 {
15555 
15556  if (ioread == NULL)
15557  return (NULL);
15558  if (ctxt == NULL)
15559  return (NULL);
15560  xmlInitParser();
15561 
15562  xmlCtxtReset(ctxt);
15563 
15564  input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
15566  if (input == NULL) {
15567  if (ioclose != NULL)
15568  ioclose(ioctx);
15569  return (NULL);
15570  }
15572  if (stream == NULL) {
15574  return (NULL);
15575  }
15576  inputPush(ctxt, stream);
15577  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15578 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15180
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14813
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
void xmlInitParser(void)
Definition: parser.c:14706
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2839
GLenum GLenum GLenum input
Definition: glext.h:9031

Referenced by parseAndPrintFile().

◆ xmlCtxtReadMemory()

XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadMemory ( xmlParserCtxtPtr  ctxt,
const char buffer,
int  size,
const char URL,
const char encoding,
int  options 
)

xmlCtxtReadMemory: @ctxt: an XML parser context @buffer: a pointer to a char array @size: the size of the array @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context

Returns the resulting document tree

Definition at line 15459 of file parser.c.

15461 {
15464 
15465  if (ctxt == NULL)
15466  return (NULL);
15467  if (buffer == NULL)
15468  return (NULL);
15469  xmlInitParser();
15470 
15471  xmlCtxtReset(ctxt);
15472 
15474  if (input == NULL) {
15475  return(NULL);
15476  }
15477 
15479  if (stream == NULL) {
15481  return(NULL);
15482  }
15483 
15484  inputPush(ctxt, stream);
15485  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15486 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15180
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
GLuint buffer
Definition: glext.h:5915
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14813
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
void xmlInitParser(void)
Definition: parser.c:14706
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2839
GLenum GLenum GLenum input
Definition: glext.h:9031

Referenced by parseAndPrintFile().

◆ xmlCtxtReset()

XMLPUBFUN void XMLCALL xmlCtxtReset ( xmlParserCtxtPtr  ctxt)

xmlCtxtReset: @ctxt: an XML parser context

Reset a parser context

Definition at line 14813 of file parser.c.

14814 {
14816  xmlDictPtr dict;
14817 
14818  if (ctxt == NULL)
14819  return;
14820 
14821  dict = ctxt->dict;
14822 
14823  while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
14825  }
14826  ctxt->inputNr = 0;
14827  ctxt->input = NULL;
14828 
14829  ctxt->spaceNr = 0;
14830  if (ctxt->spaceTab != NULL) {
14831  ctxt->spaceTab[0] = -1;
14832  ctxt->space = &ctxt->spaceTab[0];
14833  } else {
14834  ctxt->space = NULL;
14835  }
14836 
14837 
14838  ctxt->nodeNr = 0;
14839  ctxt->node = NULL;
14840 
14841  ctxt->nameNr = 0;
14842  ctxt->name = NULL;
14843 
14844  DICT_FREE(ctxt->version);
14845  ctxt->version = NULL;
14846  DICT_FREE(ctxt->encoding);
14847  ctxt->encoding = NULL;
14848  DICT_FREE(ctxt->directory);
14849  ctxt->directory = NULL;
14850  DICT_FREE(ctxt->extSubURI);
14851  ctxt->extSubURI = NULL;
14852  DICT_FREE(ctxt->extSubSystem);
14853  ctxt->extSubSystem = NULL;
14854  if (ctxt->myDoc != NULL)
14855  xmlFreeDoc(ctxt->myDoc);
14856  ctxt->myDoc = NULL;
14857 
14858  ctxt->standalone = -1;
14859  ctxt->hasExternalSubset = 0;
14860  ctxt->hasPErefs = 0;
14861  ctxt->html = 0;
14862  ctxt->external = 0;
14863  ctxt->instate = XML_PARSER_START;
14864  ctxt->token = 0;
14865 
14866  ctxt->wellFormed = 1;
14867  ctxt->nsWellFormed = 1;
14868  ctxt->disableSAX = 0;
14869  ctxt->valid = 1;
14870 #if 0
14871  ctxt->vctxt.userData = ctxt;
14874 #endif
14875  ctxt->record_info = 0;
14876  ctxt->nbChars = 0;
14877  ctxt->checkIndex = 0;
14878  ctxt->inSubset = 0;
14879  ctxt->errNo = XML_ERR_OK;
14880  ctxt->depth = 0;
14882  ctxt->catalogs = NULL;
14883  ctxt->nbentities = 0;
14884  ctxt->sizeentities = 0;
14885  ctxt->sizeentcopy = 0;
14886  xmlInitNodeInfoSeq(&ctxt->node_seq);
14887 
14888  if (ctxt->attsDefault != NULL) {
14890  ctxt->attsDefault = NULL;
14891  }
14892  if (ctxt->attsSpecial != NULL) {
14893  xmlHashFree(ctxt->attsSpecial, NULL);
14894  ctxt->attsSpecial = NULL;
14895  }
14896 
14897 #ifdef LIBXML_CATALOG_ENABLED
14898  if (ctxt->catalogs != NULL)
14899  xmlCatalogFreeLocal(ctxt->catalogs);
14900 #endif
14901  if (ctxt->lastError.code != XML_ERR_OK)
14902  xmlResetError(&ctxt->lastError);
14903 }
xmlParserInputState instate
Definition: parser.h:223
unsigned long sizeentities
Definition: parser.h:304
int * spaceTab
Definition: parser.h:247
xmlChar * extSubURI
Definition: parser.h:240
long checkIndex
Definition: parser.h:235
int nsWellFormed
Definition: parser.h:286
xmlValidityErrorFunc error
Definition: valid.h:84
int external
Definition: parser.h:217
long nbChars
Definition: parser.h:234
const xmlChar * name
Definition: parser.h:229
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
xmlError lastError
Definition: parser.h:301
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:320
int standalone
Definition: parser.h:192
xmlHashTablePtr attsDefault
Definition: parser.h:284
smooth NULL
Definition: ftsmooth.c:416
xmlChar * extSubSystem
Definition: parser.h:241
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
xmlDictPtr dict
Definition: parser.h:263
#define DICT_FREE(str)
Definition: parser.c:14801
XMLPUBFUN void XMLCALL xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
int wellFormed
Definition: parser.h:188
xmlNodePtr node
Definition: parser.h:205
int record_info
Definition: parser.h:210
int hasPErefs
Definition: parser.h:216
xmlParserInputPtr inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1740
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
xmlDocPtr myDoc
Definition: parser.h:187
const xmlChar * encoding
Definition: parser.h:191
const xmlChar * version
Definition: parser.h:190
void * catalogs
Definition: parser.h:260
int hasExternalSubset
Definition: parser.h:215
XMLPUBFUN void XMLCALL xmlResetError(xmlErrorPtr err)
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
unsigned long sizeentcopy
Definition: parser.h:313
__XML_EXTERNC typedef xmlDict * xmlDictPtr
Definition: dict.h:24
GLenum GLenum GLenum input
Definition: glext.h:9031
int inSubset
Definition: parser.h:238
xmlHashTablePtr attsSpecial
Definition: parser.h:285
char * directory
Definition: parser.h:226
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityError(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
int code
Definition: xmlerror.h:80
void * userData
Definition: valid.h:83
xmlValidCtxt vctxt
Definition: parser.h:221
int * space
Definition: parser.h:244
xmlValidityWarningFunc warning
Definition: valid.h:85
xmlParserNodeInfoSeq node_seq
Definition: parser.h:211
XMLPUBFUN void XMLCALL xmlHashDefaultDeallocator(void *entry, const xmlChar *name)
unsigned long nbentities
Definition: parser.h:303

Referenced by xmlClearParserCtxt(), xmlCtxtReadDoc(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), and xmlCtxtResetPush().

◆ xmlCtxtResetPush()

XMLPUBFUN int XMLCALL xmlCtxtResetPush ( xmlParserCtxtPtr  ctxt,
const char chunk,
int  size,
const char filename,
const char encoding 
)

xmlCtxtResetPush: @ctxt: an XML parser context @chunk: a pointer to an array of chars @size: number of chars in the array @filename: an optional file name or URI @encoding: the document encoding, or NULL

Reset a push parser context

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

Definition at line 14918 of file parser.c.

14920 {
14921  xmlParserInputPtr inputStream;
14924 
14925  if (ctxt == NULL)
14926  return(1);
14927 
14928  if ((encoding == NULL) && (chunk != NULL) && (size >= 4))
14929  enc = xmlDetectCharEncoding((const xmlChar *) chunk, size);
14930 
14932  if (buf == NULL)
14933  return(1);
14934 
14935  if (ctxt == NULL) {
14937  return(1);
14938  }
14939 
14940  xmlCtxtReset(ctxt);
14941 
14942  if (ctxt->pushTab == NULL) {
14943  ctxt->pushTab = (void **) xmlMalloc(ctxt->nameMax * 3 *
14944  sizeof(xmlChar *));
14945  if (ctxt->pushTab == NULL) {
14946  xmlErrMemory(ctxt, NULL);
14948  return(1);
14949  }
14950  }
14951 
14952  if (filename == NULL) {
14953  ctxt->directory = NULL;
14954  } else {
14956  }
14957 
14958  inputStream = xmlNewInputStream(ctxt);
14959  if (inputStream == NULL) {
14961  return(1);
14962  }
14963 
14964  if (filename == NULL)
14965  inputStream->filename = NULL;
14966  else
14967  inputStream->filename = (char *)
14968  xmlCanonicPath((const xmlChar *) filename);
14969  inputStream->buf = buf;
14970  xmlBufResetInput(buf->buffer, inputStream);
14971 
14972  inputPush(ctxt, inputStream);
14973 
14974  if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
14975  (ctxt->input->buf != NULL)) {
14976  size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
14977  size_t cur = ctxt->input->cur - ctxt->input->base;
14978 
14980 
14981  xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
14982 #ifdef DEBUG_PUSH
14983  xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
14984 #endif
14985  }
14986 
14987  if (encoding != NULL) {
14989 
14990  if (ctxt->encoding != NULL)
14991  xmlFree((xmlChar *) ctxt->encoding);
14992  ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
14993 
14995  if (hdlr != NULL) {
14996  xmlSwitchToEncoding(ctxt, hdlr);
14997  } else {
14998  xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
14999  "Unsupported encoding %s\n", BAD_CAST encoding);
15000  }
15001  } else if (enc != XML_CHAR_ENCODING_NONE) {
15002  xmlSwitchEncoding(ctxt, enc);
15003  }
15004 
15005  return(0);
15006 }
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input, size_t base, size_t cur)
Definition: buf.c:1333
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN int XMLCALL xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf)
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
const xmlChar * cur
Definition: parser.h:61
xmlCharEncoding
Definition: encoding.h:58
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1283
const char * filename
Definition: ioapi.h:135
const xmlChar * base
Definition: parser.h:60
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14813
xmlParserInputPtr input
Definition: parser.h:199
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2370
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlAllocParserInputBuffer(xmlCharEncoding enc)
#define BAD_CAST
Definition: xmlstring.h:35
void ** pushTab
Definition: parser.h:283
GLsizeiptr size
Definition: glext.h:5919
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
xmlBufPtr buffer
Definition: xmlIO.h:132
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:932
size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1302
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1641
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
ed encoding
Definition: write.c:2839
xmlParserInputBufferPtr buf
Definition: parser.h:56
const char * filename
Definition: parser.h:58
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
char * directory
Definition: parser.h:226
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ xmlCtxtUseOptions()

XMLPUBFUN int XMLCALL xmlCtxtUseOptions ( xmlParserCtxtPtr  ctxt,
int  options 
)

xmlCtxtUseOptions: @ctxt: an XML parser context @options: a combination of xmlParserOption

Applies the options to the parser context

Returns 0 in case of success, the set of unknown or unimplemented options in case of error.

Definition at line 15162 of file parser.c.

15163 {
15164  return(xmlCtxtUseOptionsInternal(ctxt, options, NULL));
15165 }
smooth NULL
Definition: ftsmooth.c:416
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15021

Referenced by parseAndPrintFile(), and xsltDocDefaultLoaderFunc().

◆ xmlFreeParserCtxt()

XMLPUBFUN void XMLCALL xmlFreeParserCtxt ( xmlParserCtxtPtr  ctxt)

xmlFreeParserCtxt: @ctxt: an XML parser context

Free all the memory used by a parser context. However the parsed document in ctxt->myDoc is not freed.

Definition at line 1775 of file parserInternals.c.

1776 {
1778 
1779  if (ctxt == NULL) return;
1780 
1781  while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
1783  }
1784  if (ctxt->spaceTab != NULL) xmlFree(ctxt->spaceTab);
1785  if (ctxt->nameTab != NULL) xmlFree((xmlChar * *)ctxt->nameTab);
1786  if (ctxt->nodeTab != NULL) xmlFree(ctxt->nodeTab);
1787  if (ctxt->nodeInfoTab != NULL) xmlFree(ctxt->nodeInfoTab);
1788  if (ctxt->inputTab != NULL) xmlFree(ctxt->inputTab);
1789  if (ctxt->version != NULL) xmlFree((char *) ctxt->version);
1790  if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding);
1791  if (ctxt->extSubURI != NULL) xmlFree((char *) ctxt->extSubURI);
1792  if (ctxt->extSubSystem != NULL) xmlFree((char *) ctxt->extSubSystem);
1793 #ifdef LIBXML_SAX1_ENABLED
1794  if ((ctxt->sax != NULL) &&
1796 #else
1797  if (ctxt->sax != NULL)
1798 #endif /* LIBXML_SAX1_ENABLED */
1799  xmlFree(ctxt->sax);
1800  if (ctxt->directory != NULL) xmlFree((char *) ctxt->directory);
1801  if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab);
1802  if (ctxt->atts != NULL) xmlFree((xmlChar * *)ctxt->atts);
1803  if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);
1804  if (ctxt->nsTab != NULL) xmlFree((char *) ctxt->nsTab);
1805  if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab);
1806  if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs);
1807  if (ctxt->attsDefault != NULL)
1809  if (ctxt->attsSpecial != NULL)
1810  xmlHashFree(ctxt->attsSpecial, NULL);
1811  if (ctxt->freeElems != NULL) {
1812  xmlNodePtr cur, next;
1813 
1814  cur = ctxt->freeElems;
1815  while (cur != NULL) {
1816  next = cur->next;
1817  xmlFree(cur);
1818  cur = next;
1819  }
1820  }
1821  if (ctxt->freeAttrs != NULL) {
1822  xmlAttrPtr cur, next;
1823 
1824  cur = ctxt->freeAttrs;
1825  while (cur != NULL) {
1826  next = cur->next;
1827  xmlFree(cur);
1828  cur = next;
1829  }
1830  }
1831  /*
1832  * cleanup the error strings
1833  */
1834  if (ctxt->lastError.message != NULL)
1835  xmlFree(ctxt->lastError.message);
1836  if (ctxt->lastError.file != NULL)
1837  xmlFree(ctxt->lastError.file);
1838  if (ctxt->lastError.str1 != NULL)
1839  xmlFree(ctxt->lastError.str1);
1840  if (ctxt->lastError.str2 != NULL)
1841  xmlFree(ctxt->lastError.str2);
1842  if (ctxt->lastError.str3 != NULL)
1843  xmlFree(ctxt->lastError.str3);
1844 
1845 #ifdef LIBXML_CATALOG_ENABLED
1846  if (ctxt->catalogs != NULL)
1847  xmlCatalogFreeLocal(ctxt->catalogs);
1848 #endif
1849  xmlFree(ctxt);
1850 }
int * attallocs
Definition: parser.h:282
int * spaceTab
Definition: parser.h:247
xmlChar * extSubURI
Definition: parser.h:240
char * file
Definition: xmlerror.h:83
xmlParserInputPtr * inputTab
Definition: parser.h:202
struct _xmlAttr * next
Definition: tree.h:441
xmlAttrPtr freeAttrs
Definition: parser.h:296
xmlNodePtr * nodeTab
Definition: parser.h:208
xmlNodePtr * nodeTab
Definition: valid.h:91
xmlError lastError
Definition: parser.h:301
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:320
char * message
Definition: xmlerror.h:81
xmlHashTablePtr attsDefault
Definition: parser.h:284
smooth NULL
Definition: ftsmooth.c:416
xmlChar * extSubSystem
Definition: parser.h:241
xmlDictPtr dict
Definition: parser.h:263
void ** pushTab
Definition: parser.h:283
char * str2
Definition: xmlerror.h:86
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler
Definition: globals.h:321
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
void xmlFreeInputStream(xmlParserInputPtr input)
Definition: tree.h:489
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN void XMLCALL xmlDictFree(xmlDictPtr dict)
Definition: dict.c:793
struct _xmlSAXHandler * sax
Definition: parser.h:185
const xmlChar * version
Definition: parser.h:190
void * catalogs
Definition: parser.h:260
XMLPUBFUN xmlParserInputPtr XMLCALL inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1740
const xmlChar ** atts
Definition: parser.h:264
char * str3
Definition: xmlerror.h:87
static unsigned __int64 next
Definition: rand_nt.c:6
GLenum GLenum GLenum input
Definition: glext.h:9031
xmlParserNodeInfo * nodeInfoTab
Definition: parser.h:310
struct _xmlNode * next
Definition: tree.h:496
xmlHashTablePtr attsSpecial
Definition: parser.h:285
char * directory
Definition: parser.h:226
const xmlChar ** nsTab
Definition: parser.h:281
Definition: tree.h:434
const xmlChar ** nameTab
Definition: parser.h:232
xmlValidCtxt vctxt
Definition: parser.h:221
xmlNodePtr freeElems
Definition: parser.h:294
XMLPUBFUN void XMLCALL xmlHashDefaultDeallocator(void *entry, const xmlChar *name)
char * str1
Definition: xmlerror.h:85

Referenced by main(), parseAndPrintFile(), testSAX(), xmlCreateEntityParserCtxtInternal(), xmlCreateIOParserCtxt(), xmlCreateMemoryParserCtxt(), xmlCreateURLParserCtxt(), xmlDoRead(), xmlNewParserCtxt(), xmlParseBalancedChunkMemoryInternal(), xmlParseCtxtExternalEntity(), xmlParseExternalEntityPrivate(), xmlParseInNodeContext(), xmlReadFd(), xmlReadIO(), and xsltDocDefaultLoaderFunc().

◆ xmlGetExternalEntityLoader()

XMLPUBFUN xmlExternalEntityLoader XMLCALL xmlGetExternalEntityLoader ( void  )

Referenced by main().

◆ xmlHasFeature()

XMLPUBFUN int XMLCALL xmlHasFeature ( xmlFeature  feature)

xmlHasFeature: @feature: the feature to be examined

Examines if the library has been compiled with a given feature.

Returns a non-zero value if the feature exist, otherwise zero. Returns zero (0) if the feature does not exist or an unknown unknown feature is requested, non-zero otherwise.

Definition at line 846 of file parser.c.

847 {
848  switch (feature) {
849  case XML_WITH_THREAD:
850 #ifdef LIBXML_THREAD_ENABLED
851  return(1);
852 #else
853  return(0);
854 #endif
855  case XML_WITH_TREE:
856 #ifdef LIBXML_TREE_ENABLED
857  return(1);
858 #else
859  return(0);
860 #endif
861  case XML_WITH_OUTPUT:
862 #ifdef LIBXML_OUTPUT_ENABLED
863  return(1);
864 #else
865  return(0);
866 #endif
867  case XML_WITH_PUSH:
868 #ifdef LIBXML_PUSH_ENABLED
869  return(1);
870 #else
871  return(0);
872 #endif
873  case XML_WITH_READER:
874 #ifdef LIBXML_READER_ENABLED
875  return(1);
876 #else
877  return(0);
878 #endif
879  case XML_WITH_PATTERN:
880 #ifdef LIBXML_PATTERN_ENABLED
881  return(1);
882 #else
883  return(0);
884 #endif
885  case XML_WITH_WRITER:
886 #ifdef LIBXML_WRITER_ENABLED
887  return(1);
888 #else
889  return(0);
890 #endif
891  case XML_WITH_SAX1:
892 #ifdef LIBXML_SAX1_ENABLED
893  return(1);
894 #else
895  return(0);
896 #endif
897  case XML_WITH_FTP:
898 #ifdef LIBXML_FTP_ENABLED
899  return(1);
900 #else
901  return(0);
902 #endif
903  case XML_WITH_HTTP:
904 #ifdef LIBXML_HTTP_ENABLED
905  return(1);
906 #else
907  return(0);
908 #endif
909  case XML_WITH_VALID:
910 #ifdef LIBXML_VALID_ENABLED
911  return(1);
912 #else
913  return(0);
914 #endif
915  case XML_WITH_HTML:
916 #ifdef LIBXML_HTML_ENABLED
917  return(1);
918 #else
919  return(0);
920 #endif
921  case XML_WITH_LEGACY:
922 #ifdef LIBXML_LEGACY_ENABLED
923  return(1);
924 #else
925  return(0);
926 #endif
927  case XML_WITH_C14N:
928 #ifdef LIBXML_C14N_ENABLED
929  return(1);
930 #else
931  return(0);
932 #endif
933  case XML_WITH_CATALOG:
934 #ifdef LIBXML_CATALOG_ENABLED
935  return(1);
936 #else
937  return(0);
938 #endif
939  case XML_WITH_XPATH:
940 #ifdef LIBXML_XPATH_ENABLED
941  return(1);
942 #else
943  return(0);
944 #endif
945  case XML_WITH_XPTR:
946 #ifdef LIBXML_XPTR_ENABLED
947  return(1);
948 #else
949  return(0);
950 #endif
951  case XML_WITH_XINCLUDE:
952 #ifdef LIBXML_XINCLUDE_ENABLED
953  return(1);
954 #else
955  return(0);
956 #endif
957  case XML_WITH_ICONV:
958 #ifdef LIBXML_ICONV_ENABLED
959  return(1);
960 #else
961  return(0);
962 #endif
963  case XML_WITH_ISO8859X:
964 #ifdef LIBXML_ISO8859X_ENABLED
965  return(1);
966 #else
967  return(0);
968 #endif
969  case XML_WITH_UNICODE:
970 #ifdef LIBXML_UNICODE_ENABLED
971  return(1);
972 #else
973  return(0);
974 #endif
975  case XML_WITH_REGEXP:
976 #ifdef LIBXML_REGEXP_ENABLED
977  return(1);
978 #else
979  return(0);
980 #endif
981  case XML_WITH_AUTOMATA:
982 #ifdef LIBXML_AUTOMATA_ENABLED
983  return(1);
984 #else
985  return(0);
986 #endif
987  case XML_WITH_EXPR:
988 #ifdef LIBXML_EXPR_ENABLED
989  return(1);
990 #else
991  return(0);
992 #endif
993  case XML_WITH_SCHEMAS:
994 #ifdef LIBXML_SCHEMAS_ENABLED
995  return(1);
996 #else
997  return(0);
998 #endif
999  case XML_WITH_SCHEMATRON:
1000 #ifdef LIBXML_SCHEMATRON_ENABLED
1001  return(1);
1002 #else
1003  return(0);
1004 #endif
1005  case XML_WITH_MODULES:
1006 #ifdef LIBXML_MODULES_ENABLED
1007  return(1);
1008 #else
1009  return(0);
1010 #endif
1011  case XML_WITH_DEBUG:
1012 #ifdef LIBXML_DEBUG_ENABLED
1013  return(1);
1014 #else
1015  return(0);
1016 #endif
1017  case XML_WITH_DEBUG_MEM:
1018 #ifdef DEBUG_MEMORY_LOCATION
1019  return(1);
1020 #else
1021  return(0);
1022 #endif
1023  case XML_WITH_DEBUG_RUN:
1024 #ifdef LIBXML_DEBUG_RUNTIME
1025  return(1);
1026 #else
1027  return(0);
1028 #endif
1029  case XML_WITH_ZLIB:
1030 #ifdef LIBXML_ZLIB_ENABLED
1031  return(1);
1032 #else
1033  return(0);
1034 #endif
1035  case XML_WITH_LZMA:
1036 #ifdef LIBXML_LZMA_ENABLED
1037  return(1);
1038 #else
1039  return(0);
1040 #endif
1041  case XML_WITH_ICU:
1042 #ifdef LIBXML_ICU_ENABLED
1043  return(1);
1044 #else
1045  return(0);
1046 #endif
1047  default:
1048  break;
1049  }
1050  return(0);
1051 }
INTERNETFEATURELIST feature
Definition: misc.c:1719

Referenced by showVersion().

◆ xmlInitNodeInfoSeq()

XMLPUBFUN void XMLCALL xmlInitNodeInfoSeq ( xmlParserNodeInfoSeqPtr  seq)

xmlInitNodeInfoSeq: @seq: a node info sequence pointer

– Initialize (set to initial state) node info sequence

Definition at line 1934 of file parserInternals.c.

1935 {
1936  if (seq == NULL)
1937  return;
1938  seq->length = 0;
1939  seq->maximum = 0;
1940  seq->buffer = NULL;
1941 }
xmlParserNodeInfo * buffer
Definition: parser.h:103
smooth NULL
Definition: ftsmooth.c:416
unsigned long length
Definition: parser.h:102
unsigned long maximum
Definition: parser.h:101

Referenced by xmlClearNodeInfoSeq(), xmlCtxtReset(), and xmlInitParserCtxt().

◆ xmlInitParser()

XMLPUBFUN void XMLCALL xmlInitParser ( void  )

xmlInitParser:

Initialization function for the XML parser. This is not reentrant. Call once before processing in case of use in multithreaded programs.

Definition at line 14706 of file parser.c.

14706  {
14707  if (xmlParserInitialized != 0)
14708  return;
14709 
14710 #ifdef LIBXML_THREAD_ENABLED
14712  if (xmlParserInitialized == 0) {
14713 #endif
14714  xmlInitThreads();
14715  xmlInitGlobals();
14717  (xmlGenericError == NULL))
14719  xmlInitMemory();
14724 #ifdef LIBXML_OUTPUT_ENABLED
14725  xmlRegisterDefaultOutputCallbacks();
14726 #endif /* LIBXML_OUTPUT_ENABLED */
14727 #ifdef LIBXML_HTML_ENABLED
14728  htmlInitAutoClose();
14729  htmlDefaultSAXHandlerInit();
14730 #endif
14731 #ifdef LIBXML_XPATH_ENABLED
14732  xmlXPathInit();
14733 #endif
14735 #ifdef LIBXML_THREAD_ENABLED
14736  }
14738 #endif
14739 }
void __xmlGlobalInitMutexUnlock(void)
Definition: threads.c:502
XMLPUBFUN void XMLCALL xmlRegisterDefaultInputCallbacks(void)
void XMLCDECL xmlGenericErrorDefaultFunc(void *ctx, const char *msg,...)
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN int XMLCALL xmlInitMemory(void)
Definition: xmlmemory.c:964
XMLPUBFUN void XMLCALL initGenericErrorDefaultFunc(xmlGenericErrorFunc *handler)
Definition: error.c:90
XMLPUBFUN void XMLCALL xmlInitThreads(void)
Definition: threads.c:858
XMLPUBFUN void XMLCALL xmlInitGlobals(void)
Definition: globals.c:47
XMLPUBFUN void XMLCALL xmlInitCharEncodingHandlers(void)
Definition: encoding.c:1397
XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit(void)
Definition: SAX2.c:2939
void void __xmlGlobalInitMutexLock(void)
Definition: threads.c:427
XMLPUBFUN int XMLCALL xmlInitializeDict(void)
Definition: dict.c:159
static int xmlParserInitialized
Definition: parser.c:14695

Referenced by DllMain(), xmlCheckVersion(), xmlCtxtReadDoc(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlParseDocument(), xmlReadDoc(), xmlReadFd(), xmlReadFile(), xmlReadIO(), and xmlReadMemory().

◆ xmlInitParserCtxt()

XMLPUBFUN int XMLCALL xmlInitParserCtxt ( xmlParserCtxtPtr  ctxt)

xmlInitParserCtxt: @ctxt: an XML parser context

Initialize a parser context

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

Definition at line 1589 of file parserInternals.c.

1590 {
1592 
1593  if(ctxt==NULL) {
1594  xmlErrInternal(NULL, "Got NULL parser context\n", NULL);
1595  return(-1);
1596  }
1597 
1599 
1600  if (ctxt->dict == NULL)
1601  ctxt->dict = xmlDictCreate();
1602  if (ctxt->dict == NULL) {
1603  xmlErrMemory(NULL, "cannot initialize parser context\n");
1604  return(-1);
1605  }
1607 
1608  if (ctxt->sax == NULL)
1609  ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
1610  if (ctxt->sax == NULL) {
1611  xmlErrMemory(NULL, "cannot initialize parser context\n");
1612  return(-1);
1613  }
1614  else
1615  xmlSAXVersion(ctxt->sax, 2);
1616 
1617  ctxt->maxatts = 0;
1618  ctxt->atts = NULL;
1619  /* Allocate the Input stack */
1620  if (ctxt->inputTab == NULL) {
1621  ctxt->inputTab = (xmlParserInputPtr *)
1622  xmlMalloc(5 * sizeof(xmlParserInputPtr));
1623  ctxt->inputMax = 5;
1624  }
1625  if (ctxt->inputTab == NULL) {
1626  xmlErrMemory(NULL, "cannot initialize parser context\n");
1627  ctxt->inputNr = 0;
1628  ctxt->inputMax = 0;
1629  ctxt->input = NULL;
1630  return(-1);
1631  }
1632  while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
1634  }
1635  ctxt->inputNr = 0;
1636  ctxt->input = NULL;
1637 
1638  ctxt->version = NULL;
1639  ctxt->encoding = NULL;
1640  ctxt->standalone = -1;
1641  ctxt->hasExternalSubset = 0;
1642  ctxt->hasPErefs = 0;
1643  ctxt->html = 0;
1644  ctxt->external = 0;
1645  ctxt->instate = XML_PARSER_START;
1646  ctxt->token = 0;
1647  ctxt->directory = NULL;
1648 
1649  /* Allocate the Node stack */
1650  if (ctxt->nodeTab == NULL) {
1651  ctxt->nodeTab = (xmlNodePtr *) xmlMalloc(10 * sizeof(xmlNodePtr));
1652  ctxt->nodeMax = 10;
1653  }
1654  if (ctxt->nodeTab == NULL) {
1655  xmlErrMemory(NULL, "cannot initialize parser context\n");
1656  ctxt->nodeNr = 0;
1657  ctxt->nodeMax = 0;
1658  ctxt->node = NULL;
1659  ctxt->inputNr = 0;
1660  ctxt->inputMax = 0;
1661  ctxt->input = NULL;
1662  return(-1);
1663  }
1664  ctxt->nodeNr = 0;
1665  ctxt->node = NULL;
1666 
1667  /* Allocate the Name stack */
1668  if (ctxt->nameTab == NULL) {
1669  ctxt->nameTab = (const xmlChar **) xmlMalloc(10 * sizeof(xmlChar *));
1670  ctxt->nameMax = 10;
1671  }
1672  if (ctxt->nameTab == NULL) {
1673  xmlErrMemory(NULL, "cannot initialize parser context\n");
1674  ctxt->nodeNr = 0;
1675  ctxt->nodeMax = 0;
1676  ctxt->node = NULL;
1677  ctxt->inputNr = 0;
1678  ctxt->inputMax = 0;
1679  ctxt->input = NULL;
1680  ctxt->nameNr = 0;
1681  ctxt->nameMax = 0;
1682  ctxt->name = NULL;
1683  return(-1);
1684  }
1685  ctxt->nameNr = 0;
1686  ctxt->name = NULL;
1687 
1688  /* Allocate the space stack */
1689  if (ctxt->spaceTab == NULL) {
1690  ctxt->spaceTab = (int *) xmlMalloc(10 * sizeof(int));
1691  ctxt->spaceMax = 10;
1692  }
1693  if (ctxt->spaceTab == NULL) {
1694  xmlErrMemory(NULL, "cannot initialize parser context\n");
1695  ctxt->nodeNr = 0;
1696  ctxt->nodeMax = 0;
1697  ctxt->node = NULL;
1698  ctxt->inputNr = 0;
1699  ctxt->inputMax = 0;
1700  ctxt->input = NULL;
1701  ctxt->nameNr = 0;
1702  ctxt->nameMax = 0;
1703  ctxt->name = NULL;
1704  ctxt->spaceNr = 0;
1705  ctxt->spaceMax = 0;
1706  ctxt->space = NULL;
1707  return(-1);
1708  }
1709  ctxt->spaceNr = 1;
1710  ctxt->spaceMax = 10;
1711  ctxt->spaceTab[0] = -1;
1712  ctxt->space = &ctxt->spaceTab[0];
1713  ctxt->userData = ctxt;
1714  ctxt->myDoc = NULL;
1715  ctxt->wellFormed = 1;
1716  ctxt->nsWellFormed = 1;
1717  ctxt->valid = 1;
1719  if (ctxt->loadsubset) {
1720  ctxt->options |= XML_PARSE_DTDLOAD;
1721  }
1724  if (ctxt->pedantic) {
1725  ctxt->options |= XML_PARSE_PEDANTIC;
1726  }
1729  if (ctxt->keepBlanks == 0) {
1730  ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
1731  ctxt->options |= XML_PARSE_NOBLANKS;
1732  }
1733 
1734  ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0;
1735  ctxt->vctxt.userData = ctxt;
1738  if (ctxt->validate) {
1739  if (xmlGetWarningsDefaultValue == 0)
1740  ctxt->vctxt.warning = NULL;
1741  else
1743  ctxt->vctxt.nodeMax = 0;
1744  ctxt->options |= XML_PARSE_DTDVALID;
1745  }
1747  if (ctxt->replaceEntities) {
1748  ctxt->options |= XML_PARSE_NOENT;
1749  }
1750  ctxt->record_info = 0;
1751  ctxt->nbChars = 0;
1752  ctxt->checkIndex = 0;
1753  ctxt->inSubset = 0;
1754  ctxt->errNo = XML_ERR_OK;
1755  ctxt->depth = 0;
1757  ctxt->catalogs = NULL;
1758  ctxt->nbentities = 0;
1759  ctxt->sizeentities = 0;
1760  ctxt->sizeentcopy = 0;
1761  ctxt->input_id = 1;
1762  xmlInitNodeInfoSeq(&ctxt->node_seq);
1763  return(0);
1764 }
int nodeMax
Definition: valid.h:90
xmlParserInputState instate
Definition: parser.h:223
unsigned long sizeentities
Definition: parser.h:304
XMLPUBVAR int xmlGetWarningsDefaultValue
Definition: globals.h:378
int * spaceTab
Definition: parser.h:247
xmlParserInputPtr * inputTab
Definition: parser.h:202
unsigned int finishDtd
Definition: valid.h:93
XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreate(void)
Definition: dict.c:568
long checkIndex
Definition: parser.h:235
int pedantic
Definition: parser.h:255
XMLPUBFUN size_t XMLCALL xmlDictSetLimit(xmlDictPtr dict, size_t limit)
Definition: dict.c:1256
int nsWellFormed
Definition: parser.h:286
xmlValidityErrorFunc error
Definition: valid.h:84
xmlNodePtr * nodeTab
Definition: parser.h:208
XMLPUBVAR int xmlSubstituteEntitiesDefaultValue
Definition: globals.h:467
int external
Definition: parser.h:217
XMLPUBVAR int xmlLoadExtDtdDefaultValue
Definition: globals.h:423
long nbChars
Definition: parser.h:234
const xmlChar * name
Definition: parser.h:229
int input_id
Definition: parser.h:312
xmlParserInputPtr input
Definition: parser.h:199
int spaceMax
Definition: parser.h:246
XMLPUBFUN int XMLCALL xmlSAXVersion(xmlSAXHandler *hdlr, int version)
Definition: SAX2.c:2866
int standalone
Definition: parser.h:192
XMLPUBVAR int xmlLineNumbersDefaultValue
Definition: globals.h:414
int linenumbers
Definition: parser.h:259
int replaceEntities
Definition: parser.h:189
smooth NULL
Definition: ftsmooth.c:416
xmlDictPtr dict
Definition: parser.h:263
#define XML_MAX_DICTIONARY_LIMIT
int validate
Definition: parser.h:220
XMLPUBFUN void XMLCALL xmlSAX2IgnorableWhitespace(void *ctx, const xmlChar *ch, int len)
int inputMax
Definition: parser.h:201
XMLPUBVAR int xmlKeepBlanksDefaultValue
Definition: globals.h:405
int wellFormed
Definition: parser.h:188
xmlNodePtr node
Definition: parser.h:205
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
int record_info
Definition: parser.h:210
int hasPErefs
Definition: parser.h:216
XMLPUBVAR int xmlPedanticParserDefaultValue
Definition: globals.h:449
XMLPUBVAR int xmlDoValidityCheckingDefaultValue
Definition: globals.h:337
void xmlFreeInputStream(xmlParserInputPtr input)
Definition: tree.h:489
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
const xmlChar * version
Definition: parser.h:190
void * catalogs
Definition: parser.h:260
int loadsubset
Definition: parser.h:258
int hasExternalSubset
Definition: parser.h:215
XMLPUBFUN xmlParserInputPtr XMLCALL inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1740
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
unsigned long sizeentcopy
Definition: parser.h:313
const xmlChar ** atts
Definition: parser.h:264
GLenum GLenum GLenum input
Definition: glext.h:9031
void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
int inSubset
Definition: parser.h:238
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
char * directory
Definition: parser.h:226
XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit(void)
Definition: SAX2.c:2939
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityError(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
int keepBlanks
Definition: parser.h:236
void * userData
Definition: valid.h:83
const xmlChar ** nameTab
Definition: parser.h:232
xmlValidCtxt vctxt
Definition: parser.h:221
int * space
Definition: parser.h:244
void * userData
Definition: parser.h:186
xmlValidityWarningFunc warning
Definition: valid.h:85
xmlParserNodeInfoSeq node_seq
Definition: parser.h:211
unsigned long nbentities
Definition: parser.h:303

Referenced by xmlNewParserCtxt().

◆ xmlKeepBlanksDefault()

XMLPUBFUN int XMLCALL xmlKeepBlanksDefault ( int  val)

xmlKeepBlanksDefault: @val: int 0 or 1

Set and return the previous value for default blanks text nodes support. The 1.x version of the parser used an heuristic to try to detect ignorable white spaces. As a result the SAX callback was generating xmlSAX2IgnorableWhitespace() callbacks instead of characters() one, and when using the DOM output text nodes containing those blanks were not generated. The 2.x and later version will switch to the XML standard way and ignorableWhitespace() are only generated when running the parser in validating mode and when the current element doesn't allow CDATA or mixed content. This function is provided as a way to force the standard behavior on 1.X libs and to switch back to the old mode for compatibility when running 1.X client code on 2.X . Upgrade of 1.X code should be done by using xmlIsBlankNode() commodity function to detect the "empty" nodes generated. This value also affect autogeneration of indentation when saving code if blanks sections are kept, indentation is not generated.

Returns the last value for 0 for no substitution, 1 for substitution.

Definition at line 2156 of file parserInternals.c.

2156  {
2157  int old = xmlKeepBlanksDefaultValue;
2158 
2160  if (!val) xmlIndentTreeOutput = 1;
2161  return(old);
2162 }
XMLPUBVAR int xmlIndentTreeOutput
Definition: globals.h:387
GLuint GLfloat * val
Definition: glext.h:7180
XMLPUBVAR int xmlKeepBlanksDefaultValue
Definition: globals.h:405

Referenced by main().

◆ xmlLineNumbersDefault()

XMLPUBFUN int XMLCALL xmlLineNumbersDefault ( int  val)

xmlLineNumbersDefault: @val: int 0 or 1

Set and return the previous value for enabling line numbers in elements contents. This may break on old application and is turned off by default.

Returns the last value for 0 for no substitution, 1 for substitution.

Definition at line 2102 of file parserInternals.c.

2102  {
2103  int old = xmlLineNumbersDefaultValue;
2104 
2106  return(old);
2107 }
XMLPUBVAR int xmlLineNumbersDefaultValue
Definition: globals.h:414
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by main().

◆ xmlLoadExternalEntity()

◆ xmlNewIOInputStream()

xmlNewIOInputStream: @ctxt: an XML parser context @input: an I/O Input @enc: the charset encoding if known

Create a new input stream structure encapsulating the @input into a stream suitable for the parser.

Returns the new input stream or NULL

Definition at line 1398 of file parserInternals.c.

1399  {
1400  xmlParserInputPtr inputStream;
1401 
1402  if (input == NULL) return(NULL);
1404  xmlGenericError(xmlGenericErrorContext, "new input from I/O\n");
1405  inputStream = xmlNewInputStream(ctxt);
1406  if (inputStream == NULL) {
1407  return(NULL);
1408  }
1409  inputStream->filename = NULL;
1410  inputStream->buf = input;
1411  xmlBufResetInput(inputStream->buf->buffer, inputStream);
1412 
1413  if (enc != XML_CHAR_ENCODING_NONE) {
1414  xmlSwitchEncoding(ctxt, enc);
1415  }
1416 
1417  return(inputStream);
1418 }
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1283
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
xmlBufPtr buffer
Definition: xmlIO.h:132
int xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
xmlParserInputBufferPtr buf
Definition: parser.h:56
const char * filename
Definition: parser.h:58
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:432
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by testSAX(), xmlCreateIOParserCtxt(), xmlCtxtReadFd(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlReadFd(), and xmlReadIO().

◆ xmlNewParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt ( void  )

xmlNewParserCtxt:

Allocate and initialize a new parser context.

Returns the xmlParserCtxtPtr or NULL

Definition at line 1861 of file parserInternals.c.

1862 {
1863  xmlParserCtxtPtr ctxt;
1864 
1865  ctxt = (xmlParserCtxtPtr) xmlMalloc(sizeof(xmlParserCtxt));
1866  if (ctxt == NULL) {
1867  xmlErrMemory(NULL, "cannot allocate parser context\n");
1868  return(NULL);
1869  }
1870  memset(ctxt, 0, sizeof(xmlParserCtxt));
1871  if (xmlInitParserCtxt(ctxt) < 0) {
1872  xmlFreeParserCtxt(ctxt);
1873  return(NULL);
1874  }
1875  return(ctxt);
1876 }
void xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
smooth NULL
Definition: ftsmooth.c:416
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
#define memset(x, y, z)
Definition: compat.h:39
int xmlInitParserCtxt(xmlParserCtxtPtr ctxt)

Referenced by main(), parseAndPrintFile(), testSAX(), xmlCreateEntityParserCtxtInternal(), xmlCreateIOParserCtxt(), xmlCreateMemoryParserCtxt(), xmlCreateURLParserCtxt(), xmlReadFd(), xmlReadIO(), and xsltDocDefaultLoaderFunc().

◆ xmlParseCtxtExternalEntity()

XMLPUBFUN int XMLCALL xmlParseCtxtExternalEntity ( xmlParserCtxtPtr  ctx,
const xmlChar URL,
const xmlChar ID,
xmlNodePtr lst 
)

xmlParseCtxtExternalEntity: @ctx: the existing parsing context @URL: the URL for the entity to load @ID: the System ID for the entity to load @lst: the return value for the set of parsed nodes

Parse an external general entity within an existing parsing context An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.

[78] extParsedEnt ::= TextDecl? content

Returns 0 if the entity is well formed, -1 in case of args problem and the parser error code otherwise

Definition at line 12867 of file parser.c.

12868  {
12869  xmlParserCtxtPtr ctxt;
12870  xmlDocPtr newDoc;
12871  xmlNodePtr newRoot;
12872  xmlSAXHandlerPtr oldsax = NULL;
12873  int ret = 0;
12874  xmlChar start[4];
12875  xmlCharEncoding enc;
12876 
12877  if (ctx == NULL) return(-1);
12878 
12879  if (((ctx->depth > 40) && ((ctx->options & XML_PARSE_HUGE) == 0)) ||
12880  (ctx->depth > 1024)) {
12881  return(XML_ERR_ENTITY_LOOP);
12882  }
12883 
12884  if (lst != NULL)
12885  *lst = NULL;
12886  if ((URL == NULL) && (ID == NULL))
12887  return(-1);
12888  if (ctx->myDoc == NULL) /* @@ relax but check for dereferences */
12889  return(-1);
12890 
12891  ctxt = xmlCreateEntityParserCtxtInternal(URL, ID, NULL, ctx);
12892  if (ctxt == NULL) {
12893  return(-1);
12894  }
12895 
12896  oldsax = ctxt->sax;
12897  ctxt->sax = ctx->sax;
12898  xmlDetectSAX2(ctxt);
12899  newDoc = xmlNewDoc(BAD_CAST "1.0");
12900  if (newDoc == NULL) {
12901  xmlFreeParserCtxt(ctxt);
12902  return(-1);
12903  }
12904  newDoc->properties = XML_DOC_INTERNAL;
12905  if (ctx->myDoc->dict) {
12906  newDoc->dict = ctx->myDoc->dict;
12907  xmlDictReference(newDoc->dict);
12908  }
12909  if (ctx->myDoc != NULL) {
12910  newDoc->intSubset = ctx->myDoc->intSubset;
12911  newDoc->extSubset = ctx->myDoc->extSubset;
12912  }
12913  if (ctx->myDoc->URL != NULL) {
12914  newDoc->URL = xmlStrdup(ctx->myDoc->URL);
12915  }
12916  newRoot = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
12917  if (newRoot == NULL) {
12918  ctxt->sax = oldsax;
12919  xmlFreeParserCtxt(ctxt);
12920  newDoc->intSubset = NULL;
12921  newDoc->extSubset = NULL;
12922  xmlFreeDoc(newDoc);
12923  return(-1);
12924  }
12925  xmlAddChild((xmlNodePtr) newDoc, newRoot);
12926  nodePush(ctxt, newDoc->children);
12927  if (ctx->myDoc == NULL) {
12928  ctxt->myDoc = newDoc;
12929  } else {
12930  ctxt->myDoc = ctx->myDoc;
12931  newDoc->children->doc = ctx->myDoc;
12932  }
12933 
12934  /*
12935  * Get the 4 first bytes and decode the charset
12936  * if enc != XML_CHAR_ENCODING_NONE
12937  * plug some encoding conversion routines.
12938  */
12939  GROW
12940  if ((ctxt->input->end - ctxt->input->cur) >= 4) {
12941  start[0] = RAW;
12942  start[1] = NXT(1);
12943  start[2] = NXT(2);
12944  start[3] = NXT(3);
12945  enc = xmlDetectCharEncoding(start, 4);
12946  if (enc != XML_CHAR_ENCODING_NONE) {
12947  xmlSwitchEncoding(ctxt, enc);
12948  }
12949  }
12950 
12951  /*
12952  * Parse a possible text declaration first
12953  */
12954  if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
12955  xmlParseTextDecl(ctxt);
12956  /*
12957  * An XML-1.0 document can't reference an entity not XML-1.0
12958  */
12959  if ((xmlStrEqual(ctx->version, BAD_CAST "1.0")) &&
12960  (!xmlStrEqual(ctxt->input->version, BAD_CAST "1.0"))) {
12961  xmlFatalErrMsg(ctxt, XML_ERR_VERSION_MISMATCH,
12962  "Version mismatch between document and entity\n");
12963  }
12964  }
12965 
12966  /*
12967  * If the user provided its own SAX callbacks then reuse the
12968  * useData callback field, otherwise the expected setup in a
12969  * DOM builder is to have userData == ctxt
12970  */
12971  if (ctx->userData == ctx)
12972  ctxt->userData = ctxt;
12973  else
12974  ctxt->userData = ctx->userData;
12975 
12976  /*
12977  * Doing validity checking on chunk doesn't make sense
12978  */
12979  ctxt->instate = XML_PARSER_CONTENT;
12980  ctxt->validate = ctx->validate;
12981  ctxt->valid = ctx->valid;
12982  ctxt->loadsubset = ctx->loadsubset;
12983  ctxt->depth = ctx->depth + 1;
12984  ctxt->replaceEntities = ctx->replaceEntities;
12985  if (ctxt->validate) {
12986  ctxt->vctxt.error = ctx->vctxt.error;
12987  ctxt->vctxt.warning = ctx->vctxt.warning;
12988  } else {
12989  ctxt->vctxt.error = NULL;
12990  ctxt->vctxt.warning = NULL;
12991  }
12992  ctxt->vctxt.nodeTab = NULL;
12993  ctxt->vctxt.nodeNr = 0;
12994  ctxt->vctxt.nodeMax = 0;
12995  ctxt->vctxt.node = NULL;
12996  if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);
12997  ctxt->dict = ctx->dict;
12998  ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
12999  ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
13000  ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
13001  ctxt->dictNames = ctx->dictNames;
13002  ctxt->attsDefault = ctx->attsDefault;
13003  ctxt->attsSpecial = ctx->attsSpecial;
13004  ctxt->linenumbers = ctx->linenumbers;
13005 
13006  xmlParseContent(ctxt);
13007 
13008  ctx->validate = ctxt->validate;
13009  ctx->valid = ctxt->valid;
13010  if ((RAW == '<') && (NXT(1) == '/')) {
13012  } else if (RAW != 0) {
13014  }
13015  if (ctxt->node != newDoc->children) {
13017  }
13018 
13019  if (!ctxt->wellFormed) {
13020  if (ctxt->errNo == 0)
13021  ret = 1;
13022  else
13023  ret = ctxt->errNo;
13024  } else {
13025  if (lst != NULL) {
13026  xmlNodePtr cur;
13027 
13028  /*
13029  * Return the newly created nodeset after unlinking it from
13030  * they pseudo parent.
13031  */
13032  cur = newDoc->children->children;
13033  *lst = cur;
13034  while (cur != NULL) {
13035  cur->parent = NULL;
13036  cur = cur->next;
13037  }
13038  newDoc->children->children = NULL;
13039  }
13040  ret = 0;
13041  }
13042  ctxt->sax = oldsax;
13043  ctxt->dict = NULL;
13044  ctxt->attsDefault = NULL;
13045  ctxt->attsSpecial = NULL;
13046  xmlFreeParserCtxt(ctxt);
13047  newDoc->intSubset = NULL;
13048  newDoc->extSubset = NULL;
13049  xmlFreeDoc(newDoc);
13050 
13051  return(ret);
13052 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
int nodeMax
Definition: valid.h:90
int nodeNr
Definition: valid.h:89
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:638
xmlParserInputState instate
Definition: parser.h:223
int properties
Definition: tree.h:584
const xmlChar * URL
Definition: tree.h:577
#define GROW
Definition: parser.c:2073
struct _xmlDtd * intSubset
Definition: tree.h:570
#define NXT(val)
Definition: parser.c:2021
const xmlChar * cur
Definition: parser.h:61
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2028
void xmlParseTextDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6841
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:13988
xmlValidityErrorFunc error
Definition: valid.h:84
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
xmlCharEncoding
Definition: encoding.h:58
xmlNodePtr * nodeTab
Definition: valid.h:91
const xmlChar * version
Definition: parser.h:74
xmlParserInputPtr input
Definition: parser.h:199
const xmlChar * str_xmlns
Definition: parser.h:272
xmlNodePtr node
Definition: valid.h:88
#define IS_BLANK_CH(c)
const xmlChar * str_xml
Definition: parser.h:271
int linenumbers
Definition: parser.h:259
int replaceEntities
Definition: parser.h:189
xmlHashTablePtr attsDefault
Definition: parser.h:284
smooth NULL
Definition: ftsmooth.c:416
#define XML_XML_NAMESPACE
Definition: tree.h:140
#define BAD_CAST
Definition: xmlstring.h:35
xmlDictPtr dict
Definition: parser.h:263
int validate
Definition: parser.h:220
struct _xmlNode * parent
Definition: tree.h:495
const xmlChar * str_xml_ns
Definition: parser.h:273
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
int wellFormed
Definition: parser.h:188
xmlNodePtr node
Definition: parser.h:205
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:858
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:932
Definition: tree.h:489
int ret
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN void XMLCALL xmlDictFree(xmlDictPtr dict)
Definition: dict.c:793
struct _xmlSAXHandler * sax
Definition: parser.h:185
const xmlChar * version
Definition: parser.h:190
#define ID
Definition: ruserpass.c:36
int loadsubset
Definition: parser.h:258
int dictNames
Definition: parser.h:292
struct _xmlNode * next
Definition: tree.h:496
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1066
GLuint start
Definition: gl.h:1545
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content)
xmlHashTablePtr attsSpecial
Definition: parser.h:285
Definition: tree.h:551
struct _xmlDtd * extSubset
Definition: tree.h:571
void xmlParseContent(xmlParserCtxtPtr ctxt)
Definition: parser.c:9809
int nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
Definition: parser.c:1767
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
struct _xmlNode * children
Definition: tree.h:555
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
xmlValidCtxt vctxt
Definition: parser.h:221
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
const xmlChar * end
Definition: parser.h:62
struct _xmlDict * dict
Definition: tree.h:580
void * userData
Definition: parser.h:186
xmlValidityWarningFunc warning
Definition: valid.h:85
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xmlSAX2GetEntity().

◆ xmlParseDocument()

XMLPUBFUN int XMLCALL xmlParseDocument ( xmlParserCtxtPtr  ctxt)

xmlParseDocument: @ctxt: an XML parser context

parse an XML document (and build a tree if using the standard SAX interface).

[1] document ::= prolog element Misc*

[22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?

Returns 0, -1 in case of error. the parser context is augmented as a result of the parsing.

Definition at line 10579 of file parser.c.

10579  {
10580  xmlChar start[4];
10581  xmlCharEncoding enc;
10582 
10583  xmlInitParser();
10584 
10585  if ((ctxt == NULL) || (ctxt->input == NULL))
10586  return(-1);
10587 
10588  GROW;
10589 
10590  /*
10591  * SAX: detecting the level.
10592  */
10593  xmlDetectSAX2(ctxt);
10594 
10595  /*
10596  * SAX: beginning of the document processing.
10597  */
10598  if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
10599  ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
10600  if (ctxt->instate == XML_PARSER_EOF)
10601  return(-1);
10602 
10603  if ((ctxt->encoding == NULL) &&
10604  ((ctxt->input->end - ctxt->input->cur) >= 4)) {
10605  /*
10606  * Get the 4 first bytes and decode the charset
10607  * if enc != XML_CHAR_ENCODING_NONE
10608  * plug some encoding conversion routines.
10609  */
10610  start[0] = RAW;
10611  start[1] = NXT(1);
10612  start[2] = NXT(2);
10613  start[3] = NXT(3);
10614  enc = xmlDetectCharEncoding(&start[0], 4);
10615  if (enc != XML_CHAR_ENCODING_NONE) {
10616  xmlSwitchEncoding(ctxt, enc);
10617  }
10618  }
10619 
10620 
10621  if (CUR == 0) {
10623  return(-1);
10624  }
10625 
10626  /*
10627  * Check for the XMLDecl in the Prolog.
10628  * do not GROW here to avoid the detected encoder to decode more
10629  * than just the first line, unless the amount of data is really
10630  * too small to hold "<?xml version="1.0" encoding="foo"
10631  */
10632  if ((ctxt->input->end - ctxt->input->cur) < 35) {
10633  GROW;
10634  }
10635  if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
10636 
10637  /*
10638  * Note that we will switch encoding on the fly.
10639  */
10640  xmlParseXMLDecl(ctxt);
10641  if ((ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) ||
10642  (ctxt->instate == XML_PARSER_EOF)) {
10643  /*
10644  * The XML REC instructs us to stop parsing right here
10645  */
10646  return(-1);
10647  }
10648  ctxt->standalone = ctxt->input->standalone;
10649  SKIP_BLANKS;
10650  } else {
10652  }
10653  if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX))
10654  ctxt->sax->startDocument(ctxt->userData);
10655  if (ctxt->instate == XML_PARSER_EOF)
10656  return(-1);
10657  if ((ctxt->myDoc != NULL) && (ctxt->input != NULL) &&
10658  (ctxt->input->buf != NULL) && (ctxt->input->buf->compressed >= 0)) {
10659  ctxt->myDoc->compression = ctxt->input->buf->compressed;
10660  }
10661 
10662  /*
10663  * The Misc part of the Prolog
10664  */
10665  GROW;
10666  xmlParseMisc(ctxt);
10667 
10668  /*
10669  * Then possibly doc type declaration(s) and more Misc
10670  * (doctypedecl Misc*)?
10671  */
10672  GROW;
10673  if (CMP9(CUR_PTR, '<', '!', 'D', 'O', 'C', 'T', 'Y', 'P', 'E')) {
10674 
10675  ctxt->inSubset = 1;
10676  xmlParseDocTypeDecl(ctxt);
10677  if (RAW == '[') {
10678  ctxt->instate = XML_PARSER_DTD;
10679  xmlParseInternalSubset(ctxt);
10680  if (ctxt->instate == XML_PARSER_EOF)
10681  return(-1);
10682  }
10683 
10684  /*
10685  * Create and update the external subset.
10686  */
10687  ctxt->inSubset = 2;
10688  if ((ctxt->sax != NULL) && (ctxt->sax->externalSubset != NULL) &&
10689  (!ctxt->disableSAX))
10690  ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName,
10691  ctxt->extSubSystem, ctxt->extSubURI);
10692  if (ctxt->instate == XML_PARSER_EOF)
10693  return(-1);
10694  ctxt->inSubset = 0;
10695 
10696  xmlCleanSpecialAttr(ctxt);
10697 
10698  ctxt->instate = XML_PARSER_PROLOG;
10699  xmlParseMisc(ctxt);
10700  }
10701 
10702  /*
10703  * Time to start parsing the tree itself
10704  */
10705  GROW;
10706  if (RAW != '<') {
10707  xmlFatalErrMsg(ctxt, XML_ERR_DOCUMENT_EMPTY,
10708  "Start tag expected, '<' not found\n");
10709  } else {
10710  ctxt->instate = XML_PARSER_CONTENT;
10711  xmlParseElement(ctxt);
10712  ctxt->instate = XML_PARSER_EPILOG;
10713 
10714 
10715  /*
10716  * The Misc part at the end
10717  */
10718  xmlParseMisc(ctxt);
10719 
10720  if (RAW != 0) {
10722  }
10723  ctxt->instate = XML_PARSER_EOF;
10724  }
10725 
10726  /*
10727  * SAX: end of the document processing.
10728  */
10729  if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
10730  ctxt->sax->endDocument(ctxt->userData);
10731 
10732  /*
10733  * Remove locally kept entity definitions if the tree was not built
10734  */
10735  if ((ctxt->myDoc != NULL) &&
10737  xmlFreeDoc(ctxt->myDoc);
10738  ctxt->myDoc = NULL;
10739  }
10740 
10741  if ((ctxt->wellFormed) && (ctxt->myDoc != NULL)) {
10743  if (ctxt->valid)
10744  ctxt->myDoc->properties |= XML_DOC_DTDVALID;
10745  if (ctxt->nsWellFormed)
10746  ctxt->myDoc->properties |= XML_DOC_NSVALID;
10747  if (ctxt->options & XML_PARSE_OLD10)
10748  ctxt->myDoc->properties |= XML_DOC_OLD10;
10749  }
10750  if (! ctxt->wellFormed) {
10751  ctxt->valid = 0;
10752  return(-1);
10753  }
10754  return(0);
10755 }
XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator
Definition: globals.h:329
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
xmlParserInputState instate
Definition: parser.h:223
int properties
Definition: tree.h:584
xmlChar * extSubURI
Definition: parser.h:240
#define GROW
Definition: parser.c:2073
static void xmlParseInternalSubset(xmlParserCtxtPtr ctxt)
Definition: parser.c:8266
const xmlChar * version
Definition: tree.h:573
#define NXT(val)
Definition: parser.c:2021
int nsWellFormed
Definition: parser.h:286
const xmlChar * cur
Definition: parser.h:61
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2028
xmlCharEncoding
Definition: encoding.h:58
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2036
#define SKIP_BLANKS
Definition: parser.c:2101
int compression
Definition: tree.h:563
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
void xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:8194
int standalone
Definition: parser.h:192
#define IS_BLANK_CH(c)
int standalone
Definition: parser.h:75
void xmlInitParser(void)
Definition: parser.c:14706
smooth NULL
Definition: ftsmooth.c:416
xmlChar * extSubSystem
Definition: parser.h:241
const xmlChar * intSubName
Definition: parser.h:239
#define XML_DEFAULT_VERSION
Definition: parser.h:33
int wellFormed
Definition: parser.h:188
void xmlParseElement(xmlParserCtxtPtr ctxt)
Definition: parser.c:9892
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
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
const xmlChar * version
Definition: parser.h:190
void xmlParseMisc(xmlParserCtxtPtr ctxt)
Definition: parser.c:10549
xmlParserInputBufferPtr buf
Definition: parser.h:56
#define CUR
Definition: parser.c:2020
int inSubset
Definition: parser.h:238
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1066
GLuint start
Definition: gl.h:1545
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
static void xmlCleanSpecialAttr(xmlParserCtxtPtr ctxt)
Definition: parser.c:1365
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xmlParseXMLDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:10434
#define SAX_COMPAT_MODE
Definition: parser.c:249
XMLPUBFUN xmlChar *XMLCALL xmlCharStrdup(const char *cur)
Definition: xmlstring.c:113
const xmlChar * end
Definition: parser.h:62
void * userData
Definition: parser.h:186

Referenced by testSAX(), xmlDoRead(), and xsltDocDefaultLoaderFunc().

◆ xmlParseExtParsedEnt()

XMLPUBFUN int XMLCALL xmlParseExtParsedEnt ( xmlParserCtxtPtr  ctxt)

xmlParseExtParsedEnt: @ctxt: an XML parser context

parse a general parsed entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.

[78] extParsedEnt ::= TextDecl? content

Returns 0, -1 in case of error. the parser context is augmented as a result of the parsing.

Definition at line 10772 of file parser.c.

10772  {
10773  xmlChar start[4];
10774  xmlCharEncoding enc;
10775 
10776  if ((ctxt == NULL) || (ctxt->input == NULL))
10777  return(-1);
10778 
10780 
10781  xmlDetectSAX2(ctxt);
10782 
10783  GROW;
10784 
10785  /*
10786  * SAX: beginning of the document processing.
10787  */
10788  if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
10789  ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
10790 
10791  /*
10792  * Get the 4 first bytes and decode the charset
10793  * if enc != XML_CHAR_ENCODING_NONE
10794  * plug some encoding conversion routines.
10795  */
10796  if ((ctxt->input->end - ctxt->input->cur) >= 4) {
10797  start[0] = RAW;
10798  start[1] = NXT(1);
10799  start[2] = NXT(2);
10800  start[3] = NXT(3);
10801  enc = xmlDetectCharEncoding(start, 4);
10802  if (enc != XML_CHAR_ENCODING_NONE) {
10803  xmlSwitchEncoding(ctxt, enc);
10804  }
10805  }
10806 
10807 
10808  if (CUR == 0) {
10810  }
10811 
10812  /*
10813  * Check for the XMLDecl in the Prolog.
10814  */
10815  GROW;
10816  if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
10817 
10818  /*
10819  * Note that we will switch encoding on the fly.
10820  */
10821  xmlParseXMLDecl(ctxt);
10822  if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
10823  /*
10824  * The XML REC instructs us to stop parsing right here
10825  */
10826  return(-1);
10827  }
10828  SKIP_BLANKS;
10829  } else {
10831  }
10832  if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX))
10833  ctxt->sax->startDocument(ctxt->userData);
10834  if (ctxt->instate == XML_PARSER_EOF)
10835  return(-1);
10836 
10837  /*
10838  * Doing validity checking on chunk doesn't make sense
10839  */
10840  ctxt->instate = XML_PARSER_CONTENT;
10841  ctxt->validate = 0;
10842  ctxt->loadsubset = 0;
10843  ctxt->depth = 0;
10844 
10845  xmlParseContent(ctxt);
10846  if (ctxt->instate == XML_PARSER_EOF)
10847  return(-1);
10848 
10849  if ((RAW == '<') && (NXT(1) == '/')) {
10851  } else if (RAW != 0) {
10853  }
10854 
10855  /*
10856  * SAX: end of the document processing.
10857  */
10858  if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
10859  ctxt->sax->endDocument(ctxt->userData);
10860 
10861  if (! ctxt->wellFormed) return(-1);
10862  return(0);
10863 }
XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator
Definition: globals.h:329
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
#define NXT(val)
Definition: parser.c:2021
const xmlChar * cur
Definition: parser.h:61
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2028
xmlCharEncoding
Definition: encoding.h:58
#define SKIP_BLANKS
Definition: parser.c:2101
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
#define IS_BLANK_CH(c)
smooth NULL
Definition: ftsmooth.c:416
int validate
Definition: parser.h:220
#define XML_DEFAULT_VERSION
Definition: parser.h:33
int wellFormed
Definition: parser.h:188
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:932
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
const xmlChar * version
Definition: parser.h:190
int loadsubset
Definition: parser.h:258
#define CUR
Definition: parser.c:2020
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1066
GLuint start
Definition: gl.h:1545
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit(void)
Definition: SAX2.c:2939
void xmlParseContent(xmlParserCtxtPtr ctxt)
Definition: parser.c:9809
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
void xmlParseXMLDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:10434
XMLPUBFUN xmlChar *XMLCALL xmlCharStrdup(const char *cur)
Definition: xmlstring.c:113
const xmlChar * end
Definition: parser.h:62
void * userData
Definition: parser.h:186

◆ xmlParseInNodeContext()

XMLPUBFUN xmlParserErrors XMLCALL xmlParseInNodeContext ( xmlNodePtr  node,
const char data,
int  datalen,
int  options,
xmlNodePtr lst 
)

xmlParseInNodeContext: @node: the context node @data: the input string @datalen: the input string length in bytes @options: a combination of xmlParserOption @lst: the return value for the set of parsed nodes

Parse a well-balanced chunk of an XML document within the context (DTD, namespaces, etc ...) of the given node.

The allowed sequence for the data is a Well Balanced Chunk defined by the content production in the XML grammar:

[43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*

Returns XML_ERR_OK if the chunk is well balanced, and the parser error code otherwise

Definition at line 13533 of file parser.c.

13534  {
13535 #ifdef SAX2
13536  xmlParserCtxtPtr ctxt;
13537  xmlDocPtr doc = NULL;
13538  xmlNodePtr fake, cur;
13539  int nsnr = 0;
13540 
13542 
13543  /*
13544  * check all input parameters, grab the document
13545  */
13546  if ((lst == NULL) || (node == NULL) || (data == NULL) || (datalen < 0))
13547  return(XML_ERR_INTERNAL_ERROR);
13548  switch (node->type) {
13549  case XML_ELEMENT_NODE:
13550  case XML_ATTRIBUTE_NODE:
13551  case XML_TEXT_NODE:
13553  case XML_ENTITY_REF_NODE:
13554  case XML_PI_NODE:
13555  case XML_COMMENT_NODE:
13556  case XML_DOCUMENT_NODE:
13558  break;
13559  default:
13560  return(XML_ERR_INTERNAL_ERROR);
13561 
13562  }
13563  while ((node != NULL) && (node->type != XML_ELEMENT_NODE) &&
13564  (node->type != XML_DOCUMENT_NODE) &&
13565  (node->type != XML_HTML_DOCUMENT_NODE))
13566  node = node->parent;
13567  if (node == NULL)
13568  return(XML_ERR_INTERNAL_ERROR);
13569  if (node->type == XML_ELEMENT_NODE)
13570  doc = node->doc;
13571  else
13572  doc = (xmlDocPtr) node;
13573  if (doc == NULL)
13574  return(XML_ERR_INTERNAL_ERROR);
13575 
13576  /*
13577  * allocate a context and set-up everything not related to the
13578  * node position in the tree
13579  */
13580  if (doc->type == XML_DOCUMENT_NODE)
13581  ctxt = xmlCreateMemoryParserCtxt((char *) data, datalen);
13582 #ifdef LIBXML_HTML_ENABLED
13583  else if (doc->type == XML_HTML_DOCUMENT_NODE) {
13584  ctxt = htmlCreateMemoryParserCtxt((char *) data, datalen);
13585  /*
13586  * When parsing in context, it makes no sense to add implied
13587  * elements like html/body/etc...
13588  */
13589  options |= HTML_PARSE_NOIMPLIED;
13590  }
13591 #endif
13592  else
13593  return(XML_ERR_INTERNAL_ERROR);
13594 
13595  if (ctxt == NULL)
13596  return(XML_ERR_NO_MEMORY);
13597 
13598  /*
13599  * Use input doc's dict if present, else assure XML_PARSE_NODICT is set.
13600  * We need a dictionary for xmlDetectSAX2, so if there's no doc dict
13601  * we must wait until the last moment to free the original one.
13602  */
13603  if (doc->dict != NULL) {
13604  if (ctxt->dict != NULL)
13605  xmlDictFree(ctxt->dict);
13606  ctxt->dict = doc->dict;
13607  } else
13609 
13610  if (doc->encoding != NULL) {
13612 
13613  if (ctxt->encoding != NULL)
13614  xmlFree((xmlChar *) ctxt->encoding);
13615  ctxt->encoding = xmlStrdup((const xmlChar *) doc->encoding);
13616 
13617  hdlr = xmlFindCharEncodingHandler((const char *) doc->encoding);
13618  if (hdlr != NULL) {
13619  xmlSwitchToEncoding(ctxt, hdlr);
13620  } else {
13622  }
13623  }
13624 
13626  xmlDetectSAX2(ctxt);
13627  ctxt->myDoc = doc;
13628  /* parsing in context, i.e. as within existing content */
13629  ctxt->input_id = 2;
13630  ctxt->instate = XML_PARSER_CONTENT;
13631 
13632  fake = xmlNewComment(NULL);
13633  if (fake == NULL) {
13634  xmlFreeParserCtxt(ctxt);
13635  return(XML_ERR_NO_MEMORY);
13636  }
13637  xmlAddChild(node, fake);
13638 
13639  if (node->type == XML_ELEMENT_NODE) {
13640  nodePush(ctxt, node);
13641  /*
13642  * initialize the SAX2 namespaces stack
13643  */
13644  cur = node;
13645  while ((cur != NULL) && (cur->type == XML_ELEMENT_NODE)) {
13646  xmlNsPtr ns = cur->nsDef;
13647  const xmlChar *iprefix, *ihref;
13648 
13649  while (ns != NULL) {
13650  if (ctxt->dict) {
13651  iprefix = xmlDictLookup(ctxt->dict, ns->prefix, -1);
13652  ihref = xmlDictLookup(ctxt->dict, ns->href, -1);
13653  } else {
13654  iprefix = ns->prefix;
13655  ihref = ns->href;
13656  }
13657 
13658  if (xmlGetNamespace(ctxt, iprefix) == NULL) {
13659  nsPush(ctxt, iprefix, ihref);
13660  nsnr++;
13661  }
13662  ns = ns->next;
13663  }
13664  cur = cur->parent;
13665  }
13666  }
13667 
13668  if ((ctxt->validate) || (ctxt->replaceEntities != 0)) {
13669  /*
13670  * ID/IDREF registration will be done in xmlValidateElement below
13671  */
13672  ctxt->loadsubset |= XML_SKIP_IDS;
13673  }
13674 
13675 #ifdef LIBXML_HTML_ENABLED
13676  if (doc->type == XML_HTML_DOCUMENT_NODE)
13677  __htmlParseContent(ctxt);
13678  else
13679 #endif
13680  xmlParseContent(ctxt);
13681 
13682  nsPop(ctxt, nsnr);
13683  if ((RAW == '<') && (NXT(1) == '/')) {
13685  } else if (RAW != 0) {
13687  }
13688  if ((ctxt->node != NULL) && (ctxt->node != node)) {
13690  ctxt->wellFormed = 0;
13691  }
13692 
13693  if (!ctxt->wellFormed) {
13694  if (ctxt->errNo == 0)
13696  else
13697  ret = (xmlParserErrors)ctxt->errNo;
13698  } else {
13699  ret = XML_ERR_OK;
13700  }
13701 
13702  /*
13703  * Return the newly created nodeset after unlinking it from
13704  * the pseudo sibling.
13705  */
13706 
13707  cur = fake->next;
13708  fake->next = NULL;
13709  node->last = fake;
13710 
13711  if (cur != NULL) {
13712  cur->prev = NULL;
13713  }
13714 
13715  *lst = cur;
13716 
13717  while (cur != NULL) {
13718  cur->parent = NULL;
13719  cur = cur->next;
13720  }
13721 
13722  xmlUnlinkNode(fake);
13723  xmlFreeNode(fake);
13724 
13725 
13726  if (ret != XML_ERR_OK) {
13727  xmlFreeNodeList(*lst);
13728  *lst = NULL;
13729  }
13730 
13731  if (doc->dict != NULL)
13732  ctxt->dict = NULL;
13733  xmlFreeParserCtxt(ctxt);
13734 
13735  return(ret);
13736 #else /* !SAX2 */
13737  return(XML_ERR_INTERNAL_ERROR);
13738 #endif
13739 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
xmlElementType type
Definition: tree.h:553
xmlParserInputState instate
Definition: parser.h:223
struct _xmlNode * prev
Definition: tree.h:497
static const xmlChar * xmlGetNamespace(xmlParserCtxtPtr ctxt, const xmlChar *prefix)
Definition: parser.c:8663
Definition: tree.h:389
XMLPUBFUN void XMLCALL xmlFreeNodeList(xmlNodePtr cur)
#define NXT(val)
Definition: parser.c:2021
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1027
xmlNs * nsDef
Definition: tree.h:504
int input_id
Definition: parser.h:312
struct node node
int replaceEntities
Definition: parser.h:189
smooth NULL
Definition: ftsmooth.c:416
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15021
xmlDictPtr dict
Definition: parser.h:263
int validate
Definition: parser.h:220
struct _xmlNode * parent
Definition: tree.h:495
XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild(xmlNodePtr parent, xmlNodePtr cur)
int wellFormed
Definition: parser.h:188
xmlParserErrors
Definition: xmlerror.h:99
xmlNodePtr node
Definition: parser.h:205
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int nsPop(xmlParserCtxtPtr ctxt, int nr)
Definition: parser.c:1645
static int nsPush(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URL)
Definition: parser.c:1595
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:858
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
XMLPUBFUN xmlNodePtr XMLCALL xmlNewComment(const xmlChar *content)
Definition: mxnamespace.c:44
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1641
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN void XMLCALL xmlDictFree(xmlDictPtr dict)
Definition: dict.c:793
int loadsubset
Definition: parser.h:258
BSTR prefix
Definition: mxnamespace.c:46
const xmlChar * encoding
Definition: tree.h:574
xmlElementType type
Definition: tree.h:491
xmlParserCtxtPtr xmlCreateMemoryParserCtxt(const char *buffer, int size)
Definition: parser.c:14369
xmlDoc * xmlDocPtr
Definition: tree.h:550
struct _xmlNode * next
Definition: tree.h:496
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1066
Definition: tree.h:551
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
void xmlParseContent(xmlParserCtxtPtr ctxt)
Definition: parser.c:9809
int nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
Definition: parser.c:1767
#define RAW
Definition: parser.c:2019
#define XML_SKIP_IDS
Definition: parser.h:156
struct _xmlDict * dict
Definition: tree.h:580
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
Definition: dlist.c:348

◆ xmlParserAddNodeInfo()

XMLPUBFUN void XMLCALL xmlParserAddNodeInfo ( xmlParserCtxtPtr  ctxt,
const xmlParserNodeInfoPtr  info 
)

xmlParserAddNodeInfo: @ctxt: an XML parser context @info: a node info sequence pointer

Insert node info record into the sorted sequence

Definition at line 2011 of file parserInternals.c.

2013 {
2014  unsigned long pos;
2015 
2016  if ((ctxt == NULL) || (info == NULL)) return;
2017 
2018  /* Find pos and check to see if node is already in the sequence */
2020  info->node);
2021 
2022  if ((pos < ctxt->node_seq.length) &&
2023  (ctxt->node_seq.buffer != NULL) &&
2024  (ctxt->node_seq.buffer[pos].node == info->node)) {
2025  ctxt->node_seq.buffer[pos] = *info;
2026  }
2027 
2028  /* Otherwise, we need to add new node to buffer */
2029  else {
2030  if ((ctxt->node_seq.length + 1 > ctxt->node_seq.maximum) ||
2031  (ctxt->node_seq.buffer == NULL)) {
2032  xmlParserNodeInfo *tmp_buffer;
2033  unsigned int byte_size;
2034 
2035  if (ctxt->node_seq.maximum == 0)
2036  ctxt->node_seq.maximum = 2;
2037  byte_size = (sizeof(*ctxt->node_seq.buffer) *
2038  (2 * ctxt->node_seq.maximum));
2039 
2040  if (ctxt->node_seq.buffer == NULL)
2041  tmp_buffer = (xmlParserNodeInfo *) xmlMalloc(byte_size);
2042  else
2043  tmp_buffer =
2045  byte_size);
2046 
2047  if (tmp_buffer == NULL) {
2048  xmlErrMemory(ctxt, "failed to allocate buffer\n");
2049  return;
2050  }
2051  ctxt->node_seq.buffer = tmp_buffer;
2052  ctxt->node_seq.maximum *= 2;
2053  }
2054 
2055  /* If position is not at end, move elements out of the way */
2056  if (pos != ctxt->node_seq.length) {
2057  unsigned long i;
2058 
2059  for (i = ctxt->node_seq.length; i > pos; i--)
2060  ctxt->node_seq.buffer[i] = ctxt->node_seq.buffer[i - 1];
2061  }
2062 
2063  /* Copy element and increase length */
2064  ctxt->node_seq.buffer[pos] = *info;
2065  ctxt->node_seq.length++;
2066  }
2067 }
struct _test_info info[]
Definition: SetCursorPos.c:19
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, const xmlNodePtr node)
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
xmlParserNodeInfo * buffer
Definition: parser.h:103
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
Definition: tree.h:489
const struct _xmlNode * node
Definition: parser.h:90
unsigned long length
Definition: parser.h:102
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
unsigned long maximum
Definition: parser.h:101
xmlParserNodeInfoSeq node_seq
Definition: parser.h:211

Referenced by xmlParseElement(), and xmlSAX2EndElementNs().

◆ xmlParserFindNodeInfo()