ReactOS  0.4.15-dev-425-gc40b086
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 existence 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 substitution */
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 subtract 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 14798 of file parser.c.

14798  {
14799  if (!xmlParserInitialized)
14800  return;
14801 
14803 #ifdef LIBXML_CATALOG_ENABLED
14804  xmlCatalogCleanup();
14805 #endif
14806  xmlDictCleanup();
14808 #ifdef LIBXML_OUTPUT_ENABLED
14809  xmlCleanupOutputCallbacks();
14810 #endif
14811 #ifdef LIBXML_SCHEMAS_ENABLED
14812  xmlSchemaCleanupTypes();
14813  xmlRelaxNGCleanupTypes();
14814 #endif
14817  xmlCleanupThreads(); /* must be last if called not from the main thread */
14818  xmlCleanupMemory();
14820 }
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:222
static int xmlParserInitialized
Definition: parser.c:14729

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:14847
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 14606 of file parser.c.

14606  {
14607  int len;
14608 
14609  if (cur == NULL)
14610  return(NULL);
14611  len = xmlStrlen(cur);
14612  return(xmlCreateMemoryParserCtxt((const char *)cur, len));
14613 }
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:14403

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 12534 of file parser.c.

12536  {
12537  xmlParserCtxtPtr ctxt;
12538  xmlParserInputPtr inputStream;
12540 
12541  if (ioread == NULL) return(NULL);
12542 
12543  buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);
12544  if (buf == NULL) {
12545  if (ioclose != NULL)
12546  ioclose(ioctx);
12547  return (NULL);
12548  }
12549 
12550  ctxt = xmlNewParserCtxt();
12551  if (ctxt == NULL) {
12553  return(NULL);
12554  }
12555  if (sax != NULL) {
12556 #ifdef LIBXML_SAX1_ENABLED
12557  if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
12558 #endif /* LIBXML_SAX1_ENABLED */
12559  xmlFree(ctxt->sax);
12560  ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
12561  if (ctxt->sax == NULL) {
12562  xmlErrMemory(ctxt, NULL);
12563  xmlFreeParserCtxt(ctxt);
12564  return(NULL);
12565  }
12566  memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
12567  if (sax->initialized == XML_SAX2_MAGIC)
12568  memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
12569  else
12570  memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
12571  if (user_data != NULL)
12572  ctxt->userData = user_data;
12573  }
12574 
12575  inputStream = xmlNewIOInputStream(ctxt, buf, enc);
12576  if (inputStream == NULL) {
12577  xmlFreeParserCtxt(ctxt);
12578  return(NULL);
12579  }
12580  inputPush(ctxt, inputStream);
12581 
12582  return(ctxt);
12583 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
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 15413 of file parser.c.

15415 {
15417 
15418  if (cur == NULL)
15419  return (NULL);
15420  if (ctxt == NULL)
15421  return (NULL);
15422  xmlInitParser();
15423 
15424  xmlCtxtReset(ctxt);
15425 
15426  stream = xmlNewStringInputStream(ctxt, cur);
15427  if (stream == NULL) {
15428  return (NULL);
15429  }
15430  inputPush(ctxt, stream);
15431  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15432 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
void xmlInitParser(void)
Definition: parser.c:14740
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2825

◆ 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 15528 of file parser.c.

15530 {
15533 
15534  if (fd < 0)
15535  return (NULL);
15536  if (ctxt == NULL)
15537  return (NULL);
15538  xmlInitParser();
15539 
15540  xmlCtxtReset(ctxt);
15541 
15542 
15544  if (input == NULL)
15545  return (NULL);
15546  input->closecallback = NULL;
15548  if (stream == NULL) {
15550  return (NULL);
15551  }
15552  inputPush(ctxt, stream);
15553  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15554 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
static int fd
Definition: io.c:51
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
void xmlInitParser(void)
Definition: parser.c:14740
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2825
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 15447 of file parser.c.

15449 {
15451 
15452  if (filename == NULL)
15453  return (NULL);
15454  if (ctxt == NULL)
15455  return (NULL);
15456  xmlInitParser();
15457 
15458  xmlCtxtReset(ctxt);
15459 
15461  if (stream == NULL) {
15462  return (NULL);
15463  }
15464  inputPush(ctxt, stream);
15465  return (xmlDoRead(ctxt, NULL, encoding, options, 1));
15466 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
const char * filename
Definition: ioapi.h:135
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
void xmlInitParser(void)
Definition: parser.c:14740
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:2825

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 15572 of file parser.c.

15576 {
15579 
15580  if (ioread == NULL)
15581  return (NULL);
15582  if (ctxt == NULL)
15583  return (NULL);
15584  xmlInitParser();
15585 
15586  xmlCtxtReset(ctxt);
15587 
15588  input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
15590  if (input == NULL) {
15591  if (ioclose != NULL)
15592  ioclose(ioctx);
15593  return (NULL);
15594  }
15596  if (stream == NULL) {
15598  return (NULL);
15599  }
15600  inputPush(ctxt, stream);
15601  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15602 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
void xmlInitParser(void)
Definition: parser.c:14740
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2825
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 15483 of file parser.c.

15485 {
15488 
15489  if (ctxt == NULL)
15490  return (NULL);
15491  if (buffer == NULL)
15492  return (NULL);
15493  xmlInitParser();
15494 
15495  xmlCtxtReset(ctxt);
15496 
15498  if (input == NULL) {
15499  return(NULL);
15500  }
15501 
15503  if (stream == NULL) {
15505  return(NULL);
15506  }
15507 
15508  inputPush(ctxt, stream);
15509  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15510 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
GLuint buffer
Definition: glext.h:5915
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
void xmlInitParser(void)
Definition: parser.c:14740
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:2825
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 14847 of file parser.c.

14848 {
14850  xmlDictPtr dict;
14851 
14852  if (ctxt == NULL)
14853  return;
14854 
14855  dict = ctxt->dict;
14856 
14857  while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
14859  }
14860  ctxt->inputNr = 0;
14861  ctxt->input = NULL;
14862 
14863  ctxt->spaceNr = 0;
14864  if (ctxt->spaceTab != NULL) {
14865  ctxt->spaceTab[0] = -1;
14866  ctxt->space = &ctxt->spaceTab[0];
14867  } else {
14868  ctxt->space = NULL;
14869  }
14870 
14871 
14872  ctxt->nodeNr = 0;
14873  ctxt->node = NULL;
14874 
14875  ctxt->nameNr = 0;
14876  ctxt->name = NULL;
14877 
14878  DICT_FREE(ctxt->version);
14879  ctxt->version = NULL;
14880  DICT_FREE(ctxt->encoding);
14881  ctxt->encoding = NULL;
14882  DICT_FREE(ctxt->directory);
14883  ctxt->directory = NULL;
14884  DICT_FREE(ctxt->extSubURI);
14885  ctxt->extSubURI = NULL;
14886  DICT_FREE(ctxt->extSubSystem);
14887  ctxt->extSubSystem = NULL;
14888  if (ctxt->myDoc != NULL)
14889  xmlFreeDoc(ctxt->myDoc);
14890  ctxt->myDoc = NULL;
14891 
14892  ctxt->standalone = -1;
14893  ctxt->hasExternalSubset = 0;
14894  ctxt->hasPErefs = 0;
14895  ctxt->html = 0;
14896  ctxt->external = 0;
14897  ctxt->instate = XML_PARSER_START;
14898  ctxt->token = 0;
14899 
14900  ctxt->wellFormed = 1;
14901  ctxt->nsWellFormed = 1;
14902  ctxt->disableSAX = 0;
14903  ctxt->valid = 1;
14904 #if 0
14905  ctxt->vctxt.userData = ctxt;
14908 #endif
14909  ctxt->record_info = 0;
14910  ctxt->nbChars = 0;
14911  ctxt->checkIndex = 0;
14912  ctxt->inSubset = 0;
14913  ctxt->errNo = XML_ERR_OK;
14914  ctxt->depth = 0;
14916  ctxt->catalogs = NULL;
14917  ctxt->nbentities = 0;
14918  ctxt->sizeentities = 0;
14919  ctxt->sizeentcopy = 0;
14920  xmlInitNodeInfoSeq(&ctxt->node_seq);
14921 
14922  if (ctxt->attsDefault != NULL) {
14924  ctxt->attsDefault = NULL;
14925  }
14926  if (ctxt->attsSpecial != NULL) {
14927  xmlHashFree(ctxt->attsSpecial, NULL);
14928  ctxt->attsSpecial = NULL;
14929  }
14930 
14931 #ifdef LIBXML_CATALOG_ENABLED
14932  if (ctxt->catalogs != NULL)
14933  xmlCatalogFreeLocal(ctxt->catalogs);
14934 #endif
14935  if (ctxt->lastError.code != XML_ERR_OK)
14936  xmlResetError(&ctxt->lastError);
14937 }
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:327
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
Definition: dict.c:116
#define DICT_FREE(str)
Definition: parser.c:14835
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:1749
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
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 14952 of file parser.c.

14954 {
14955  xmlParserInputPtr inputStream;
14958 
14959  if (ctxt == NULL)
14960  return(1);
14961 
14962  if ((encoding == NULL) && (chunk != NULL) && (size >= 4))
14963  enc = xmlDetectCharEncoding((const xmlChar *) chunk, size);
14964 
14966  if (buf == NULL)
14967  return(1);
14968 
14969  if (ctxt == NULL) {
14971  return(1);
14972  }
14973 
14974  xmlCtxtReset(ctxt);
14975 
14976  if (filename == NULL) {
14977  ctxt->directory = NULL;
14978  } else {
14980  }
14981 
14982  inputStream = xmlNewInputStream(ctxt);
14983  if (inputStream == NULL) {
14985  return(1);
14986  }
14987 
14988  if (filename == NULL)
14989  inputStream->filename = NULL;
14990  else
14991  inputStream->filename = (char *)
14992  xmlCanonicPath((const xmlChar *) filename);
14993  inputStream->buf = buf;
14994  xmlBufResetInput(buf->buffer, inputStream);
14995 
14996  inputPush(ctxt, inputStream);
14997 
14998  if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
14999  (ctxt->input->buf != NULL)) {
15000  size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
15001  size_t cur = ctxt->input->cur - ctxt->input->base;
15002 
15004 
15005  xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
15006 #ifdef DEBUG_PUSH
15007  xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
15008 #endif
15009  }
15010 
15011  if (encoding != NULL) {
15013 
15014  if (ctxt->encoding != NULL)
15015  xmlFree((xmlChar *) ctxt->encoding);
15016  ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
15017 
15019  if (hdlr != NULL) {
15020  xmlSwitchToEncoding(ctxt, hdlr);
15021  } else {
15022  xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
15023  "Unsupported encoding %s\n", BAD_CAST encoding);
15024  }
15025  } else if (enc != XML_CHAR_ENCODING_NONE) {
15026  xmlSwitchEncoding(ctxt, enc);
15027  }
15028 
15029  return(0);
15030 }
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:1718
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:14847
xmlParserInputPtr input
Definition: parser.h:199
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2372
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlAllocParserInputBuffer(xmlCharEncoding enc)
#define BAD_CAST
Definition: xmlstring.h:35
GLsizeiptr size
Definition: glext.h:5919
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:2825
xmlParserInputBufferPtr buf
Definition: parser.h:56
const char * filename
Definition: parser.h:58
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
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 15186 of file parser.c.

15187 {
15188  return(xmlCtxtUseOptionsInternal(ctxt, options, NULL));
15189 }
smooth NULL
Definition: ftsmooth.c:416
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15045

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:327
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:800
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:1749
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 855 of file parser.c.

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

14740  {
14741  if (xmlParserInitialized != 0)
14742  return;
14743 
14744 #ifdef LIBXML_THREAD_ENABLED
14746  if (xmlParserInitialized == 0) {
14747 #endif
14748  xmlInitThreads();
14749  xmlInitGlobals();
14751  (xmlGenericError == NULL))
14753  xmlInitMemory();
14758 #ifdef LIBXML_OUTPUT_ENABLED
14759  xmlRegisterDefaultOutputCallbacks();
14760 #endif /* LIBXML_OUTPUT_ENABLED */
14761 #ifdef LIBXML_HTML_ENABLED
14762  htmlInitAutoClose();
14763  htmlDefaultSAXHandlerInit();
14764 #endif
14765 #ifdef LIBXML_XPATH_ENABLED
14766  xmlXPathInit();
14767 #endif
14769 #ifdef LIBXML_THREAD_ENABLED
14770  }
14772 #endif
14773 }
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:2941
void void __xmlGlobalInitMutexLock(void)
Definition: threads.c:427
XMLPUBFUN int XMLCALL xmlInitializeDict(void)
Definition: dict.c:160
static int xmlParserInitialized
Definition: parser.c:14729

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:575
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:1263
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:2868
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:1749
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:2941
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 12896 of file parser.c.

12897  {
12898  xmlParserCtxtPtr ctxt;
12899  xmlDocPtr newDoc;
12900  xmlNodePtr newRoot;
12901  xmlSAXHandlerPtr oldsax = NULL;
12902  int ret = 0;
12903  xmlChar start[4];
12904  xmlCharEncoding enc;
12905 
12906  if (ctx == NULL) return(-1);
12907 
12908  if (((ctx->depth > 40) && ((ctx->options & XML_PARSE_HUGE) == 0)) ||
12909  (ctx->depth > 1024)) {
12910  return(XML_ERR_ENTITY_LOOP);
12911  }
12912 
12913  if (lst != NULL)
12914  *lst = NULL;
12915  if ((URL == NULL) && (ID == NULL))
12916  return(-1);
12917  if (ctx->myDoc == NULL) /* @@ relax but check for dereferences */
12918  return(-1);
12919 
12920  ctxt = xmlCreateEntityParserCtxtInternal(URL, ID, NULL, ctx);
12921  if (ctxt == NULL) {
12922  return(-1);
12923  }
12924 
12925  oldsax = ctxt->sax;
12926  ctxt->sax = ctx->sax;
12927  xmlDetectSAX2(ctxt);
12928  newDoc = xmlNewDoc(BAD_CAST "1.0");
12929  if (newDoc == NULL) {
12930  xmlFreeParserCtxt(ctxt);
12931  return(-1);
12932  }
12933  newDoc->properties = XML_DOC_INTERNAL;
12934  if (ctx->myDoc->dict) {
12935  newDoc->dict = ctx->myDoc->dict;
12936  xmlDictReference(newDoc->dict);
12937  }
12938  if (ctx->myDoc != NULL) {
12939  newDoc->intSubset = ctx->myDoc->intSubset;
12940  newDoc->extSubset = ctx->myDoc->extSubset;
12941  }
12942  if (ctx->myDoc->URL != NULL) {
12943  newDoc->URL = xmlStrdup(ctx->myDoc->URL);
12944  }
12945  newRoot = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
12946  if (newRoot == NULL) {
12947  ctxt->sax = oldsax;
12948  xmlFreeParserCtxt(ctxt);
12949  newDoc->intSubset = NULL;
12950  newDoc->extSubset = NULL;
12951  xmlFreeDoc(newDoc);
12952  return(-1);
12953  }
12954  xmlAddChild((xmlNodePtr) newDoc, newRoot);
12955  nodePush(ctxt, newDoc->children);
12956  if (ctx->myDoc == NULL) {
12957  ctxt->myDoc = newDoc;
12958  } else {
12959  ctxt->myDoc = ctx->myDoc;
12960  newDoc->children->doc = ctx->myDoc;
12961  }
12962 
12963  /*
12964  * Get the 4 first bytes and decode the charset
12965  * if enc != XML_CHAR_ENCODING_NONE
12966  * plug some encoding conversion routines.
12967  */
12968  GROW
12969  if ((ctxt->input->end - ctxt->input->cur) >= 4) {
12970  start[0] = RAW;
12971  start[1] = NXT(1);
12972  start[2] = NXT(2);
12973  start[3] = NXT(3);
12974  enc = xmlDetectCharEncoding(start, 4);
12975  if (enc != XML_CHAR_ENCODING_NONE) {
12976  xmlSwitchEncoding(ctxt, enc);
12977  }
12978  }
12979 
12980  /*
12981  * Parse a possible text declaration first
12982  */
12983  if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
12984  xmlParseTextDecl(ctxt);
12985  /*
12986  * An XML-1.0 document can't reference an entity not XML-1.0
12987  */
12988  if ((xmlStrEqual(ctx->version, BAD_CAST "1.0")) &&
12989  (!xmlStrEqual(ctxt->input->version, BAD_CAST "1.0"))) {
12990  xmlFatalErrMsg(ctxt, XML_ERR_VERSION_MISMATCH,
12991  "Version mismatch between document and entity\n");
12992  }
12993  }
12994 
12995  /*
12996  * If the user provided its own SAX callbacks then reuse the
12997  * useData callback field, otherwise the expected setup in a
12998  * DOM builder is to have userData == ctxt
12999  */
13000  if (ctx->userData == ctx)
13001  ctxt->userData = ctxt;
13002  else
13003  ctxt->userData = ctx->userData;
13004 
13005  /*
13006  * Doing validity checking on chunk doesn't make sense
13007  */
13008  ctxt->instate = XML_PARSER_CONTENT;
13009  ctxt->validate = ctx->validate;
13010  ctxt->valid = ctx->valid;
13011  ctxt->loadsubset = ctx->loadsubset;
13012  ctxt->depth = ctx->depth + 1;
13013  ctxt->replaceEntities = ctx->replaceEntities;
13014  if (ctxt->validate) {
13015  ctxt->vctxt.error = ctx->vctxt.error;
13016  ctxt->vctxt.warning = ctx->vctxt.warning;
13017  } else {
13018  ctxt->vctxt.error = NULL;
13019  ctxt->vctxt.warning = NULL;
13020  }
13021  ctxt->vctxt.nodeTab = NULL;
13022  ctxt->vctxt.nodeNr = 0;
13023  ctxt->vctxt.nodeMax = 0;
13024  ctxt->vctxt.node = NULL;
13025  if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);
13026  ctxt->dict = ctx->dict;
13027  ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
13028  ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
13029  ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
13030  ctxt->dictNames = ctx->dictNames;
13031  ctxt->attsDefault = ctx->attsDefault;
13032  ctxt->attsSpecial = ctx->attsSpecial;
13033  ctxt->linenumbers = ctx->linenumbers;
13034 
13035  xmlParseContent(ctxt);
13036 
13037  ctx->validate = ctxt->validate;
13038  ctx->valid = ctxt->valid;
13039  if ((RAW == '<') && (NXT(1) == '/')) {
13041  } else if (RAW != 0) {
13043  }
13044  if (ctxt->node != newDoc->children) {
13046  }
13047 
13048  if (!ctxt->wellFormed) {
13049  if (ctxt->errNo == 0)
13050  ret = 1;
13051  else
13052  ret = ctxt->errNo;
13053  } else {
13054  if (lst != NULL) {
13055  xmlNodePtr cur;
13056 
13057  /*
13058  * Return the newly created nodeset after unlinking it from
13059  * they pseudo parent.
13060  */
13061  cur = newDoc->children->children;
13062  *lst = cur;
13063  while (cur != NULL) {
13064  cur->parent = NULL;
13065  cur = cur->next;
13066  }
13067  newDoc->children->children = NULL;
13068  }
13069  ret = 0;
13070  }
13071  ctxt->sax = oldsax;
13072  ctxt->dict = NULL;
13073  ctxt->attsDefault = NULL;
13074  ctxt->attsSpecial = NULL;
13075  xmlFreeParserCtxt(ctxt);
13076  newDoc->intSubset = NULL;
13077  newDoc->extSubset = NULL;
13078  xmlFreeDoc(newDoc);
13079 
13080  return(ret);
13081 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
int nodeMax
Definition: valid.h:90
int nodeNr
Definition: valid.h:89
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:645
xmlParserInputState instate
Definition: parser.h:223
int properties
Definition: tree.h:584
const xmlChar * URL
Definition: tree.h:577
#define GROW
Definition: parser.c:2087
struct _xmlDtd * intSubset
Definition: tree.h:570
#define NXT(val)
Definition: parser.c:2035
const xmlChar * cur
Definition: parser.h:61
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2042
void xmlParseTextDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:6852
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:14018
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:865
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:800
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:1075
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:9818
int nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
Definition: parser.c:1776
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
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 10615 of file parser.c.

10615  {
10616  xmlChar start[4];
10617  xmlCharEncoding enc;
10618 
10619  xmlInitParser();
10620 
10621  if ((ctxt == NULL) || (ctxt->input == NULL))
10622  return(-1);
10623 
10624  GROW;
10625 
10626  /*
10627  * SAX: detecting the level.
10628  */
10629  xmlDetectSAX2(ctxt);
10630 
10631  /*
10632  * SAX: beginning of the document processing.
10633  */
10634  if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
10635  ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
10636  if (ctxt->instate == XML_PARSER_EOF)
10637  return(-1);
10638 
10639  if ((ctxt->encoding == NULL) &&
10640  ((ctxt->input->end - ctxt->input->cur) >= 4)) {
10641  /*
10642  * Get the 4 first bytes and decode the charset
10643  * if enc != XML_CHAR_ENCODING_NONE
10644  * plug some encoding conversion routines.
10645  */
10646  start[0] = RAW;
10647  start[1] = NXT(1);
10648  start[2] = NXT(2);
10649  start[3] = NXT(3);
10650  enc = xmlDetectCharEncoding(&start[0], 4);
10651  if (enc != XML_CHAR_ENCODING_NONE) {
10652  xmlSwitchEncoding(ctxt, enc);
10653  }
10654  }
10655 
10656 
10657  if (CUR == 0) {
10659  return(-1);
10660  }
10661 
10662  /*
10663  * Check for the XMLDecl in the Prolog.
10664  * do not GROW here to avoid the detected encoder to decode more
10665  * than just the first line, unless the amount of data is really
10666  * too small to hold "<?xml version="1.0" encoding="foo"
10667  */
10668  if ((ctxt->input->end - ctxt->input->cur) < 35) {
10669  GROW;
10670  }
10671  if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
10672 
10673  /*
10674  * Note that we will switch encoding on the fly.
10675  */
10676  xmlParseXMLDecl(ctxt);
10677  if ((ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) ||
10678  (ctxt->instate == XML_PARSER_EOF)) {
10679  /*
10680  * The XML REC instructs us to stop parsing right here
10681  */
10682  return(-1);
10683  }
10684  ctxt->standalone = ctxt->input->standalone;
10685  SKIP_BLANKS;
10686  } else {
10688  }
10689  if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX))
10690  ctxt->sax->startDocument(ctxt->userData);
10691  if (ctxt->instate == XML_PARSER_EOF)
10692  return(-1);
10693  if ((ctxt->myDoc != NULL) && (ctxt->input != NULL) &&
10694  (ctxt->input->buf != NULL) && (ctxt->input->buf->compressed >= 0)) {
10695  ctxt->myDoc->compression = ctxt->input->buf->compressed;
10696  }
10697 
10698  /*
10699  * The Misc part of the Prolog
10700  */
10701  GROW;
10702  xmlParseMisc(ctxt);
10703 
10704  /*
10705  * Then possibly doc type declaration(s) and more Misc
10706  * (doctypedecl Misc*)?
10707  */
10708  GROW;
10709  if (CMP9(CUR_PTR, '<', '!', 'D', 'O', 'C', 'T', 'Y', 'P', 'E')) {
10710 
10711  ctxt->inSubset = 1;
10712  xmlParseDocTypeDecl(ctxt);
10713  if (RAW == '[') {
10714  ctxt->instate = XML_PARSER_DTD;
10715  xmlParseInternalSubset(ctxt);
10716  if (ctxt->instate == XML_PARSER_EOF)
10717  return(-1);
10718  }
10719 
10720  /*
10721  * Create and update the external subset.
10722  */
10723  ctxt->inSubset = 2;
10724  if ((ctxt->sax != NULL) && (ctxt->sax->externalSubset != NULL) &&
10725  (!ctxt->disableSAX))
10726  ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName,
10727  ctxt->extSubSystem, ctxt->extSubURI);
10728  if (ctxt->instate == XML_PARSER_EOF)
10729  return(-1);
10730  ctxt->inSubset = 0;
10731 
10732  xmlCleanSpecialAttr(ctxt);
10733 
10734  ctxt->instate = XML_PARSER_PROLOG;
10735  xmlParseMisc(ctxt);
10736  }
10737 
10738  /*
10739  * Time to start parsing the tree itself
10740  */
10741  GROW;
10742  if (RAW != '<') {
10743  xmlFatalErrMsg(ctxt, XML_ERR_DOCUMENT_EMPTY,
10744  "Start tag expected, '<' not found\n");
10745  } else {
10746  ctxt->instate = XML_PARSER_CONTENT;
10747  xmlParseElement(ctxt);
10748  ctxt->instate = XML_PARSER_EPILOG;
10749 
10750 
10751  /*
10752  * The Misc part at the end
10753  */
10754  xmlParseMisc(ctxt);
10755 
10756  if (RAW != 0) {
10758  }
10759  ctxt->instate = XML_PARSER_EOF;
10760  }
10761 
10762  /*
10763  * SAX: end of the document processing.
10764  */
10765  if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
10766  ctxt->sax->endDocument(ctxt->userData);
10767 
10768  /*
10769  * Remove locally kept entity definitions if the tree was not built
10770  */
10771  if ((ctxt->myDoc != NULL) &&
10773  xmlFreeDoc(ctxt->myDoc);
10774  ctxt->myDoc = NULL;
10775  }
10776 
10777  if ((ctxt->wellFormed) && (ctxt->myDoc != NULL)) {
10779  if (ctxt->valid)
10780  ctxt->myDoc->properties |= XML_DOC_DTDVALID;
10781  if (ctxt->nsWellFormed)
10782  ctxt->myDoc->properties |= XML_DOC_NSVALID;
10783  if (ctxt->options & XML_PARSE_OLD10)
10784  ctxt->myDoc->properties |= XML_DOC_OLD10;
10785  }
10786  if (! ctxt->wellFormed) {
10787  ctxt->valid = 0;
10788  return(-1);
10789  }
10790  return(0);
10791 }
XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator
Definition: globals.h:329
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
xmlParserInputState instate
Definition: parser.h:223
int properties
Definition: tree.h:584
xmlChar * extSubURI
Definition: parser.h:240
#define GROW
Definition: parser.c:2087
static void xmlParseInternalSubset(xmlParserCtxtPtr ctxt)
Definition: parser.c:8280
const xmlChar * version
Definition: tree.h:573
#define NXT(val)
Definition: parser.c:2035
int nsWellFormed
Definition: parser.h:286
const xmlChar * cur
Definition: parser.h:61
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2042
xmlCharEncoding
Definition: encoding.h:58
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2050
#define SKIP_BLANKS
Definition: parser.c:2115
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:8208
int standalone
Definition: parser.h:192
#define IS_BLANK_CH(c)
int standalone
Definition: parser.h:75
void xmlInitParser(void)
Definition: parser.c:14740
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:9908
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:10585
xmlParserInputBufferPtr buf
Definition: parser.h:56
#define CUR
Definition: parser.c:2034
int inSubset
Definition: parser.h:238
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1075
GLuint start
Definition: gl.h:1545
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
static void xmlCleanSpecialAttr(xmlParserCtxtPtr ctxt)
Definition: parser.c:1374
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xmlParseXMLDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:10470
#define SAX_COMPAT_MODE
Definition: parser.c:258
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 10808 of file parser.c.

10808  {
10809  xmlChar start[4];
10810  xmlCharEncoding enc;
10811 
10812  if ((ctxt == NULL) || (ctxt->input == NULL))
10813  return(-1);
10814 
10816 
10817  xmlDetectSAX2(ctxt);
10818 
10819  GROW;
10820 
10821  /*
10822  * SAX: beginning of the document processing.
10823  */
10824  if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
10825  ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
10826 
10827  /*
10828  * Get the 4 first bytes and decode the charset
10829  * if enc != XML_CHAR_ENCODING_NONE
10830  * plug some encoding conversion routines.
10831  */
10832  if ((ctxt->input->end - ctxt->input->cur) >= 4) {
10833  start[0] = RAW;
10834  start[1] = NXT(1);
10835  start[2] = NXT(2);
10836  start[3] = NXT(3);
10837  enc = xmlDetectCharEncoding(start, 4);
10838  if (enc != XML_CHAR_ENCODING_NONE) {
10839  xmlSwitchEncoding(ctxt, enc);
10840  }
10841  }
10842 
10843 
10844  if (CUR == 0) {
10846  }
10847 
10848  /*
10849  * Check for the XMLDecl in the Prolog.
10850  */
10851  GROW;
10852  if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
10853 
10854  /*
10855  * Note that we will switch encoding on the fly.
10856  */
10857  xmlParseXMLDecl(ctxt);
10858  if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
10859  /*
10860  * The XML REC instructs us to stop parsing right here
10861  */
10862  return(-1);
10863  }
10864  SKIP_BLANKS;
10865  } else {
10867  }
10868  if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX))
10869  ctxt->sax->startDocument(ctxt->userData);
10870  if (ctxt->instate == XML_PARSER_EOF)
10871  return(-1);
10872 
10873  /*
10874  * Doing validity checking on chunk doesn't make sense
10875  */
10876  ctxt->instate = XML_PARSER_CONTENT;
10877  ctxt->validate = 0;
10878  ctxt->loadsubset = 0;
10879  ctxt->depth = 0;
10880 
10881  xmlParseContent(ctxt);
10882  if (ctxt->instate == XML_PARSER_EOF)
10883  return(-1);
10884 
10885  if ((RAW == '<') && (NXT(1) == '/')) {
10887  } else if (RAW != 0) {
10889  }
10890 
10891  /*
10892  * SAX: end of the document processing.
10893  */
10894  if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
10895  ctxt->sax->endDocument(ctxt->userData);
10896 
10897  if (! ctxt->wellFormed) return(-1);
10898  return(0);
10899 }
XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator
Definition: globals.h:329
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2087
#define NXT(val)
Definition: parser.c:2035
const xmlChar * cur
Definition: parser.h:61
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2042
xmlCharEncoding
Definition: encoding.h:58
#define SKIP_BLANKS
Definition: parser.c:2115
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:2034
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1075
GLuint start
Definition: gl.h:1545
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit(void)
Definition: SAX2.c:2941
void xmlParseContent(xmlParserCtxtPtr ctxt)
Definition: parser.c:9818
#define CUR_PTR
Definition: parser.c:2036
#define RAW
Definition: parser.c:2033
void xmlParseXMLDecl(xmlParserCtxtPtr ctxt)
Definition: parser.c:10470
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 13562 of file parser.c.

13563  {
13564 #ifdef SAX2
13565  xmlParserCtxtPtr ctxt;
13566  xmlDocPtr doc = NULL;
13567  xmlNodePtr fake, cur;
13568  int nsnr = 0;
13569 
13571 
13572  /*
13573  * check all input parameters, grab the document
13574  */
13575  if ((lst == NULL) || (node == NULL) || (data == NULL) || (datalen < 0))
13576  return(XML_ERR_INTERNAL_ERROR);
13577  switch (node->type) {
13578  case XML_ELEMENT_NODE:
13579  case XML_ATTRIBUTE_NODE:
13580  case XML_TEXT_NODE:
13582  case XML_ENTITY_REF_NODE:
13583  case XML_PI_NODE:
13584  case XML_COMMENT_NODE:
13585  case XML_DOCUMENT_NODE:
13587  break;
13588  default:
13589  return(XML_ERR_INTERNAL_ERROR);
13590 
13591  }
13592  while ((node != NULL) && (node->type != XML_ELEMENT_NODE) &&
13593  (node->type != XML_DOCUMENT_NODE) &&
13594  (node->type != XML_HTML_DOCUMENT_NODE))
13595  node = node->parent;
13596  if (node == NULL)
13597  return(XML_ERR_INTERNAL_ERROR);
13598  if (node->type == XML_ELEMENT_NODE)
13599  doc = node->doc;
13600  else
13601  doc = (xmlDocPtr) node;
13602  if (doc == NULL)
13603  return(XML_ERR_INTERNAL_ERROR);
13604 
13605  /*
13606  * allocate a context and set-up everything not related to the
13607  * node position in the tree
13608  */
13609  if (doc->type == XML_DOCUMENT_NODE)
13610  ctxt = xmlCreateMemoryParserCtxt((char *) data, datalen);
13611 #ifdef LIBXML_HTML_ENABLED
13612  else if (doc->type == XML_HTML_DOCUMENT_NODE) {
13613  ctxt = htmlCreateMemoryParserCtxt((char *) data, datalen);
13614  /*
13615  * When parsing in context, it makes no sense to add implied
13616  * elements like html/body/etc...
13617  */
13618  options |= HTML_PARSE_NOIMPLIED;
13619  }
13620 #endif
13621  else
13622  return(XML_ERR_INTERNAL_ERROR);
13623 
13624  if (ctxt == NULL)
13625  return(XML_ERR_NO_MEMORY);
13626 
13627  /*
13628  * Use input doc's dict if present, else assure XML_PARSE_NODICT is set.
13629  * We need a dictionary for xmlDetectSAX2, so if there's no doc dict
13630  * we must wait until the last moment to free the original one.
13631  */
13632  if (doc->dict != NULL) {
13633  if (ctxt->dict != NULL)
13634  xmlDictFree(ctxt->dict);
13635  ctxt->dict = doc->dict;
13636  } else
13638 
13639  if (doc->encoding != NULL) {
13641 
13642  if (ctxt->encoding != NULL)
13643  xmlFree((xmlChar *) ctxt->encoding);
13644  ctxt->encoding = xmlStrdup((const xmlChar *) doc->encoding);
13645 
13646  hdlr = xmlFindCharEncodingHandler((const char *) doc->encoding);
13647  if (hdlr != NULL) {
13648  xmlSwitchToEncoding(ctxt, hdlr);
13649  } else {
13651  }
13652  }
13653 
13655  xmlDetectSAX2(ctxt);
13656  ctxt->myDoc = doc;
13657  /* parsing in context, i.e. as within existing content */
13658  ctxt->input_id = 2;
13659  ctxt->instate = XML_PARSER_CONTENT;
13660 
13661  fake = xmlNewComment(NULL);
13662  if (fake == NULL) {
13663  xmlFreeParserCtxt(ctxt);
13664  return(XML_ERR_NO_MEMORY);
13665  }
13666  xmlAddChild(node, fake);
13667 
13668  if (node->type == XML_ELEMENT_NODE) {
13669  nodePush(ctxt, node);
13670  /*
13671  * initialize the SAX2 namespaces stack
13672  */
13673  cur = node;
13674  while ((cur != NULL) && (cur->type == XML_ELEMENT_NODE)) {
13675  xmlNsPtr ns = cur->nsDef;
13676  const xmlChar *iprefix, *ihref;
13677 
13678  while (ns != NULL) {
13679  if (ctxt->dict) {
13680  iprefix = xmlDictLookup(ctxt->dict, ns->prefix, -1);
13681  ihref = xmlDictLookup(ctxt->dict, ns->href, -1);
13682  } else {
13683  iprefix = ns->prefix;
13684  ihref = ns->href;
13685  }
13686 
13687  if (xmlGetNamespace(ctxt, iprefix) == NULL) {
13688  nsPush(ctxt, iprefix, ihref);
13689  nsnr++;
13690  }
13691  ns = ns->next;
13692  }
13693  cur = cur->parent;
13694  }
13695  }
13696 
13697  if ((ctxt->validate) || (ctxt->replaceEntities != 0)) {
13698  /*
13699  * ID/IDREF registration will be done in xmlValidateElement below
13700  */
13701  ctxt->loadsubset |= XML_SKIP_IDS;
13702  }
13703 
13704 #ifdef LIBXML_HTML_ENABLED
13705  if (doc->type == XML_HTML_DOCUMENT_NODE)
13706  __htmlParseContent(ctxt);
13707  else
13708 #endif
13709  xmlParseContent(ctxt);
13710 
13711  nsPop(ctxt, nsnr);
13712  if ((RAW == '<') && (NXT(1) == '/')) {
13714  } else if (RAW != 0) {
13716  }
13717  if ((ctxt->node != NULL) && (ctxt->node != node)) {
13719  ctxt->wellFormed = 0;
13720  }
13721 
13722  if (!ctxt->wellFormed) {
13723  if (ctxt->errNo == 0)
13725  else
13726  ret = (xmlParserErrors)ctxt->errNo;
13727  } else {
13728  ret = XML_ERR_OK;
13729  }
13730 
13731  /*
13732  * Return the newly created nodeset after unlinking it from
13733  * the pseudo sibling.
13734  */
13735 
13736  cur = fake->next;
13737  fake->next = NULL;
13738  node->last = fake;
13739 
13740  if (cur != NULL) {
13741  cur->prev = NULL;
13742  }
13743 
13744  *lst = cur;
13745 
13746  while (cur != NULL) {
13747  cur->parent = NULL;
13748  cur = cur->next;
13749  }
13750 
13751  xmlUnlinkNode(fake);
13752  xmlFreeNode(fake);
13753 
13754 
13755  if (ret != XML_ERR_OK) {
13756  xmlFreeNodeList(*lst);
13757  *lst = NULL;
13758  }
13759 
13760  if (doc->dict != NULL)
13761  ctxt->dict = NULL;
13762  xmlFreeParserCtxt(ctxt);
13763 
13764  return(ret);
13765 #else /* !SAX2 */
13766  return(XML_ERR_INTERNAL_ERROR);
13767 #endif
13768 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
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:8686
Definition: tree.h:389
XMLPUBFUN void XMLCALL xmlFreeNodeList(xmlNodePtr cur)
#define NXT(val)
Definition: parser.c:2035
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1030
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:15045
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:1654
static int nsPush(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URL)
Definition: parser.c:1604
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
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:800
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:14403
xmlDoc * xmlDocPtr
Definition: tree.h:550
struct _xmlNode * next
Definition: tree.h:496
static void xmlDetectSAX2(xmlParserCtxtPtr ctxt)
Definition: parser.c:1075
Definition: tree.h:551
XMLPUBFUN void XMLCALL xmlFreeNode(xmlNodePtr cur)
void xmlParseContent(xmlParserCtxtPtr ctxt)
Definition: parser.c:9818
int nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
Definition: parser.c:1776
#define RAW
Definition: parser.c:2033
#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 xmlParseElementEnd(), xmlParseElementStart(), and xmlSAX2EndElementNs().

◆ xmlParserFindNodeInfo()

XMLPUBFUN const xmlParserNodeInfo* XMLCALL xmlParserFindNodeInfo ( const xmlParserCtxtPtr  ctx,
const xmlNodePtr  node 
)

xmlParserFindNodeInfo: @ctx: an XML parser context @node: an XML node within the tree

Find the parser node info struct for a given node

Returns an xmlParserNodeInfo block pointer or NULL

Definition at line 1911 of file parserInternals.c.

1912 {
1913  unsigned long pos;
1914 
1915  if ((ctx == NULL) || (node == NULL))
1916  return (NULL);
1917  /* Find position where node should be at */
1919  if (pos < ctx->node_seq.length
1920  && ctx->node_seq.buffer[pos].node == node)
1921  return &ctx->node_seq.buffer[pos];
1922  else
1923  return