2 * Summary: the core parser module
3 * Description: Interfaces, constants and types related to the XML parser
5 * Copy: See Copyright for the status of this software.
7 * Author: Daniel Veillard
10 #ifndef __XML_PARSER_H__
11 #define __XML_PARSER_H__
15 #include <libxml/xmlversion.h>
16 #include <libxml/tree.h>
17 #include <libxml/dict.h>
18 #include <libxml/hash.h>
19 #include <libxml/valid.h>
20 #include <libxml/entities.h>
21 #include <libxml/xmlerror.h>
22 #include <libxml/xmlstring.h>
29 * XML_DEFAULT_VERSION:
31 * The default version of XML used: 1.0
33 #define XML_DEFAULT_VERSION "1.0"
38 * An xmlParserInput is an input flow for the XML processor.
39 * Each entity parsed is associated an xmlParserInput (except the
40 * few predefined ones). This is the case both for internal entities
41 * - in which case the flow is already completely in memory - or
42 * external entities - in which case we use the buf structure for
43 * progressive reading and I18N conversions to the internal UTF-8 format.
47 * xmlParserInputDeallocate:
48 * @str: the string to deallocate
50 * Callback for freeing some parser input allocations.
52 typedef void (* xmlParserInputDeallocate
)(xmlChar
*str
);
54 struct _xmlParserInput
{
56 xmlParserInputBufferPtr buf
; /* UTF-8 encoded buffer */
58 const char *filename
; /* The file analyzed, if any */
59 const char *directory
; /* the directory/base of the file */
60 const xmlChar
*base
; /* Base of the array to parse */
61 const xmlChar
*cur
; /* Current char being parsed */
62 const xmlChar
*end
; /* end of the array to parse */
63 int length
; /* length if known */
64 int line
; /* Current line */
65 int col
; /* Current column */
67 * NOTE: consumed is only tested for equality in the parser code,
68 * so even if there is an overflow this should not give troubles
69 * for parsing very large instances.
71 unsigned long consumed
; /* How many xmlChars already consumed */
72 xmlParserInputDeallocate free
; /* function to deallocate the base */
73 const xmlChar
*encoding
; /* the encoding string for entity */
74 const xmlChar
*version
; /* the version string for entity */
75 int standalone
; /* Was that entity marked standalone */
76 int id
; /* an unique identifier for the entity */
82 * The parser can be asked to collect Node informations, i.e. at what
83 * place in the file they were detected.
84 * NOTE: This is off by default and not very well tested.
86 typedef struct _xmlParserNodeInfo xmlParserNodeInfo
;
87 typedef xmlParserNodeInfo
*xmlParserNodeInfoPtr
;
89 struct _xmlParserNodeInfo
{
90 const struct _xmlNode
* node
;
91 /* Position & line # that text that created the node begins & ends on */
92 unsigned long begin_pos
;
93 unsigned long begin_line
;
94 unsigned long end_pos
;
95 unsigned long end_line
;
98 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq
;
99 typedef xmlParserNodeInfoSeq
*xmlParserNodeInfoSeqPtr
;
100 struct _xmlParserNodeInfoSeq
{
101 unsigned long maximum
;
102 unsigned long length
;
103 xmlParserNodeInfo
* buffer
;
107 * xmlParserInputState:
109 * The parser is now working also as a state based parser.
110 * The recursive one use the state info for entities processing.
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 */
131 } xmlParserInputState
;
136 * Bit in the loadsubset context field to tell to do ID/REFs lookups.
137 * Use it to initialize xmlLoadExtDtdDefaultValue.
139 #define XML_DETECT_IDS 2
142 * XML_COMPLETE_ATTRS:
144 * Bit in the loadsubset context field to tell to do complete the
145 * elements attributes lists with the ones defaulted from the DTDs.
146 * Use it to initialize xmlLoadExtDtdDefaultValue.
148 #define XML_COMPLETE_ATTRS 4
153 * Bit in the loadsubset context field to tell to not do ID/REFs registration.
154 * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.
156 #define XML_SKIP_IDS 8
161 * A parser can operate in various modes
164 XML_PARSE_UNKNOWN
= 0,
167 XML_PARSE_PUSH_DOM
= 3,
168 XML_PARSE_PUSH_SAX
= 4,
175 * The parser context.
176 * NOTE This doesn't completely define the parser state, the (current ?)
177 * design of the parser uses recursive function calls since this allow
178 * and easy mapping from the production rules of the specification
179 * to the actual code. The drawback is that the actual function call
180 * also reflect the parser state. However most of the parsing routines
181 * takes as the only argument the parser context pointer, so migrating
182 * to a state based parser for progressive parsing shouldn't be too hard.
184 struct _xmlParserCtxt
{
185 struct _xmlSAXHandler
*sax
; /* The SAX handler */
186 void *userData
; /* For SAX interface only, used by DOM build */
187 xmlDocPtr myDoc
; /* the document being built */
188 int wellFormed
; /* is the document well formed */
189 int replaceEntities
; /* shall we replace entities ? */
190 const xmlChar
*version
; /* the XML version string */
191 const xmlChar
*encoding
; /* the declared encoding, if any */
192 int standalone
; /* standalone document */
193 int html
; /* an HTML(1)/Docbook(2) document
194 * 3 is HTML after <head>
195 * 10 is HTML after <body>
198 /* Input stream stack */
199 xmlParserInputPtr input
; /* Current input stream */
200 int inputNr
; /* Number of current input streams */
201 int inputMax
; /* Max number of input streams */
202 xmlParserInputPtr
*inputTab
; /* stack of inputs */
204 /* Node analysis stack only used for DOM building */
205 xmlNodePtr node
; /* Current parsed Node */
206 int nodeNr
; /* Depth of the parsing stack */
207 int nodeMax
; /* Max depth of the parsing stack */
208 xmlNodePtr
*nodeTab
; /* array of nodes */
210 int record_info
; /* Whether node info should be kept */
211 xmlParserNodeInfoSeq node_seq
; /* info about each node parsed */
213 int errNo
; /* error code */
215 int hasExternalSubset
; /* reference and external subset */
216 int hasPErefs
; /* the internal subset has PE refs */
217 int external
; /* are we parsing an external entity */
219 int valid
; /* is the document valid */
220 int validate
; /* shall we try to validate ? */
221 xmlValidCtxt vctxt
; /* The validity context */
223 xmlParserInputState instate
; /* current type of input */
224 int token
; /* next char look-ahead */
226 char *directory
; /* the data directory */
228 /* Node name stack */
229 const xmlChar
*name
; /* Current parsed Node */
230 int nameNr
; /* Depth of the parsing stack */
231 int nameMax
; /* Max depth of the parsing stack */
232 const xmlChar
* *nameTab
; /* array of nodes */
234 long nbChars
; /* number of xmlChar processed */
235 long checkIndex
; /* used by progressive parsing lookup */
236 int keepBlanks
; /* ugly but ... */
237 int disableSAX
; /* SAX callbacks are disabled */
238 int inSubset
; /* Parsing is in int 1/ext 2 subset */
239 const xmlChar
* intSubName
; /* name of subset */
240 xmlChar
* extSubURI
; /* URI of external subset */
241 xmlChar
* extSubSystem
; /* SYSTEM ID of external subset */
243 /* xml:space values */
244 int * space
; /* Should the parser preserve spaces */
245 int spaceNr
; /* Depth of the parsing stack */
246 int spaceMax
; /* Max depth of the parsing stack */
247 int * spaceTab
; /* array of space infos */
249 int depth
; /* to prevent entity substitution loops */
250 xmlParserInputPtr entity
; /* used to check entities boundaries */
251 int charset
; /* encoding of the in-memory content
252 actually an xmlCharEncoding */
253 int nodelen
; /* Those two fields are there to */
254 int nodemem
; /* Speed up large node parsing */
255 int pedantic
; /* signal pedantic warnings */
256 void *_private
; /* For user data, libxml won't touch it */
258 int loadsubset
; /* should the external subset be loaded */
259 int linenumbers
; /* set line number in element content */
260 void *catalogs
; /* document's own catalog */
261 int recovery
; /* run in recovery mode */
262 int progressive
; /* is this a progressive parsing */
263 xmlDictPtr dict
; /* dictionnary for the parser */
264 const xmlChar
* *atts
; /* array for the attributes callbacks */
265 int maxatts
; /* the size of the array */
266 int docdict
; /* use strings from dict to build tree */
269 * pre-interned strings
271 const xmlChar
*str_xml
;
272 const xmlChar
*str_xmlns
;
273 const xmlChar
*str_xml_ns
;
276 * Everything below is used only by the new SAX mode
278 int sax2
; /* operating in the new SAX mode */
279 int nsNr
; /* the number of inherited namespaces */
280 int nsMax
; /* the size of the arrays */
281 const xmlChar
* *nsTab
; /* the array of prefix/namespace name */
282 int *attallocs
; /* which attribute were allocated */
283 void * *pushTab
; /* array of data for push */
284 xmlHashTablePtr attsDefault
; /* defaulted attributes if any */
285 xmlHashTablePtr attsSpecial
; /* non-CDATA attributes if any */
286 int nsWellFormed
; /* is the document XML Nanespace okay */
287 int options
; /* Extra options */
290 * Those fields are needed only for treaming parsing so far
292 int dictNames
; /* Use dictionary names for the tree */
293 int freeElemsNr
; /* number of freed element nodes */
294 xmlNodePtr freeElems
; /* List of freed element nodes */
295 int freeAttrsNr
; /* number of freed attributes nodes */
296 xmlAttrPtr freeAttrs
; /* List of freed attributes nodes */
299 * the complete error informations for the last error.
302 xmlParserMode parseMode
; /* the parser mode */
303 unsigned long nbentities
; /* number of entities references */
304 unsigned long sizeentities
; /* size of parsed entities */
312 struct _xmlSAXLocator
{
313 const xmlChar
*(*getPublicId
)(void *ctx
);
314 const xmlChar
*(*getSystemId
)(void *ctx
);
315 int (*getLineNumber
)(void *ctx
);
316 int (*getColumnNumber
)(void *ctx
);
322 * A SAX handler is bunch of callbacks called by the parser when processing
323 * of the input generate data or structure informations.
327 * resolveEntitySAXFunc:
328 * @ctx: the user data (XML parser context)
329 * @publicId: The public ID of the entity
330 * @systemId: The system ID of the entity
333 * The entity loader, to control the loading of external entities,
334 * the application can either:
335 * - override this resolveEntity() callback in the SAX block
336 * - or better use the xmlSetExternalEntityLoader() function to
337 * set up it's own entity resolution routine
339 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
341 typedef xmlParserInputPtr (*resolveEntitySAXFunc
) (void *ctx
,
342 const xmlChar
*publicId
,
343 const xmlChar
*systemId
);
345 * internalSubsetSAXFunc:
346 * @ctx: the user data (XML parser context)
347 * @name: the root element name
348 * @ExternalID: the external ID
349 * @SystemID: the SYSTEM ID (e.g. filename or URL)
351 * Callback on internal subset declaration.
353 typedef void (*internalSubsetSAXFunc
) (void *ctx
,
355 const xmlChar
*ExternalID
,
356 const xmlChar
*SystemID
);
358 * externalSubsetSAXFunc:
359 * @ctx: the user data (XML parser context)
360 * @name: the root element name
361 * @ExternalID: the external ID
362 * @SystemID: the SYSTEM ID (e.g. filename or URL)
364 * Callback on external subset declaration.
366 typedef void (*externalSubsetSAXFunc
) (void *ctx
,
368 const xmlChar
*ExternalID
,
369 const xmlChar
*SystemID
);
372 * @ctx: the user data (XML parser context)
373 * @name: The entity name
375 * Get an entity by name.
377 * Returns the xmlEntityPtr if found.
379 typedef xmlEntityPtr (*getEntitySAXFunc
) (void *ctx
,
380 const xmlChar
*name
);
382 * getParameterEntitySAXFunc:
383 * @ctx: the user data (XML parser context)
384 * @name: The entity name
386 * Get a parameter entity by name.
388 * Returns the xmlEntityPtr if found.
390 typedef xmlEntityPtr (*getParameterEntitySAXFunc
) (void *ctx
,
391 const xmlChar
*name
);
394 * @ctx: the user data (XML parser context)
395 * @name: the entity name
396 * @type: the entity type
397 * @publicId: The public ID of the entity
398 * @systemId: The system ID of the entity
399 * @content: the entity value (without processing).
401 * An entity definition has been parsed.
403 typedef void (*entityDeclSAXFunc
) (void *ctx
,
406 const xmlChar
*publicId
,
407 const xmlChar
*systemId
,
410 * notationDeclSAXFunc:
411 * @ctx: the user data (XML parser context)
412 * @name: The name of the notation
413 * @publicId: The public ID of the entity
414 * @systemId: The system ID of the entity
416 * What to do when a notation declaration has been parsed.
418 typedef void (*notationDeclSAXFunc
)(void *ctx
,
420 const xmlChar
*publicId
,
421 const xmlChar
*systemId
);
423 * attributeDeclSAXFunc:
424 * @ctx: the user data (XML parser context)
425 * @elem: the name of the element
426 * @fullname: the attribute name
427 * @type: the attribute type
428 * @def: the type of default value
429 * @defaultValue: the attribute default value
430 * @tree: the tree of enumerated value set
432 * An attribute definition has been parsed.
434 typedef void (*attributeDeclSAXFunc
)(void *ctx
,
436 const xmlChar
*fullname
,
439 const xmlChar
*defaultValue
,
440 xmlEnumerationPtr tree
);
442 * elementDeclSAXFunc:
443 * @ctx: the user data (XML parser context)
444 * @name: the element name
445 * @type: the element type
446 * @content: the element value tree
448 * An element definition has been parsed.
450 typedef void (*elementDeclSAXFunc
)(void *ctx
,
453 xmlElementContentPtr content
);
455 * unparsedEntityDeclSAXFunc:
456 * @ctx: the user data (XML parser context)
457 * @name: The name of the entity
458 * @publicId: The public ID of the entity
459 * @systemId: The system ID of the entity
460 * @notationName: the name of the notation
462 * What to do when an unparsed entity declaration is parsed.
464 typedef void (*unparsedEntityDeclSAXFunc
)(void *ctx
,
466 const xmlChar
*publicId
,
467 const xmlChar
*systemId
,
468 const xmlChar
*notationName
);
470 * setDocumentLocatorSAXFunc:
471 * @ctx: the user data (XML parser context)
472 * @loc: A SAX Locator
474 * Receive the document locator at startup, actually xmlDefaultSAXLocator.
475 * Everything is available on the context, so this is useless in our case.
477 typedef void (*setDocumentLocatorSAXFunc
) (void *ctx
,
478 xmlSAXLocatorPtr loc
);
480 * startDocumentSAXFunc:
481 * @ctx: the user data (XML parser context)
483 * Called when the document start being processed.
485 typedef void (*startDocumentSAXFunc
) (void *ctx
);
487 * endDocumentSAXFunc:
488 * @ctx: the user data (XML parser context)
490 * Called when the document end has been detected.
492 typedef void (*endDocumentSAXFunc
) (void *ctx
);
494 * startElementSAXFunc:
495 * @ctx: the user data (XML parser context)
496 * @name: The element name, including namespace prefix
497 * @atts: An array of name/value attributes pairs, NULL terminated
499 * Called when an opening tag has been processed.
501 typedef void (*startElementSAXFunc
) (void *ctx
,
503 const xmlChar
**atts
);
506 * @ctx: the user data (XML parser context)
507 * @name: The element name
509 * Called when the end of an element has been detected.
511 typedef void (*endElementSAXFunc
) (void *ctx
,
512 const xmlChar
*name
);
515 * @ctx: the user data (XML parser context)
516 * @name: The attribute name, including namespace prefix
517 * @value: The attribute value
519 * Handle an attribute that has been read by the parser.
520 * The default handling is to convert the attribute into an
521 * DOM subtree and past it in a new xmlAttr element added to
524 typedef void (*attributeSAXFunc
) (void *ctx
,
526 const xmlChar
*value
);
529 * @ctx: the user data (XML parser context)
530 * @name: The entity name
532 * Called when an entity reference is detected.
534 typedef void (*referenceSAXFunc
) (void *ctx
,
535 const xmlChar
*name
);
538 * @ctx: the user data (XML parser context)
539 * @ch: a xmlChar string
540 * @len: the number of xmlChar
542 * Receiving some chars from the parser.
544 typedef void (*charactersSAXFunc
) (void *ctx
,
548 * ignorableWhitespaceSAXFunc:
549 * @ctx: the user data (XML parser context)
550 * @ch: a xmlChar string
551 * @len: the number of xmlChar
553 * Receiving some ignorable whitespaces from the parser.
554 * UNUSED: by default the DOM building will use characters.
556 typedef void (*ignorableWhitespaceSAXFunc
) (void *ctx
,
560 * processingInstructionSAXFunc:
561 * @ctx: the user data (XML parser context)
562 * @target: the target name
563 * @data: the PI data's
565 * A processing instruction has been parsed.
567 typedef void (*processingInstructionSAXFunc
) (void *ctx
,
568 const xmlChar
*target
,
569 const xmlChar
*data
);
572 * @ctx: the user data (XML parser context)
573 * @value: the comment content
575 * A comment has been parsed.
577 typedef void (*commentSAXFunc
) (void *ctx
,
578 const xmlChar
*value
);
581 * @ctx: the user data (XML parser context)
582 * @value: The pcdata content
583 * @len: the block length
585 * Called when a pcdata block has been parsed.
587 typedef void (*cdataBlockSAXFunc
) (
589 const xmlChar
*value
,
593 * @ctx: an XML parser context
594 * @msg: the message to display/transmit
595 * @...: extra parameters for the message display
597 * Display and format a warning messages, callback.
599 typedef void (XMLCDECL
*warningSAXFunc
) (void *ctx
,
600 const char *msg
, ...) LIBXML_ATTR_FORMAT(2,3);
603 * @ctx: an XML parser context
604 * @msg: the message to display/transmit
605 * @...: extra parameters for the message display
607 * Display and format an error messages, callback.
609 typedef void (XMLCDECL
*errorSAXFunc
) (void *ctx
,
610 const char *msg
, ...) LIBXML_ATTR_FORMAT(2,3);
613 * @ctx: an XML parser context
614 * @msg: the message to display/transmit
615 * @...: extra parameters for the message display
617 * Display and format fatal error messages, callback.
618 * Note: so far fatalError() SAX callbacks are not used, error()
619 * get all the callbacks for errors.
621 typedef void (XMLCDECL
*fatalErrorSAXFunc
) (void *ctx
,
622 const char *msg
, ...) LIBXML_ATTR_FORMAT(2,3);
624 * isStandaloneSAXFunc:
625 * @ctx: the user data (XML parser context)
627 * Is this document tagged standalone?
631 typedef int (*isStandaloneSAXFunc
) (void *ctx
);
633 * hasInternalSubsetSAXFunc:
634 * @ctx: the user data (XML parser context)
636 * Does this document has an internal subset.
640 typedef int (*hasInternalSubsetSAXFunc
) (void *ctx
);
643 * hasExternalSubsetSAXFunc:
644 * @ctx: the user data (XML parser context)
646 * Does this document has an external subset?
650 typedef int (*hasExternalSubsetSAXFunc
) (void *ctx
);
652 /************************************************************************
654 * The SAX version 2 API extensions *
656 ************************************************************************/
660 * Special constant found in SAX2 blocks initialized fields
662 #define XML_SAX2_MAGIC 0xDEEDBEAF
665 * startElementNsSAX2Func:
666 * @ctx: the user data (XML parser context)
667 * @localname: the local name of the element
668 * @prefix: the element namespace prefix if available
669 * @URI: the element namespace name if available
670 * @nb_namespaces: number of namespace definitions on that node
671 * @namespaces: pointer to the array of prefix/URI pairs namespace definitions
672 * @nb_attributes: the number of attributes on that node
673 * @nb_defaulted: the number of defaulted attributes. The defaulted
674 * ones are at the end of the array
675 * @attributes: pointer to the array of (localname/prefix/URI/value/end)
678 * SAX2 callback when an element start has been detected by the parser.
679 * It provides the namespace informations for the element, as well as
680 * the new namespace declarations on the element.
683 typedef void (*startElementNsSAX2Func
) (void *ctx
,
684 const xmlChar
*localname
,
685 const xmlChar
*prefix
,
688 const xmlChar
**namespaces
,
691 const xmlChar
**attributes
);
694 * endElementNsSAX2Func:
695 * @ctx: the user data (XML parser context)
696 * @localname: the local name of the element
697 * @prefix: the element namespace prefix if available
698 * @URI: the element namespace name if available
700 * SAX2 callback when an element end has been detected by the parser.
701 * It provides the namespace informations for the element.
704 typedef void (*endElementNsSAX2Func
) (void *ctx
,
705 const xmlChar
*localname
,
706 const xmlChar
*prefix
,
710 struct _xmlSAXHandler
{
711 internalSubsetSAXFunc internalSubset
;
712 isStandaloneSAXFunc isStandalone
;
713 hasInternalSubsetSAXFunc hasInternalSubset
;
714 hasExternalSubsetSAXFunc hasExternalSubset
;
715 resolveEntitySAXFunc resolveEntity
;
716 getEntitySAXFunc getEntity
;
717 entityDeclSAXFunc entityDecl
;
718 notationDeclSAXFunc notationDecl
;
719 attributeDeclSAXFunc attributeDecl
;
720 elementDeclSAXFunc elementDecl
;
721 unparsedEntityDeclSAXFunc unparsedEntityDecl
;
722 setDocumentLocatorSAXFunc setDocumentLocator
;
723 startDocumentSAXFunc startDocument
;
724 endDocumentSAXFunc endDocument
;
725 startElementSAXFunc startElement
;
726 endElementSAXFunc endElement
;
727 referenceSAXFunc reference
;
728 charactersSAXFunc characters
;
729 ignorableWhitespaceSAXFunc ignorableWhitespace
;
730 processingInstructionSAXFunc processingInstruction
;
731 commentSAXFunc comment
;
732 warningSAXFunc warning
;
734 fatalErrorSAXFunc fatalError
; /* unused error() get all the errors */
735 getParameterEntitySAXFunc getParameterEntity
;
736 cdataBlockSAXFunc cdataBlock
;
737 externalSubsetSAXFunc externalSubset
;
738 unsigned int initialized
;
739 /* The following fields are extensions available only on version 2 */
741 startElementNsSAX2Func startElementNs
;
742 endElementNsSAX2Func endElementNs
;
743 xmlStructuredErrorFunc serror
;
749 typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1
;
750 typedef xmlSAXHandlerV1
*xmlSAXHandlerV1Ptr
;
751 struct _xmlSAXHandlerV1
{
752 internalSubsetSAXFunc internalSubset
;
753 isStandaloneSAXFunc isStandalone
;
754 hasInternalSubsetSAXFunc hasInternalSubset
;
755 hasExternalSubsetSAXFunc hasExternalSubset
;
756 resolveEntitySAXFunc resolveEntity
;
757 getEntitySAXFunc getEntity
;
758 entityDeclSAXFunc entityDecl
;
759 notationDeclSAXFunc notationDecl
;
760 attributeDeclSAXFunc attributeDecl
;
761 elementDeclSAXFunc elementDecl
;
762 unparsedEntityDeclSAXFunc unparsedEntityDecl
;
763 setDocumentLocatorSAXFunc setDocumentLocator
;
764 startDocumentSAXFunc startDocument
;
765 endDocumentSAXFunc endDocument
;
766 startElementSAXFunc startElement
;
767 endElementSAXFunc endElement
;
768 referenceSAXFunc reference
;
769 charactersSAXFunc characters
;
770 ignorableWhitespaceSAXFunc ignorableWhitespace
;
771 processingInstructionSAXFunc processingInstruction
;
772 commentSAXFunc comment
;
773 warningSAXFunc warning
;
775 fatalErrorSAXFunc fatalError
; /* unused error() get all the errors */
776 getParameterEntitySAXFunc getParameterEntity
;
777 cdataBlockSAXFunc cdataBlock
;
778 externalSubsetSAXFunc externalSubset
;
779 unsigned int initialized
;
784 * xmlExternalEntityLoader:
785 * @URL: The System ID of the resource requested
786 * @ID: The Public ID of the resource requested
787 * @context: the XML parser context
789 * External entity loaders types.
791 * Returns the entity input parser.
793 typedef xmlParserInputPtr (*xmlExternalEntityLoader
) (const char *URL
,
795 xmlParserCtxtPtr context
);
801 #include <libxml/encoding.h>
802 #include <libxml/xmlIO.h>
803 #include <libxml/globals.h>
813 XMLPUBFUN
void XMLCALL
814 xmlInitParser (void);
815 XMLPUBFUN
void XMLCALL
816 xmlCleanupParser (void);
821 XMLPUBFUN
int XMLCALL
822 xmlParserInputRead (xmlParserInputPtr in
,
824 XMLPUBFUN
int XMLCALL
825 xmlParserInputGrow (xmlParserInputPtr in
,
829 * Basic parsing Interfaces
831 #ifdef LIBXML_SAX1_ENABLED
832 XMLPUBFUN xmlDocPtr XMLCALL
833 xmlParseDoc (const xmlChar
*cur
);
834 XMLPUBFUN xmlDocPtr XMLCALL
835 xmlParseFile (const char *filename
);
836 XMLPUBFUN xmlDocPtr XMLCALL
837 xmlParseMemory (const char *buffer
,
839 #endif /* LIBXML_SAX1_ENABLED */
840 XMLPUBFUN
int XMLCALL
841 xmlSubstituteEntitiesDefault(int val
);
842 XMLPUBFUN
int XMLCALL
843 xmlKeepBlanksDefault (int val
);
844 XMLPUBFUN
void XMLCALL
845 xmlStopParser (xmlParserCtxtPtr ctxt
);
846 XMLPUBFUN
int XMLCALL
847 xmlPedanticParserDefault(int val
);
848 XMLPUBFUN
int XMLCALL
849 xmlLineNumbersDefault (int val
);
851 #ifdef LIBXML_SAX1_ENABLED
855 XMLPUBFUN xmlDocPtr XMLCALL
856 xmlRecoverDoc (const xmlChar
*cur
);
857 XMLPUBFUN xmlDocPtr XMLCALL
858 xmlRecoverMemory (const char *buffer
,
860 XMLPUBFUN xmlDocPtr XMLCALL
861 xmlRecoverFile (const char *filename
);
862 #endif /* LIBXML_SAX1_ENABLED */
865 * Less common routines and SAX interfaces
867 XMLPUBFUN
int XMLCALL
868 xmlParseDocument (xmlParserCtxtPtr ctxt
);
869 XMLPUBFUN
int XMLCALL
870 xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt
);
871 #ifdef LIBXML_SAX1_ENABLED
872 XMLPUBFUN
int XMLCALL
873 xmlSAXUserParseFile (xmlSAXHandlerPtr sax
,
875 const char *filename
);
876 XMLPUBFUN
int XMLCALL
877 xmlSAXUserParseMemory (xmlSAXHandlerPtr sax
,
881 XMLPUBFUN xmlDocPtr XMLCALL
882 xmlSAXParseDoc (xmlSAXHandlerPtr sax
,
885 XMLPUBFUN xmlDocPtr XMLCALL
886 xmlSAXParseMemory (xmlSAXHandlerPtr sax
,
890 XMLPUBFUN xmlDocPtr XMLCALL
891 xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax
,
896 XMLPUBFUN xmlDocPtr XMLCALL
897 xmlSAXParseFile (xmlSAXHandlerPtr sax
,
898 const char *filename
,
900 XMLPUBFUN xmlDocPtr XMLCALL
901 xmlSAXParseFileWithData (xmlSAXHandlerPtr sax
,
902 const char *filename
,
905 XMLPUBFUN xmlDocPtr XMLCALL
906 xmlSAXParseEntity (xmlSAXHandlerPtr sax
,
907 const char *filename
);
908 XMLPUBFUN xmlDocPtr XMLCALL
909 xmlParseEntity (const char *filename
);
910 #endif /* LIBXML_SAX1_ENABLED */
912 #ifdef LIBXML_VALID_ENABLED
913 XMLPUBFUN xmlDtdPtr XMLCALL
914 xmlSAXParseDTD (xmlSAXHandlerPtr sax
,
915 const xmlChar
*ExternalID
,
916 const xmlChar
*SystemID
);
917 XMLPUBFUN xmlDtdPtr XMLCALL
918 xmlParseDTD (const xmlChar
*ExternalID
,
919 const xmlChar
*SystemID
);
920 XMLPUBFUN xmlDtdPtr XMLCALL
921 xmlIOParseDTD (xmlSAXHandlerPtr sax
,
922 xmlParserInputBufferPtr input
,
923 xmlCharEncoding enc
);
924 #endif /* LIBXML_VALID_ENABLE */
925 #ifdef LIBXML_SAX1_ENABLED
926 XMLPUBFUN
int XMLCALL
927 xmlParseBalancedChunkMemory(xmlDocPtr doc
,
928 xmlSAXHandlerPtr sax
,
931 const xmlChar
*string
,
933 #endif /* LIBXML_SAX1_ENABLED */
934 XMLPUBFUN xmlParserErrors XMLCALL
935 xmlParseInNodeContext (xmlNodePtr node
,
940 #ifdef LIBXML_SAX1_ENABLED
941 XMLPUBFUN
int XMLCALL
942 xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc
,
943 xmlSAXHandlerPtr sax
,
946 const xmlChar
*string
,
949 XMLPUBFUN
int XMLCALL
950 xmlParseExternalEntity (xmlDocPtr doc
,
951 xmlSAXHandlerPtr sax
,
957 #endif /* LIBXML_SAX1_ENABLED */
958 XMLPUBFUN
int XMLCALL
959 xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx
,
965 * Parser contexts handling.
967 XMLPUBFUN xmlParserCtxtPtr XMLCALL
968 xmlNewParserCtxt (void);
969 XMLPUBFUN
int XMLCALL
970 xmlInitParserCtxt (xmlParserCtxtPtr ctxt
);
971 XMLPUBFUN
void XMLCALL
972 xmlClearParserCtxt (xmlParserCtxtPtr ctxt
);
973 XMLPUBFUN
void XMLCALL
974 xmlFreeParserCtxt (xmlParserCtxtPtr ctxt
);
975 #ifdef LIBXML_SAX1_ENABLED
976 XMLPUBFUN
void XMLCALL
977 xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt
,
978 const xmlChar
* buffer
,
979 const char *filename
);
980 #endif /* LIBXML_SAX1_ENABLED */
981 XMLPUBFUN xmlParserCtxtPtr XMLCALL
982 xmlCreateDocParserCtxt (const xmlChar
*cur
);
984 #ifdef LIBXML_LEGACY_ENABLED
986 * Reading/setting optional parsing features.
988 XMLPUBFUN
int XMLCALL
989 xmlGetFeaturesList (int *len
,
990 const char **result
);
991 XMLPUBFUN
int XMLCALL
992 xmlGetFeature (xmlParserCtxtPtr ctxt
,
995 XMLPUBFUN
int XMLCALL
996 xmlSetFeature (xmlParserCtxtPtr ctxt
,
999 #endif /* LIBXML_LEGACY_ENABLED */
1001 #ifdef LIBXML_PUSH_ENABLED
1003 * Interfaces for the Push mode.
1005 XMLPUBFUN xmlParserCtxtPtr XMLCALL
1006 xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax
,
1010 const char *filename
);
1011 XMLPUBFUN
int XMLCALL
1012 xmlParseChunk (xmlParserCtxtPtr ctxt
,
1016 #endif /* LIBXML_PUSH_ENABLED */
1022 XMLPUBFUN xmlParserCtxtPtr XMLCALL
1023 xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax
,
1025 xmlInputReadCallback ioread
,
1026 xmlInputCloseCallback ioclose
,
1028 xmlCharEncoding enc
);
1030 XMLPUBFUN xmlParserInputPtr XMLCALL
1031 xmlNewIOInputStream (xmlParserCtxtPtr ctxt
,
1032 xmlParserInputBufferPtr input
,
1033 xmlCharEncoding enc
);
1038 XMLPUBFUN
const xmlParserNodeInfo
* XMLCALL
1039 xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt
,
1040 const xmlNodePtr node
);
1041 XMLPUBFUN
void XMLCALL
1042 xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq
);
1043 XMLPUBFUN
void XMLCALL
1044 xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq
);
1045 XMLPUBFUN
unsigned long XMLCALL
1046 xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq
,
1047 const xmlNodePtr node
);
1048 XMLPUBFUN
void XMLCALL
1049 xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt
,
1050 const xmlParserNodeInfoPtr info
);
1053 * External entities handling actually implemented in xmlIO.
1056 XMLPUBFUN
void XMLCALL
1057 xmlSetExternalEntityLoader(xmlExternalEntityLoader f
);
1058 XMLPUBFUN xmlExternalEntityLoader XMLCALL
1059 xmlGetExternalEntityLoader(void);
1060 XMLPUBFUN xmlParserInputPtr XMLCALL
1061 xmlLoadExternalEntity (const char *URL
,
1063 xmlParserCtxtPtr ctxt
);
1066 * Index lookup, actually implemented in the encoding module
1068 XMLPUBFUN
long XMLCALL
1069 xmlByteConsumed (xmlParserCtxtPtr ctxt
);
1072 * New set of simpler/more flexible APIs
1077 * This is the set of XML parser options that can be passed down
1078 * to the xmlReadDoc() and similar calls.
1081 XML_PARSE_RECOVER
= 1<<0, /* recover on errors */
1082 XML_PARSE_NOENT
= 1<<1, /* substitute entities */
1083 XML_PARSE_DTDLOAD
= 1<<2, /* load the external subset */
1084 XML_PARSE_DTDATTR
= 1<<3, /* default DTD attributes */
1085 XML_PARSE_DTDVALID
= 1<<4, /* validate with the DTD */
1086 XML_PARSE_NOERROR
= 1<<5, /* suppress error reports */
1087 XML_PARSE_NOWARNING
= 1<<6, /* suppress warning reports */
1088 XML_PARSE_PEDANTIC
= 1<<7, /* pedantic error reporting */
1089 XML_PARSE_NOBLANKS
= 1<<8, /* remove blank nodes */
1090 XML_PARSE_SAX1
= 1<<9, /* use the SAX1 interface internally */
1091 XML_PARSE_XINCLUDE
= 1<<10,/* Implement XInclude substitition */
1092 XML_PARSE_NONET
= 1<<11,/* Forbid network access */
1093 XML_PARSE_NODICT
= 1<<12,/* Do not reuse the context dictionnary */
1094 XML_PARSE_NSCLEAN
= 1<<13,/* remove redundant namespaces declarations */
1095 XML_PARSE_NOCDATA
= 1<<14,/* merge CDATA as text nodes */
1096 XML_PARSE_NOXINCNODE
= 1<<15,/* do not generate XINCLUDE START/END nodes */
1097 XML_PARSE_COMPACT
= 1<<16,/* compact small text nodes; no modification of
1098 the tree allowed afterwards (will possibly
1099 crash if you try to modify the tree) */
1100 XML_PARSE_OLD10
= 1<<17,/* parse using XML-1.0 before update 5 */
1101 XML_PARSE_NOBASEFIX
= 1<<18,/* do not fixup XINCLUDE xml:base uris */
1102 XML_PARSE_HUGE
= 1<<19, /* relax any hardcoded limit from the parser */
1103 XML_PARSE_OLDSAX
= 1<<20 /* parse using SAX2 interface from before 2.7.0 */
1106 XMLPUBFUN
void XMLCALL
1107 xmlCtxtReset (xmlParserCtxtPtr ctxt
);
1108 XMLPUBFUN
int XMLCALL
1109 xmlCtxtResetPush (xmlParserCtxtPtr ctxt
,
1112 const char *filename
,
1113 const char *encoding
);
1114 XMLPUBFUN
int XMLCALL
1115 xmlCtxtUseOptions (xmlParserCtxtPtr ctxt
,
1117 XMLPUBFUN xmlDocPtr XMLCALL
1118 xmlReadDoc (const xmlChar
*cur
,
1120 const char *encoding
,
1122 XMLPUBFUN xmlDocPtr XMLCALL
1123 xmlReadFile (const char *URL
,
1124 const char *encoding
,
1126 XMLPUBFUN xmlDocPtr XMLCALL
1127 xmlReadMemory (const char *buffer
,
1130 const char *encoding
,
1132 XMLPUBFUN xmlDocPtr XMLCALL
1135 const char *encoding
,
1137 XMLPUBFUN xmlDocPtr XMLCALL
1138 xmlReadIO (xmlInputReadCallback ioread
,
1139 xmlInputCloseCallback ioclose
,
1142 const char *encoding
,
1144 XMLPUBFUN xmlDocPtr XMLCALL
1145 xmlCtxtReadDoc (xmlParserCtxtPtr ctxt
,
1148 const char *encoding
,
1150 XMLPUBFUN xmlDocPtr XMLCALL
1151 xmlCtxtReadFile (xmlParserCtxtPtr ctxt
,
1152 const char *filename
,
1153 const char *encoding
,
1155 XMLPUBFUN xmlDocPtr XMLCALL
1156 xmlCtxtReadMemory (xmlParserCtxtPtr ctxt
,
1160 const char *encoding
,
1162 XMLPUBFUN xmlDocPtr XMLCALL
1163 xmlCtxtReadFd (xmlParserCtxtPtr ctxt
,
1166 const char *encoding
,
1168 XMLPUBFUN xmlDocPtr XMLCALL
1169 xmlCtxtReadIO (xmlParserCtxtPtr ctxt
,
1170 xmlInputReadCallback ioread
,
1171 xmlInputCloseCallback ioclose
,
1174 const char *encoding
,
1178 * Library wide options
1183 * Used to examine the existance of features that can be enabled
1184 * or disabled at compile-time.
1185 * They used to be called XML_FEATURE_xxx but this clashed with Expat
1188 XML_WITH_THREAD
= 1,
1190 XML_WITH_OUTPUT
= 3,
1192 XML_WITH_READER
= 5,
1193 XML_WITH_PATTERN
= 6,
1194 XML_WITH_WRITER
= 7,
1198 XML_WITH_VALID
= 11,
1200 XML_WITH_LEGACY
= 13,
1202 XML_WITH_CATALOG
= 15,
1203 XML_WITH_XPATH
= 16,
1205 XML_WITH_XINCLUDE
= 18,
1206 XML_WITH_ICONV
= 19,
1207 XML_WITH_ISO8859X
= 20,
1208 XML_WITH_UNICODE
= 21,
1209 XML_WITH_REGEXP
= 22,
1210 XML_WITH_AUTOMATA
= 23,
1212 XML_WITH_SCHEMAS
= 25,
1213 XML_WITH_SCHEMATRON
= 26,
1214 XML_WITH_MODULES
= 27,
1215 XML_WITH_DEBUG
= 28,
1216 XML_WITH_DEBUG_MEM
= 29,
1217 XML_WITH_DEBUG_RUN
= 30,
1219 XML_WITH_NONE
= 99999 /* just to be sure of allocation size */
1222 XMLPUBFUN
int XMLCALL
1223 xmlHasFeature (xmlFeature feature
);
1228 #endif /* __XML_PARSER_H__ */