2 * This is part of tree.h from the libxml2 distribution. It is used
3 * for structure reference when dynamically linking to libxml.
5 * The GPL agreement for this file and for libxml2 can be found at
6 * http://www.xmlsoft.org
11 /****************** From xml headers ************************************/
14 * use those to be sure nothing nasty will happen if
15 * your library and includes mismatch
17 #ifndef LIBXML2_COMPILING_MSCCDEF
18 extern void xmlCheckVersion(int version);
19 #endif /* LIBXML2_COMPILING_MSCCDEF */
20 #define LIBXML_DOTTED_VERSION "2.3.8"
21 #define LIBXML_VERSION 20308
22 #define LIBXML_VERSION_STRING "20308"
23 #define LIBXML_TEST_VERSION xmlCheckVersion(20308);
26 * Whether the trio support need to be configured in
35 * Whether the FTP support is configured in
38 #define LIBXML_FTP_ENABLED
40 #define LIBXML_FTP_DISABLED
44 * Whether the HTTP support is configured in
47 #define LIBXML_HTTP_ENABLED
49 #define LIBXML_HTTP_DISABLED
53 * Whether the HTML support is configured in
56 #define LIBXML_HTML_ENABLED
58 #define LIBXML_HTML_DISABLED
62 * Whether the SGML Docbook support is configured in
65 #define LIBXML_DOCB_ENABLED
67 #define LIBXML_DOCB_DISABLED
71 * Whether XPath is configured in
74 #define LIBXML_XPATH_ENABLED
76 #define LIBXML_XPATH_DISABLED
80 * Whether XPointer is configured in
83 #define LIBXML_XPTR_ENABLED
85 #define LIBXML_XPTR_DISABLED
89 * Whether XInclude is configured in
92 #define LIBXML_XINCLUDE_ENABLED
94 #define LIBXML_XINCLUDE_DISABLED
98 * Whether iconv support is available
101 #define LIBXML_ICONV_ENABLED
104 #define LIBXML_ICONV_DISABLED
108 * Whether Debugging module is configured in
111 #define LIBXML_DEBUG_ENABLED
113 #define LIBXML_DEBUG_DISABLED
117 * Whether the memory debugging is configured in
120 #define DEBUG_MEMORY_LOCATION
123 #ifndef LIBXML_DLL_IMPORT
124 #if defined(WIN32) && !defined(STATIC)
125 #define LIBXML_DLL_IMPORT __declspec(dllimport)
127 #define LIBXML_DLL_IMPORT
132 #ifdef HAVE_ANSIDECL_H
133 #include <ansidecl.h>
135 #ifndef ATTRIBUTE_UNUSED
136 #define ATTRIBUTE_UNUSED
139 #define ATTRIBUTE_UNUSED
143 #define XML_XML_NAMESPACE \
144 (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
147 * The different element types carried by an XML tree
149 * NOTE: This is synchronized with DOM Level1 values
150 * See http://www.w3.org/TR/REC-DOM-Level-1/
152 * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
153 * be deprecated to use an XML_DTD_NODE.
157 XML_ATTRIBUTE_NODE= 2,
159 XML_CDATA_SECTION_NODE= 4,
160 XML_ENTITY_REF_NODE= 5,
164 XML_DOCUMENT_NODE= 9,
165 XML_DOCUMENT_TYPE_NODE= 10,
166 XML_DOCUMENT_FRAG_NODE= 11,
167 XML_NOTATION_NODE= 12,
168 XML_HTML_DOCUMENT_NODE= 13,
170 XML_ELEMENT_DECL= 15,
171 XML_ATTRIBUTE_DECL= 16,
173 XML_NAMESPACE_DECL= 18,
174 XML_XINCLUDE_START= 19,
176 #ifdef LIBXML_DOCB_ENABLED
177 ,XML_DOCB_DOCUMENT_NODE= 21
182 * Size of an internal character representation.
184 * We use 8bit chars internal representation for memory efficiency,
185 * Note that with 8 bits wide xmlChars one can still use UTF-8 to handle
186 * correctly non ISO-Latin input.
189 typedef unsigned char xmlChar;
197 #define BAD_CAST (xmlChar *)
200 * a DTD Notation definition
203 typedef struct _xmlNotation xmlNotation;
204 typedef xmlNotation *xmlNotationPtr;
205 struct _xmlNotation {
206 const xmlChar *name; /* Notation name */
207 const xmlChar *PublicID; /* Public identifier, if any */
208 const xmlChar *SystemID; /* System identifier, if any */
212 * a DTD Attribute definition
216 XML_ATTRIBUTE_CDATA = 1,
218 XML_ATTRIBUTE_IDREF ,
219 XML_ATTRIBUTE_IDREFS,
220 XML_ATTRIBUTE_ENTITY,
221 XML_ATTRIBUTE_ENTITIES,
222 XML_ATTRIBUTE_NMTOKEN,
223 XML_ATTRIBUTE_NMTOKENS,
224 XML_ATTRIBUTE_ENUMERATION,
225 XML_ATTRIBUTE_NOTATION
229 XML_ATTRIBUTE_NONE = 1,
230 XML_ATTRIBUTE_REQUIRED,
231 XML_ATTRIBUTE_IMPLIED,
233 } xmlAttributeDefault;
235 typedef struct _xmlEnumeration xmlEnumeration;
236 typedef xmlEnumeration *xmlEnumerationPtr;
237 struct _xmlEnumeration {
238 struct _xmlEnumeration *next; /* next one */
239 const xmlChar *name; /* Enumeration name */
242 typedef struct _xmlAttribute xmlAttribute;
243 typedef xmlAttribute *xmlAttributePtr;
244 struct _xmlAttribute {
245 #ifndef XML_WITHOUT_CORBA
246 void *_private; /* for Corba, must be first ! */
248 xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
249 const xmlChar *name; /* Attribute name */
250 struct _xmlNode *children; /* NULL */
251 struct _xmlNode *last; /* NULL */
252 struct _xmlDtd *parent; /* -> DTD */
253 struct _xmlNode *next; /* next sibling link */
254 struct _xmlNode *prev; /* previous sibling link */
255 struct _xmlDoc *doc; /* the containing document */
257 struct _xmlAttribute *nexth; /* next in hash table */
258 xmlAttributeType atype; /* The attribute type */
259 xmlAttributeDefault def; /* the default */
260 const xmlChar *defaultValue; /* or the default value */
261 xmlEnumerationPtr tree; /* or the enumeration tree if any */
262 const xmlChar *prefix; /* the namespace prefix if any */
263 const xmlChar *elem; /* Element holding the attribute */
267 * a DTD Element definition.
270 XML_ELEMENT_CONTENT_PCDATA = 1,
271 XML_ELEMENT_CONTENT_ELEMENT,
272 XML_ELEMENT_CONTENT_SEQ,
273 XML_ELEMENT_CONTENT_OR
274 } xmlElementContentType;
277 XML_ELEMENT_CONTENT_ONCE = 1,
278 XML_ELEMENT_CONTENT_OPT,
279 XML_ELEMENT_CONTENT_MULT,
280 XML_ELEMENT_CONTENT_PLUS
281 } xmlElementContentOccur;
283 typedef struct _xmlElementContent xmlElementContent;
284 typedef xmlElementContent *xmlElementContentPtr;
285 struct _xmlElementContent {
286 xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
287 xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
288 const xmlChar *name; /* Element name */
289 struct _xmlElementContent *c1; /* first child */
290 struct _xmlElementContent *c2; /* second child */
291 struct _xmlElementContent *parent; /* parent */
295 XML_ELEMENT_TYPE_UNDEFINED = 0,
296 XML_ELEMENT_TYPE_EMPTY = 1,
297 XML_ELEMENT_TYPE_ANY,
298 XML_ELEMENT_TYPE_MIXED,
299 XML_ELEMENT_TYPE_ELEMENT
302 typedef struct _xmlElement xmlElement;
303 typedef xmlElement *xmlElementPtr;
305 #ifndef XML_WITHOUT_CORBA
306 void *_private; /* for Corba, must be first ! */
308 xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
309 const xmlChar *name; /* Element name */
310 struct _xmlNode *children; /* NULL */
311 struct _xmlNode *last; /* NULL */
312 struct _xmlDtd *parent; /* -> DTD */
313 struct _xmlNode *next; /* next sibling link */
314 struct _xmlNode *prev; /* previous sibling link */
315 struct _xmlDoc *doc; /* the containing document */
317 xmlElementTypeVal etype; /* The type */
318 xmlElementContentPtr content; /* the allowed element content */
319 xmlAttributePtr attributes; /* List of the declared attributes */
320 const xmlChar *prefix; /* the namespace prefix if any */
325 * Note that prefix == NULL is valid, it defines the default namespace
326 * within the subtree (until overriden).
328 * XML_GLOBAL_NAMESPACE is now deprecated for good
329 * xmlNsType is unified with xmlElementType
332 #define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
333 typedef xmlElementType xmlNsType;
335 typedef struct _xmlNs xmlNs;
336 typedef xmlNs *xmlNsPtr;
338 struct _xmlNs *next; /* next Ns link for this node */
339 xmlNsType type; /* global or local */
340 const xmlChar *href; /* URL for the namespace */
341 const xmlChar *prefix; /* prefix for the namespace */
345 * An XML DtD, as defined by <!DOCTYPE.
347 typedef struct _xmlDtd xmlDtd;
348 typedef xmlDtd *xmlDtdPtr;
350 #ifndef XML_WITHOUT_CORBA
351 void *_private; /* for Corba, must be first ! */
353 xmlElementType type; /* XML_DTD_NODE, must be second ! */
354 const xmlChar *name; /* Name of the DTD */
355 struct _xmlNode *children; /* the value of the property link */
356 struct _xmlNode *last; /* last child link */
357 struct _xmlDoc *parent; /* child->parent link */
358 struct _xmlNode *next; /* next sibling link */
359 struct _xmlNode *prev; /* previous sibling link */
360 struct _xmlDoc *doc; /* the containing document */
362 /* End of common part */
363 void *notations; /* Hash table for notations if any */
364 void *elements; /* Hash table for elements if any */
365 void *attributes; /* Hash table for attributes if any */
366 void *entities; /* Hash table for entities if any */
367 const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
368 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
369 void *pentities; /* Hash table for param entities if any */
373 * A attribute of an XML node.
375 typedef struct _xmlAttr xmlAttr;
376 typedef xmlAttr *xmlAttrPtr;
378 #ifndef XML_WITHOUT_CORBA
379 void *_private; /* for Corba, must be first ! */
381 xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
382 const xmlChar *name; /* the name of the property */
383 struct _xmlNode *children; /* the value of the property */
384 struct _xmlNode *last; /* NULL */
385 struct _xmlNode *parent; /* child->parent link */
386 struct _xmlAttr *next; /* next sibling link */
387 struct _xmlAttr *prev; /* previous sibling link */
388 struct _xmlDoc *doc; /* the containing document */
389 xmlNs *ns; /* pointer to the associated namespace */
390 xmlAttributeType atype; /* the attribute type if validating */
394 * An XML ID instance.
397 typedef struct _xmlID xmlID;
398 typedef xmlID *xmlIDPtr;
400 struct _xmlID *next; /* next ID */
401 const xmlChar *value; /* The ID name */
402 xmlAttrPtr attr; /* The attribut holding it */
406 * An XML IDREF instance.
409 typedef struct _xmlRef xmlRef;
410 typedef xmlRef *xmlRefPtr;
412 struct _xmlRef *next; /* next Ref */
413 const xmlChar *value; /* The Ref name */
414 xmlAttrPtr attr; /* The attribut holding it */
422 XML_BUFFER_ALLOC_DOUBLEIT,
423 XML_BUFFER_ALLOC_EXACT
424 } xmlBufferAllocationScheme;
426 typedef struct _xmlBuffer xmlBuffer;
427 typedef xmlBuffer *xmlBufferPtr;
429 xmlChar *content; /* The buffer content UTF8 */
430 unsigned int use; /* The buffer size used */
431 unsigned int size; /* The buffer size */
432 xmlBufferAllocationScheme alloc; /* The realloc method */
436 * A node in an XML tree.
438 typedef struct _xmlNode xmlNode;
439 typedef xmlNode *xmlNodePtr;
441 #ifndef XML_WITHOUT_CORBA
442 void *_private; /* for Corba, must be first ! */
444 xmlElementType type; /* type number, must be second ! */
445 const xmlChar *name; /* the name of the node, or the entity */
446 struct _xmlNode *children; /* parent->childs link */
447 struct _xmlNode *last; /* last child link */
448 struct _xmlNode *parent; /* child->parent link */
449 struct _xmlNode *next; /* next sibling link */
450 struct _xmlNode *prev; /* previous sibling link */
451 struct _xmlDoc *doc; /* the containing document */
452 xmlNs *ns; /* pointer to the associated namespace */
453 #ifndef XML_USE_BUFFER_CONTENT
454 xmlChar *content; /* the content */
456 xmlBufferPtr content; /* the content in a buffer */
459 /* End of common part */
460 struct _xmlAttr *properties;/* properties list */
461 xmlNs *nsDef; /* namespace definitions on this node */
467 typedef struct _xmlDoc xmlDoc;
468 typedef xmlDoc *xmlDocPtr;
470 #ifndef XML_WITHOUT_CORBA
471 void *_private; /* for Corba, must be first ! */
473 xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
474 char *name; /* name/filename/URI of the document */
475 struct _xmlNode *children; /* the document tree */
476 struct _xmlNode *last; /* last child link */
477 struct _xmlNode *parent; /* child->parent link */
478 struct _xmlNode *next; /* next sibling link */
479 struct _xmlNode *prev; /* previous sibling link */
480 struct _xmlDoc *doc; /* autoreference to itself */
482 /* End of common part */
483 int compression;/* level of zlib compression */
484 int standalone; /* standalone document (no external refs) */
485 struct _xmlDtd *intSubset; /* the document internal subset */
486 struct _xmlDtd *extSubset; /* the document external subset */
487 struct _xmlNs *oldNs; /* Global namespace, the old way */
488 const xmlChar *version; /* the XML version string */
489 const xmlChar *encoding; /* external initial encoding, if any */
490 void *ids; /* Hash table for ID attributes if any */
491 void *refs; /* Hash table for IDREFs attributes if any */
492 const xmlChar *URL; /* The URI for that document */
493 int charset; /* encoding of the in-memory content
494 actually an xmlCharEncoding */
498 * Predefined values for some standard encodings
499 * Libxml don't do beforehand translation on UTF8, ISOLatinX
500 * It also support UTF16 (LE and BE) by default.
502 * Anything else would have to be translated to UTF8 before being
503 * given to the parser itself. The BOM for UTF16 and the encoding
504 * declaration are looked at and a converter is looked for at that
505 * point. If not found the parser stops here as asked by the XML REC
506 * Converter can be registered by the user using xmlRegisterCharEncodingHandler
507 * but the currentl form doesn't allow stateful transcoding (a serious
508 * problem agreed !). If iconv has been found it will be used
509 * automatically and allow stateful transcoding, the simplest is then
510 * to be sure to enable icon and to provide iconv libs for the encoding
514 XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
515 XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
516 XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
517 XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
518 XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
519 XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
520 XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
521 XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
522 XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
523 XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
524 XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
525 XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
526 XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
527 XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
528 XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
529 XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
530 XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
531 XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
532 XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
533 XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
534 XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
535 XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
536 XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
537 XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
541 * xmlCharEncodingInputFunc:
542 * @out: a pointer ot an array of bytes to store the UTF-8 result
543 * @outlen: the lenght of @out
544 * @in: a pointer ot an array of chars in the original encoding
545 * @inlen: the lenght of @in
547 * Take a block of chars in the original encoding and try to convert
548 * it to an UTF-8 block of chars out.
550 * Returns the number of byte written, or -1 by lack of space, or -2
551 * if the transcoding failed.
552 * The value of @inlen after return is the number of octets consumed
553 * as the return value is positive, else unpredictiable.
554 * The value of @outlen after return is the number of ocetes consumed.
556 typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int *outlen,
557 const unsigned char* in, int *inlen);
561 * xmlCharEncodingOutputFunc:
562 * @out: a pointer ot an array of bytes to store the result
563 * @outlen: the lenght of @out
564 * @in: a pointer ot an array of UTF-8 chars
565 * @inlen: the lenght of @in
567 * Take a block of UTF-8 chars in and try to convert it to an other
569 * Note: a first call designed to produce heading info is called with
570 * in = NULL. If stateful this should also initialize the encoder state
572 * Returns the number of byte written, or -1 by lack of space, or -2
573 * if the transcoding failed.
574 * The value of @inlen after return is the number of octets consumed
575 * as the return value is positive, else unpredictiable.
576 * The value of @outlen after return is the number of ocetes consumed.
578 typedef int (* xmlCharEncodingOutputFunc)(unsigned char* out, int *outlen,
579 const unsigned char* in, int *inlen);
583 * Block defining the handlers for non UTF-8 encodings.
584 * If iconv is supported, there is two extra fields
587 typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
588 typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
589 struct _xmlCharEncodingHandler {
591 xmlCharEncodingInputFunc input;
592 xmlCharEncodingOutputFunc output;
593 #ifdef LIBXML_ICONV_ENABLED
596 #endif /* LIBXML_ICONV_ENABLED */
599 typedef int (*xmlInputMatchCallback) (char const *filename);
600 typedef void * (*xmlInputOpenCallback) (char const *filename);
601 typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
602 typedef void (*xmlInputCloseCallback) (void * context);
604 typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
605 typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
606 struct _xmlParserInputBuffer {
608 xmlInputReadCallback readcallback;
609 xmlInputCloseCallback closecallback;
611 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
613 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
614 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
619 * Those are the functions and datatypes for the library output
623 typedef int (*xmlOutputMatchCallback) (char const *filename);
624 typedef void * (*xmlOutputOpenCallback) (char const *filename);
625 typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
627 typedef void (*xmlOutputCloseCallback) (void * context);
629 typedef struct _xmlOutputBuffer xmlOutputBuffer;
630 typedef xmlOutputBuffer *xmlOutputBufferPtr;
631 struct _xmlOutputBuffer {
633 xmlOutputWriteCallback writecallback;
634 xmlOutputCloseCallback closecallback;
636 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
638 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
639 xmlBufferPtr conv; /* if encoder != NULL buffer for output */
640 int written; /* total number of byte written */
643 #define XML_DEFAULT_VERSION "1.0"
646 * an xmlParserInput is an input flow for the XML processor.
647 * Each entity parsed is associated an xmlParserInput (except the
648 * few predefined ones). This is the case both for internal entities
649 * - in which case the flow is already completely in memory - or
650 * external entities - in which case we use the buf structure for
651 * progressive reading and I18N conversions to the internal UTF-8 format.
654 typedef void (* xmlParserInputDeallocate)(xmlChar *);
655 typedef struct _xmlParserInput xmlParserInput;
656 typedef xmlParserInput *xmlParserInputPtr;
657 struct _xmlParserInput {
659 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
661 const char *filename; /* The file analyzed, if any */
662 const char *directory; /* the directory/base of teh file */
663 const xmlChar *base; /* Base of the array to parse */
664 const xmlChar *cur; /* Current char being parsed */
665 const xmlChar *end; /* end of the arry to parse */
666 int length; /* length if known */
667 int line; /* Current line */
668 int col; /* Current column */
669 int consumed; /* How many xmlChars already consumed */
670 xmlParserInputDeallocate free; /* function to deallocate the base */
671 const xmlChar *encoding; /* the encoding string for entity */
672 const xmlChar *version; /* the version string for entity */
673 int standalone; /* Was that entity marked standalone */
677 * the parser can be asked to collect Node informations, i.e. at what
678 * place in the file they were detected.
679 * NOTE: This is off by default and not very well tested.
681 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
682 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
684 struct _xmlParserNodeInfo {
685 const struct _xmlNode* node;
686 /* Position & line # that text that created the node begins & ends on */
687 unsigned long begin_pos;
688 unsigned long begin_line;
689 unsigned long end_pos;
690 unsigned long end_line;
693 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
694 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
695 struct _xmlParserNodeInfoSeq {
696 unsigned long maximum;
697 unsigned long length;
698 xmlParserNodeInfo* buffer;
702 * Validation state added for non-determinist content model
704 typedef struct _xmlValidState xmlValidState;
705 typedef xmlValidState *xmlValidStatePtr;
708 * an xmlValidCtxt is used for error reporting when validating
711 typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
712 typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
714 typedef struct _xmlValidCtxt xmlValidCtxt;
715 typedef xmlValidCtxt *xmlValidCtxtPtr;
716 struct _xmlValidCtxt {
717 void *userData; /* user specific data block */
718 xmlValidityErrorFunc error; /* the callback in case of errors */
719 xmlValidityWarningFunc warning; /* the callback in case of warning */
721 /* Node analysis stack used when validating within entities */
722 xmlNodePtr node; /* Current parsed Node */
723 int nodeNr; /* Depth of the parsing stack */
724 int nodeMax; /* Max depth of the parsing stack */
725 xmlNodePtr *nodeTab; /* array of nodes */
727 int finishDtd; /* finished validating the Dtd ? */
728 xmlDocPtr doc; /* the document */
729 int valid; /* temporary validity check result */
731 /* state state used for non-determinist content validation */
732 xmlValidState *vstate; /* current state */
733 int vstateNr; /* Depth of the validation stack */
734 int vstateMax; /* Max depth of the validation stack */
735 xmlValidState *vstateTab; /* array of validation states */
738 typedef struct _xmlLink xmlLink;
739 typedef xmlLink *xmlLinkPtr;
741 typedef struct _xmlList xmlList;
742 typedef xmlList *xmlListPtr;
744 typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
745 typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
746 typedef int (*xmlListWalker) (const void *data, const void *user);
749 * ALl notation declarations are stored in a table
750 * there is one table per DTD
753 typedef struct _xmlHashTable xmlNotationTable;
754 typedef xmlNotationTable *xmlNotationTablePtr;
757 * ALl element declarations are stored in a table
758 * there is one table per DTD
761 typedef struct _xmlHashTable xmlElementTable;
762 typedef xmlElementTable *xmlElementTablePtr;
765 * ALl attribute declarations are stored in a table
766 * there is one table per DTD
769 typedef struct _xmlHashTable xmlAttributeTable;
770 typedef xmlAttributeTable *xmlAttributeTablePtr;
773 * ALl IDs attributes are stored in a table
774 * there is one table per document
777 typedef struct _xmlHashTable xmlIDTable;
778 typedef xmlIDTable *xmlIDTablePtr;
781 * ALl Refs attributes are stored in a table
782 * there is one table per document
785 typedef struct _xmlHashTable xmlRefTable;
786 typedef xmlRefTable *xmlRefTablePtr;
789 xmlChar * xmlSplitQName2 (const xmlChar *name,
793 * The parser is now working also as a state based parser
794 * The recursive one use the stagte info for entities processing
797 XML_PARSER_EOF = -1, /* nothing is to be parsed */
798 XML_PARSER_START = 0, /* nothing has been parsed */
799 XML_PARSER_MISC, /* Misc* before int subset */
800 XML_PARSER_PI, /* Whithin a processing instruction */
801 XML_PARSER_DTD, /* within some DTD content */
802 XML_PARSER_PROLOG, /* Misc* after internal subset */
803 XML_PARSER_COMMENT, /* within a comment */
804 XML_PARSER_START_TAG, /* within a start tag */
805 XML_PARSER_CONTENT, /* within the content */
806 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
807 XML_PARSER_END_TAG, /* within a closing tag */
808 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
809 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
810 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
811 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
812 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
813 XML_PARSER_IGNORE /* within an IGNORED section */
814 } xmlParserInputState;
817 * The parser context.
818 * NOTE This doesn't completely defines the parser state, the (current ?)
819 * design of the parser uses recursive function calls since this allow
820 * and easy mapping from the production rules of the specification
821 * to the actual code. The drawback is that the actual function call
822 * also reflect the parser state. However most of the parsing routines
823 * takes as the only argument the parser context pointer, so migrating
824 * to a state based parser for progressive parsing shouldn't be too hard.
826 typedef struct _xmlParserCtxt xmlParserCtxt;
827 typedef xmlParserCtxt *xmlParserCtxtPtr;
828 struct _xmlParserCtxt {
829 struct _xmlSAXHandler *sax; /* The SAX handler */
830 void *userData; /* For SAX interface only, used by DOM build */
831 xmlDocPtr myDoc; /* the document being built */
832 int wellFormed; /* is the document well formed */
833 int replaceEntities; /* shall we replace entities ? */
834 const xmlChar *version; /* the XML version string */
835 const xmlChar *encoding; /* the declared encoding, if any */
836 int standalone; /* standalone document */
837 int html; /* an HTML(1)/Docbook(2) document */
839 /* Input stream stack */
840 xmlParserInputPtr input; /* Current input stream */
841 int inputNr; /* Number of current input streams */
842 int inputMax; /* Max number of input streams */
843 xmlParserInputPtr *inputTab; /* stack of inputs */
845 /* Node analysis stack only used for DOM building */
846 xmlNodePtr node; /* Current parsed Node */
847 int nodeNr; /* Depth of the parsing stack */
848 int nodeMax; /* Max depth of the parsing stack */
849 xmlNodePtr *nodeTab; /* array of nodes */
851 int record_info; /* Whether node info should be kept */
852 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
854 int errNo; /* error code */
856 int hasExternalSubset; /* reference and external subset */
857 int hasPErefs; /* the internal subset has PE refs */
858 int external; /* are we parsing an external entity */
860 int valid; /* is the document valid */
861 int validate; /* shall we try to validate ? */
862 xmlValidCtxt vctxt; /* The validity context */
864 xmlParserInputState instate; /* current type of input */
865 int token; /* next char look-ahead */
867 char *directory; /* the data directory */
869 /* Node name stack */
870 xmlChar *name; /* Current parsed Node */
871 int nameNr; /* Depth of the parsing stack */
872 int nameMax; /* Max depth of the parsing stack */
873 xmlChar * *nameTab; /* array of nodes */
875 long nbChars; /* number of xmlChar processed */
876 long checkIndex; /* used by progressive parsing lookup */
877 int keepBlanks; /* ugly but ... */
878 int disableSAX; /* SAX callbacks are disabled */
879 int inSubset; /* Parsing is in int 1/ext 2 subset */
880 xmlChar * intSubName; /* name of subset */
881 xmlChar * extSubURI; /* URI of external subset */
882 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
884 /* xml:space values */
885 int * space; /* Should the parser preserve spaces */
886 int spaceNr; /* Depth of the parsing stack */
887 int spaceMax; /* Max depth of the parsing stack */
888 int * spaceTab; /* array of space infos */
890 int depth; /* to prevent entity substitution loops */
891 xmlParserInputPtr entity; /* used to check entities boundaries */
892 int charset; /* encoding of the in-memory content
893 actually an xmlCharEncoding */
894 int nodelen; /* Those two fields are there to */
895 int nodemem; /* Speed up large node parsing */
896 int pedantic; /* signal pedantic warnings */
897 void *_private; /* For user data, libxml won't touch it */
899 int loadsubset; /* should the external subset be loaded */
905 typedef struct _xmlSAXLocator xmlSAXLocator;
906 typedef xmlSAXLocator *xmlSAXLocatorPtr;
907 struct _xmlSAXLocator {
908 const xmlChar *(*getPublicId)(void *ctx);
909 const xmlChar *(*getSystemId)(void *ctx);
910 int (*getLineNumber)(void *ctx);
911 int (*getColumnNumber)(void *ctx);
915 * The different valid entity types
918 XML_INTERNAL_GENERAL_ENTITY = 1,
919 XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
920 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
921 XML_INTERNAL_PARAMETER_ENTITY = 4,
922 XML_EXTERNAL_PARAMETER_ENTITY = 5,
923 XML_INTERNAL_PREDEFINED_ENTITY = 6
927 * An unit of storage for an entity, contains the string, the value
928 * and the linkind data needed for the linking in the hash table.
931 typedef struct _xmlEntity xmlEntity;
932 typedef xmlEntity *xmlEntityPtr;
934 #ifndef XML_WITHOUT_CORBA
935 void *_private; /* for Corba, must be first ! */
937 xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
938 const xmlChar *name; /* Attribute name */
939 struct _xmlNode *children; /* NULL */
940 struct _xmlNode *last; /* NULL */
941 struct _xmlDtd *parent; /* -> DTD */
942 struct _xmlNode *next; /* next sibling link */
943 struct _xmlNode *prev; /* previous sibling link */
944 struct _xmlDoc *doc; /* the containing document */
946 xmlChar *orig; /* content without ref substitution */
947 xmlChar *content; /* content or ndata if unparsed */
948 int length; /* the content length */
949 xmlEntityType etype; /* The entity type */
950 const xmlChar *ExternalID; /* External identifier for PUBLIC */
951 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
953 struct _xmlEntity *nexte; /* unused */
954 const xmlChar *URI; /* the full URI as computed */
958 * ALl entities are stored in an hash table
959 * there is 2 separate hash tables for global and parmeter entities
962 typedef struct _xmlHashTable xmlEntitiesTable;
963 typedef xmlEntitiesTable *xmlEntitiesTablePtr;
966 * External functions :
970 * a SAX handler is bunch of callbacks called by the parser when processing
971 * of the input generate data or structure informations.
974 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
975 const xmlChar *publicId, const xmlChar *systemId);
976 typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
977 const xmlChar *ExternalID, const xmlChar *SystemID);
978 typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
979 const xmlChar *ExternalID, const xmlChar *SystemID);
980 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
981 const xmlChar *name);
982 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
983 const xmlChar *name);
984 typedef void (*entityDeclSAXFunc) (void *ctx,
985 const xmlChar *name, int type, const xmlChar *publicId,
986 const xmlChar *systemId, xmlChar *content);
987 typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
988 const xmlChar *publicId, const xmlChar *systemId);
989 typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
990 const xmlChar *name, int type, int def,
991 const xmlChar *defaultValue, xmlEnumerationPtr tree);
992 typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
993 int type, xmlElementContentPtr content);
994 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
995 const xmlChar *name, const xmlChar *publicId,
996 const xmlChar *systemId, const xmlChar *notationName);
997 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
998 xmlSAXLocatorPtr loc);
999 typedef void (*startDocumentSAXFunc) (void *ctx);
1000 typedef void (*endDocumentSAXFunc) (void *ctx);
1001 typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
1002 const xmlChar **atts);
1003 typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
1004 typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
1005 const xmlChar *value);
1006 typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
1007 typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
1009 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
1010 const xmlChar *ch, int len);
1011 typedef void (*processingInstructionSAXFunc) (void *ctx,
1012 const xmlChar *target, const xmlChar *data);
1013 typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
1014 typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
1015 typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
1016 typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
1017 typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
1018 typedef int (*isStandaloneSAXFunc) (void *ctx);
1019 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
1020 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
1022 typedef struct _xmlSAXHandler xmlSAXHandler;
1023 typedef xmlSAXHandler *xmlSAXHandlerPtr;
1024 struct _xmlSAXHandler {
1025 internalSubsetSAXFunc internalSubset;
1026 isStandaloneSAXFunc isStandalone;
1027 hasInternalSubsetSAXFunc hasInternalSubset;
1028 hasExternalSubsetSAXFunc hasExternalSubset;
1029 resolveEntitySAXFunc resolveEntity;
1030 getEntitySAXFunc getEntity;
1031 entityDeclSAXFunc entityDecl;
1032 notationDeclSAXFunc notationDecl;
1033 attributeDeclSAXFunc attributeDecl;
1034 elementDeclSAXFunc elementDecl;
1035 unparsedEntityDeclSAXFunc unparsedEntityDecl;
1036 setDocumentLocatorSAXFunc setDocumentLocator;
1037 startDocumentSAXFunc startDocument;
1038 endDocumentSAXFunc endDocument;
1039 startElementSAXFunc startElement;
1040 endElementSAXFunc endElement;
1041 referenceSAXFunc reference;
1042 charactersSAXFunc characters;
1043 ignorableWhitespaceSAXFunc ignorableWhitespace;
1044 processingInstructionSAXFunc processingInstruction;
1045 commentSAXFunc comment;
1046 warningSAXFunc warning;
1048 fatalErrorSAXFunc fatalError;
1049 getParameterEntitySAXFunc getParameterEntity;
1050 cdataBlockSAXFunc cdataBlock;
1051 externalSubsetSAXFunc externalSubset;
1055 * External entity loaders types
1057 typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
1059 xmlParserCtxtPtr context);
1062 * Compatibility naming layer with libxml1
1064 #ifndef xmlChildrenNode
1065 #define xmlChildrenNode children
1066 #define xmlRootNode children
1070 /*********************Xml routines and function pointers */
1074 #define XML_EXTERN extern
1079 xmlDocPtr (*xmlParseFile)(const char *filename);
1080 int (*xmlStrcmp)(const xmlChar *str1, const xmlChar *str2);
1081 xmlParserCtxtPtr (*xmlCreatePushParserCtxt)(xmlSAXHandlerPtr, void *, const char *,
1083 int (*xmlParseChunk)(xmlParserCtxtPtr, const char *, int, int);
1084 void (*xmlFreeParserCtxt)(xmlParserCtxtPtr);
1085 xmlNodePtr (*xmlDocGetRootElement)(xmlDocPtr);
1086 void (*xmlFreeDoc)(xmlDocPtr);
1087 char *(*xmlNodeListGetString)(xmlDocPtr, xmlNodePtr, int);
1088 char *(*xmlGetProp)(xmlNodePtr, char *);
1089 int (*xmlKeepBlanksDefault)(int);
1090 int (*xmlSubstituteEntitiesDefault)(int);
1093 int *xmlDoValidityCheckingDefaultValue;
1097 XML_EXTERN XML_STUB XmlStub;
1098 XML_EXTERN int XmlStubInitialized;
1101 /* We're in windows, use the windows filename */
1102 #define XML_LIBRARY "libxml2.dll"
1104 #define XML_LIBRARY "libxml2.so"
1108 * This needs to be called before the library is used. It
1109 * returns zero on success. Any non-zero return means that
1110 * either dynamic libraries are not supported, or that libxml
1111 * is not installed on the current system. (Or it's not in
1114 int loadLibXML(void);