/*
* Summary: the core parser module
* Description: Interfaces, constants and types related to the XML parser
*
* Copy: See Copyright for the status of this software.
*
* Author: Daniel Veillard
*/
#ifndef __XML_PARSER_H__
#define __XML_PARSER_H__
#include <stdarg.h>
#include <libxml/xmlversion.h>
#include <libxml/entities.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlstring.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* XML_DEFAULT_VERSION:
*
* The default version of XML used: 1.0
*/
/**
* 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.
*/
struct _xmlParserInput {
/* Input buffer */
/*
* NOTE: consumed is only tested for equality in the parser code,
* so even if there is an overflow this should not give troubles
* for parsing very large instances.
*/
};
/**
* 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.
*/
struct _xmlParserNodeInfo {
/* Position & line # that text that created the node begins & ends on */
unsigned long begin_pos;
unsigned long begin_line;
unsigned long end_pos;
unsigned long end_line;
};
struct _xmlParserNodeInfoSeq {
unsigned long maximum;
unsigned long length;
};
/**
* xmlParserInputState:
*
* The parser is now working also as a state based parser.
* The recursive one use the state info for entities processing.
*/
typedef enum {
/**
* XML_DETECT_IDS:
*
* Use it to initialize xmlLoadExtDtdDefaultValue.
*/
/**
* 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.
*/
/**
* XML_SKIP_IDS:
*
* Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
*/
/**
* xmlParserMode:
*
* A parser can operate in various modes
*/
typedef enum {
XML_PARSE_UNKNOWN = 0,
/**
* xmlParserCtxt:
*
* The parser context.
* NOTE This doesn't completely define the parser state, the (current ?)
* design of the parser uses recursive function calls since this allow
* and easy mapping from the production rules of the specification
* to the actual code. The drawback is that the actual function call
* also reflect the parser state. However most of the parsing routines
* takes as the only argument the parser context pointer, so migrating
* to a state based parser for progressive parsing shouldn't be too hard.
*/
struct _xmlParserCtxt {
/* Input stream stack */
/* Node analysis stack only used for DOM building */
/* Node name stack */
/* xml:space values */
actually an xmlCharEncoding */
/*
* pre-interned strings
*/
/*
* Everything below is used only by the new SAX mode
*/
/*
* Those fields are needed only for treaming parsing so far
*/
/*
* the complete error informations for the last error.
*/
};
/**
* xmlSAXLocator:
*
* A SAX Locator.
*/
struct _xmlSAXLocator {
};
/**
* 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.
*/
/**
* internalSubsetSAXFunc:
* @ctx: the user data (XML parser context)
* @name: the root element name
* @ExternalID: the external ID
* @SystemID: the SYSTEM ID (e.g. filename or URL)
*
* Callback on internal subset declaration.
*/
const xmlChar *ExternalID,
/**
* externalSubsetSAXFunc:
* @ctx: the user data (XML parser context)
* @name: the root element name
* @ExternalID: the external ID
* @SystemID: the SYSTEM ID (e.g. filename or URL)
*
* Callback on external subset declaration.
*/
const xmlChar *ExternalID,
/**
* getEntitySAXFunc:
* @ctx: the user data (XML parser context)
* @name: The entity name
*
* Get an entity by name.
*
* Returns the xmlEntityPtr if found.
*/
/**
* getParameterEntitySAXFunc:
* @ctx: the user data (XML parser context)
* @name: The entity name
*
* Get a parameter entity by name.
*
* Returns the xmlEntityPtr if found.
*/
/**
* entityDeclSAXFunc:
* @ctx: the user data (XML parser context)
* @name: the entity name
* @type: the entity type
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @content: the entity value (without processing).
*
* An entity definition has been parsed.
*/
int type,
/**
* notationDeclSAXFunc:
* @ctx: the user data (XML parser context)
* @name: The name of the notation
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
*
* What to do when a notation declaration has been parsed.
*/
/**
* attributeDeclSAXFunc:
* @ctx: the user data (XML parser context)
* @elem: the name of the element
* @fullname: the attribute name
* @type: the attribute type
* @def: the type of default value
* @defaultValue: the attribute default value
* @tree: the tree of enumerated value set
*
* An attribute definition has been parsed.
*/
int type,
int def,
const xmlChar *defaultValue,
/**
* elementDeclSAXFunc:
* @ctx: the user data (XML parser context)
* @name: the element name
* @type: the element type
* @content: the element value tree
*
* An element definition has been parsed.
*/
int type,
/**
* unparsedEntityDeclSAXFunc:
* @ctx: the user data (XML parser context)
* @name: The name of the entity
* @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.
*/
const xmlChar *notationName);
/**
* 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.
*/
/**
* startDocumentSAXFunc:
* @ctx: the user data (XML parser context)
*
* Called when the document start being processed.
*/
/**
* endDocumentSAXFunc:
* @ctx: the user data (XML parser context)
*
* Called when the document end has been detected.
*/
/**
* startElementSAXFunc:
* @ctx: the user data (XML parser context)
* @name: The element name, including namespace prefix
*
* Called when an opening tag has been processed.
*/
/**
* endElementSAXFunc:
* @ctx: the user data (XML parser context)
* @name: The element name
*
* Called when the end of an element has been detected.
*/
/**
* attributeSAXFunc:
* @ctx: the user data (XML parser context)
* @name: The attribute name, including namespace prefix
* @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.
*/
/**
* referenceSAXFunc:
* @ctx: the user data (XML parser context)
* @name: The entity name
*
* Called when an entity reference is detected.
*/
/**
* charactersSAXFunc:
* @ctx: the user data (XML parser context)
* @ch: a xmlChar string
* @len: the number of xmlChar
*
* Receiving some chars from the parser.
*/
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.
*/
int len);
/**
* processingInstructionSAXFunc:
* @ctx: the user data (XML parser context)
* @target: the target name
* @data: the PI data's
*
* A processing instruction has been parsed.
*/
/**
* commentSAXFunc:
* @ctx: the user data (XML parser context)
* @value: the comment content
*
* A comment has been parsed.
*/
/**
* cdataBlockSAXFunc:
* @ctx: the user data (XML parser context)
* @value: The pcdata content
* @len: the block length
*
* Called when a pcdata block has been parsed.
*/
typedef void (*cdataBlockSAXFunc) (
void *ctx,
int len);
/**
* warningSAXFunc:
* @ctx: an XML parser context
* @...: extra parameters for the message display
*
* Display and format a warning messages, callback.
*/
const char *msg, ...);
/**
* errorSAXFunc:
* @ctx: an XML parser context
* @...: extra parameters for the message display
*
* Display and format an error messages, callback.
*/
const char *msg, ...);
/**
* fatalErrorSAXFunc:
* @ctx: an XML parser context
* @...: 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.
*/
const char *msg, ...);
/**
* isStandaloneSAXFunc:
* @ctx: the user data (XML parser context)
*
* Is this document tagged standalone?
*
* Returns 1 if true
*/
/**
* hasInternalSubsetSAXFunc:
* @ctx: the user data (XML parser context)
*
* Does this document has an internal subset.
*
* Returns 1 if true
*/
/**
* hasExternalSubsetSAXFunc:
* @ctx: the user data (XML parser context)
*
* Does this document has an external subset?
*
* Returns 1 if true
*/
/************************************************************************
* *
* The SAX version 2 API extensions *
* *
************************************************************************/
/**
* XML_SAX2_MAGIC:
*
* Special constant found in SAX2 blocks initialized fields
*/
/**
* 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
* @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
* 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.
*/
int nb_namespaces,
const xmlChar **namespaces,
int nb_attributes,
int nb_defaulted,
const xmlChar **attributes);
/**
* 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.
*/
struct _xmlSAXHandler {
unsigned int initialized;
/* The following fields are extensions available only on version 2 */
void *_private;
};
/*
* SAX Version 1
*/
struct _xmlSAXHandlerV1 {
unsigned int initialized;
};
/**
* 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.
*/
const char *ID,
#ifdef __cplusplus
}
#endif
#include <libxml/encoding.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
*/
xmlInitParser (void);
xmlCleanupParser (void);
/*
* Input functions
*/
int len);
int len);
/*
* Basic parsing Interfaces
*/
#ifdef LIBXML_SAX1_ENABLED
xmlParseFile (const char *filename);
xmlParseMemory (const char *buffer,
int size);
#endif /* LIBXML_SAX1_ENABLED */
xmlKeepBlanksDefault (int val);
xmlPedanticParserDefault(int val);
xmlLineNumbersDefault (int val);
#ifdef LIBXML_SAX1_ENABLED
/*
* Recovery mode
*/
xmlRecoverMemory (const char *buffer,
int size);
xmlRecoverFile (const char *filename);
#endif /* LIBXML_SAX1_ENABLED */
/*
* Less common routines and SAX interfaces
*/
#ifdef LIBXML_SAX1_ENABLED
void *user_data,
const char *filename);
void *user_data,
const char *buffer,
int size);
int recovery);
const char *buffer,
int size,
int recovery);
const char *buffer,
int size,
int recovery,
void *data);
const char *filename,
int recovery);
const char *filename,
int recovery,
void *data);
const char *filename);
xmlParseEntity (const char *filename);
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_VALID_ENABLED
const xmlChar *ExternalID,
#endif /* LIBXML_VALID_ENABLE */
#ifdef LIBXML_SAX1_ENABLED
void *user_data,
int depth,
xmlNodePtr *lst);
#endif /* LIBXML_SAX1_ENABLED */
const char *data,
int datalen,
int options,
xmlNodePtr *lst);
#ifdef LIBXML_SAX1_ENABLED
void *user_data,
int depth,
int recover);
void *user_data,
int depth,
xmlNodePtr *lst);
#endif /* LIBXML_SAX1_ENABLED */
xmlNodePtr *lst);
/*
* Parser contexts handling.
*/
xmlNewParserCtxt (void);
#ifdef LIBXML_SAX1_ENABLED
const char *filename);
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_LEGACY_ENABLED
/*
*/
xmlGetFeaturesList (int *len,
const char **result);
const char *name,
void *result);
const char *name,
void *value);
#endif /* LIBXML_LEGACY_ENABLED */
#ifdef LIBXML_PUSH_ENABLED
/*
* Interfaces for the Push mode.
*/
void *user_data,
const char *chunk,
int size,
const char *filename);
const char *chunk,
int size,
int terminate);
#endif /* LIBXML_PUSH_ENABLED */
/*
* Special I/O mode.
*/
void *user_data,
void *ioctx,
/*
* Node infos.
*/
const xmlNodePtr node);
const xmlNodePtr node);
const xmlParserNodeInfoPtr info);
/*
* External entities handling actually implemented in xmlIO.
*/
xmlGetExternalEntityLoader(void);
xmlLoadExternalEntity (const char *URL,
const char *ID,
/*
* Index lookup, actually implemented in the encoding module
*/
/*
*/
/**
* xmlParserOption:
*
* This is the set of XML parser options that can be passed down
* to the xmlReadDoc() and similar calls.
*/
typedef enum {
the tree allowed afterwards (will possibly
crash if you try to modify the tree) */
const char *chunk,
int size,
const char *filename,
const char *encoding);
int options);
const char *URL,
const char *encoding,
int options);
xmlReadFile (const char *URL,
const char *encoding,
int options);
xmlReadMemory (const char *buffer,
int size,
const char *URL,
const char *encoding,
int options);
const char *URL,
const char *encoding,
int options);
void *ioctx,
const char *URL,
const char *encoding,
int options);
const char *URL,
const char *encoding,
int options);
const char *filename,
const char *encoding,
int options);
const char *buffer,
int size,
const char *URL,
const char *encoding,
int options);
int fd,
const char *URL,
const char *encoding,
int options);
void *ioctx,
const char *URL,
const char *encoding,
int options);
/*
* Library wide options
*/
/**
* xmlFeature:
*
* Used to examine the existance of features that can be enabled
* or disabled at compile-time.
* They used to be called XML_FEATURE_xxx but this clashed with Expat
*/
typedef enum {
} xmlFeature;
#ifdef __cplusplus
}
#endif
#endif /* __XML_PARSER_H__ */