struct xmlParserInput {
/* Input buffer */
xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
const char *filename; /* The file analyzed, if any */
const char *directory; /* the directory/base of teh file */
const xmlChar *base; /* Base of the array to parse */
const xmlChar *cur; /* Current char being parsed */
int length; /* length if known */
int line; /* Current line */
int col; /* Current column */
int consumed; /* How many xmlChars already consumed */
xmlParserInputDeallocate free; /* function to deallocate the base */
/* added after 2.3.5 integration */
const xmlChar *end; /* end of the arry to parse */
const xmlChar *encoding; /* the encoding string for entity */
const xmlChar *version; /* the version string for entity */
int standalone; /* Was that entity marked standalone */
};
xmlParserInputPtr
typedef xmlParserInput *xmlParserInputPtr;
struct xmlParserNodeInfo
struct xmlParserNodeInfo {
const struct _xmlNode* node;
/* 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;
};
xmlParserNodeInfoPtr
typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
struct xmlParserNodeInfoSeq
struct xmlParserNodeInfoSeq {
unsigned long maximum;
unsigned long length;
xmlParserNodeInfo* buffer;
};
typedef enum {
XML_PARSER_EOF = -1, /* nothing is to be parsed */
XML_PARSER_START = 0, /* nothing has been parsed */
XML_PARSER_MISC, /* Misc* before int subset */
XML_PARSER_PI, /* Whithin a processing instruction */
XML_PARSER_DTD, /* within some DTD content */
XML_PARSER_PROLOG, /* Misc* after internal subset */
XML_PARSER_COMMENT, /* within a comment */
XML_PARSER_START_TAG, /* within a start tag */
XML_PARSER_CONTENT, /* within the content */
XML_PARSER_CDATA_SECTION, /* within a CDATA section */
XML_PARSER_END_TAG, /* within a closing tag */
XML_PARSER_ENTITY_DECL, /* within an entity declaration */
XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
XML_PARSER_EPILOG, /* the Misc* after the last end tag */
/* added after 2.3.5 integration */
XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
XML_PARSER_IGNORE /* within an IGNORED section */
} xmlParserInputState;
struct xmlParserCtxt
struct xmlParserCtxt {
struct _xmlSAXHandler *sax; /* The SAX handler */
void *userData; /* the document being built */
xmlDocPtr myDoc; /* the document being built */
int wellFormed; /* is the document well formed */
int replaceEntities; /* shall we replace entities ? */
const xmlChar *version; /* the XML version string */
const xmlChar *encoding; /* encoding, if any */
int standalone; /* standalone document */
int html; /* are we parsing an HTML document */
/* Input stream stack */
xmlParserInputPtr input; /* Current input stream */
int inputNr; /* Number of current input streams */
int inputMax; /* Max number of input streams */
xmlParserInputPtr *inputTab; /* stack of inputs */
/* Node analysis stack only used for DOM building */
xmlNodePtr node; /* Current parsed Node */
int nodeNr; /* Depth of the parsing stack */
int nodeMax; /* Max depth of the parsing stack */
xmlNodePtr *nodeTab; /* array of nodes */
int record_info; /* Whether node info should be kept */
xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
int errNo; /* error code */
int hasExternalSubset; /* reference and external subset */
int hasPErefs; /* the internal subset has PE refs */
int external; /* are we parsing an external entity */
int valid; /* is the document valid */
int validate; /* shall we try to validate ? */
xmlValidCtxt vctxt; /* The validity context */
xmlParserInputState instate; /* current type of input */
int token; /* next char look-ahead */
char *directory; /* the data directory */
/* Node name stack only used for HTML parsing */
xmlChar *name; /* Current parsed Node */
int nameNr; /* Depth of the parsing stack */
int nameMax; /* Max depth of the parsing stack */
xmlChar * *nameTab; /* array of nodes */
long nbChars; /* number of xmlChar processed */
long checkIndex; /* used by progressive parsing lookup */
int keepBlanks; /* ugly but ... */
/* Added after integration of 2.3.5 parser */
int disableSAX; /* SAX callbacks are disabled */
int inSubset; /* Parsing is in int 1/ext 2 subset */
xmlChar * intSubName; /* name of subset */
xmlChar * extSubURI; /* URI of external subset */
xmlChar * extSubSystem; /* SYSTEM ID of external subset */
/* xml:space values */
int * space; /* Should the parser preserve spaces */
int spaceNr; /* Depth of the parsing stack */
int spaceMax; /* Max depth of the parsing stack */
int * spaceTab; /* array of space infos */
int depth; /* to prevent entity substitution loops */
xmlParserInputPtr entity; /* used to check entities boundaries */
int charset; /* encoding of the in-memory content
actually an xmlCharEncoding */
int nodelen; /* Those two fields are there to */
int nodemem; /* Speed up large node parsing */
int pedantic; /* signal pedantic warnings or loose
behaviour */
void *_private; /* For user data, libxml won't touch it */
int loadsubset; /* should the external subset be loaded */
};
xmlParserCtxtPtr
typedef xmlParserCtxt *xmlParserCtxtPtr;
struct xmlSAXLocator
struct xmlSAXLocator {
const xmlChar *(*getPublicId)(void *ctx);
const xmlChar *(*getSystemId)(void *ctx);
int (*getLineNumber)(void *ctx);
int (*getColumnNumber)(void *ctx);
};
Cleanup function for the XML parser. It tries to reclaim all
parsing related global memory allocated for the parser processing.
It doesn't deallocate any document related memory. Calling this
function should not prevent reusing the parser.
parse an XML file and build a tree. Automatic support for ZLIB/Compress
compressed document is provided by default if found at compile-time.
filename :
the filename
Returns :
the resulting document tree
xmlSubstituteEntitiesDefault ()
int xmlSubstituteEntitiesDefault (int val);
Set and return the previous value for default entity support.
Initially the parser always keep entity references instead of substituting
entity values in the output. This function has to be used to change the
default parser behaviour
SAX::subtituteEntities() has to be used for changing that on a file by
file basis.
val :
int 0 or 1
Returns :
the last value for 0 for no substitution, 1 for substitution.
xmlKeepBlanksDefault ()
int xmlKeepBlanksDefault (int val);
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
ignorableWhitespace() 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 behaviour
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.
val :
int 0 or 1
Returns :
the last value for 0 for no substitution, 1 for substitution.
parse an XML file and build a tree. Automatic support for ZLIB/Compress
compressed document is provided by default if found at compile-time.
In the case the document is not Well Formed, a tree is built anyway
parse an XML in-memory document and build a tree.
It use the given SAX function block to handle the parsing callback.
If sax is NULL, fallback to the default DOM tree building routines.
sax :
the SAX handler block
cur :
a pointer to an array of xmlChar
recovery :
work in recovery mode, i.e. tries to read no Well Formed
documents
Returns :
the resulting document tree
xmlSAXUserParseFile ()
int xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
void *user_data,
const char *filename);
parse an XML file and call the given SAX handler routines.
Automatic support for ZLIB/Compress compressed document is provided
sax :
a SAX handler
user_data :
The user data returned on SAX callbacks
filename :
a file name
Returns :
0 in case of success or a error number otherwise
xmlSAXUserParseMemory ()
int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
void *user_data,
char *buffer,
int size);
A better SAX parsing routine.
parse an XML in-memory buffer and call the given SAX handler routines.
parse an XML in-memory block and use the given SAX function block
to handle the parsing callback. If sax is NULL, fallback to the default
DOM tree building routines.
sax :
the SAX handler block
buffer :
an pointer to a char array
size :
the size of the array
recovery :
work in recovery mode, i.e. tries to read not Well Formed
documents
parse an XML file and build a tree. Automatic support for ZLIB/Compress
compressed document is provided by default if found at compile-time.
It use the given SAX function block to handle the parsing callback.
If sax is NULL, fallback to the default DOM tree building routines.
sax :
the SAX handler block
filename :
the filename
recovery :
work in recovery mode, i.e. tries to read no Well Formed
documents
Setup the parser context to parse a new buffer; Clears any prior
contents from the parser context. The buffer parameter must not be
NULL, but the filename parameter can be
Create a parser context for using the XML parser in push mode
To allow content encoding detection, size should be >= 4
The value of filename is used for fetching external entities
and error/warning reports.
sax :
a SAX handler
user_data :
The user data returned on SAX callbacks
chunk :
a pointer to an array of chars
size :
number of chars in the array
filename :
an optional file name or URI
Returns :
the new parser context or NULL
xmlParseChunk ()
int xmlParseChunk (xmlParserCtxtPtr ctxt,
const char *chunk,
int size,
int terminate);
Set and return the previous value for the default XML parser to use
The 1.x version of the parser up to 1.8.11 is horribly broken
The 2.x and later version aim at completete compliance to the standard
This function is provided as a way to force using the new parser
on 1.X libs when the applications are ready to handle correct XML
and the UTF8 character flow provided by the new parser.
val :
int 0 or 1
Returns :
the last value for 0 for no substitution, 1 for substitution.