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 /****************** specific to ethereal ********************************/
13 * Uncomment the following line to restore XML_DO_VALIDITY_CHECKING
14 * behavior which is causing issues on WIN32 platforms. See:
15 * http://www.ethereal.com/lists/ethereal-dev/200410/msg00194.html
17 /* #define ETHEREAL_XML_DO_VALIDITY_CHECKING */
18 /****************** From xml headers ************************************/
21 * use those to be sure nothing nasty will happen if
22 * your library and includes mismatch
24 #ifndef LIBXML2_COMPILING_MSCCDEF
25 extern void xmlCheckVersion(int version);
26 #endif /* LIBXML2_COMPILING_MSCCDEF */
27 #define LIBXML_DOTTED_VERSION "2.3.8"
28 #define LIBXML_VERSION 20308
29 #define LIBXML_VERSION_STRING "20308"
30 #define LIBXML_TEST_VERSION xmlCheckVersion(20308);
33 * Whether the trio support need to be configured in
42 * Whether the FTP support is configured in
45 #define LIBXML_FTP_ENABLED
47 #define LIBXML_FTP_DISABLED
51 * Whether the HTTP support is configured in
54 #define LIBXML_HTTP_ENABLED
56 #define LIBXML_HTTP_DISABLED
60 * Whether the HTML support is configured in
63 #define LIBXML_HTML_ENABLED
65 #define LIBXML_HTML_DISABLED
69 * Whether the SGML Docbook support is configured in
72 #define LIBXML_DOCB_ENABLED
74 #define LIBXML_DOCB_DISABLED
78 * Whether XPath is configured in
81 #define LIBXML_XPATH_ENABLED
83 #define LIBXML_XPATH_DISABLED
87 * Whether XPointer is configured in
90 #define LIBXML_XPTR_ENABLED
92 #define LIBXML_XPTR_DISABLED
96 * Whether XInclude is configured in
99 #define LIBXML_XINCLUDE_ENABLED
101 #define LIBXML_XINCLUDE_DISABLED
105 * Whether iconv support is available
108 #define LIBXML_ICONV_ENABLED
111 #define LIBXML_ICONV_DISABLED
115 * Whether Debugging module is configured in
118 #define LIBXML_DEBUG_ENABLED
120 #define LIBXML_DEBUG_DISABLED
124 * Whether the memory debugging is configured in
127 #define DEBUG_MEMORY_LOCATION
130 #ifndef LIBXML_DLL_IMPORT
131 #if defined(_WIN32) && !defined(STATIC)
132 #define LIBXML_DLL_IMPORT __declspec(dllimport)
134 #define LIBXML_DLL_IMPORT
139 #ifdef HAVE_ANSIDECL_H
140 #include <ansidecl.h>
142 #ifndef ATTRIBUTE_UNUSED
143 #define ATTRIBUTE_UNUSED
146 #define ATTRIBUTE_UNUSED
150 #define XML_XML_NAMESPACE \
151 (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
154 * The different element types carried by an XML tree
156 * NOTE: This is synchronized with DOM Level1 values
157 * See http://www.w3.org/TR/REC-DOM-Level-1/
159 * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
160 * be deprecated to use an XML_DTD_NODE.
164 XML_ATTRIBUTE_NODE= 2,
166 XML_CDATA_SECTION_NODE= 4,
167 XML_ENTITY_REF_NODE= 5,
171 XML_DOCUMENT_NODE= 9,
172 XML_DOCUMENT_TYPE_NODE= 10,
173 XML_DOCUMENT_FRAG_NODE= 11,
174 XML_NOTATION_NODE= 12,
175 XML_HTML_DOCUMENT_NODE= 13,
177 XML_ELEMENT_DECL= 15,
178 XML_ATTRIBUTE_DECL= 16,
180 XML_NAMESPACE_DECL= 18,
181 XML_XINCLUDE_START= 19,
183 #ifdef LIBXML_DOCB_ENABLED
184 ,XML_DOCB_DOCUMENT_NODE= 21
189 * Size of an internal character representation.
191 * We use 8bit chars internal representation for memory efficiency,
192 * Note that with 8 bits wide xmlChars one can still use UTF-8 to handle
193 * correctly non ISO-Latin input.
196 typedef unsigned char xmlChar;
204 #define BAD_CAST (xmlChar *)
207 * a DTD Notation definition
210 typedef struct _xmlNotation xmlNotation;
211 typedef xmlNotation *xmlNotationPtr;
212 struct _xmlNotation {
213 const xmlChar *name; /* Notation name */
214 const xmlChar *PublicID; /* Public identifier, if any */
215 const xmlChar *SystemID; /* System identifier, if any */
219 * a DTD Attribute definition
223 XML_ATTRIBUTE_CDATA = 1,
225 XML_ATTRIBUTE_IDREF ,
226 XML_ATTRIBUTE_IDREFS,
227 XML_ATTRIBUTE_ENTITY,
228 XML_ATTRIBUTE_ENTITIES,
229 XML_ATTRIBUTE_NMTOKEN,
230 XML_ATTRIBUTE_NMTOKENS,
231 XML_ATTRIBUTE_ENUMERATION,
232 XML_ATTRIBUTE_NOTATION
236 XML_ATTRIBUTE_NONE = 1,
237 XML_ATTRIBUTE_REQUIRED,
238 XML_ATTRIBUTE_IMPLIED,
240 } xmlAttributeDefault;
242 typedef struct _xmlEnumeration xmlEnumeration;
243 typedef xmlEnumeration *xmlEnumerationPtr;
244 struct _xmlEnumeration {
245 struct _xmlEnumeration *next; /* next one */
246 const xmlChar *name; /* Enumeration name */
249 typedef struct _xmlAttribute xmlAttribute;
250 typedef xmlAttribute *xmlAttributePtr;
251 struct _xmlAttribute {
252 #ifndef XML_WITHOUT_CORBA
253 void *_private; /* for Corba, must be first ! */
255 xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
256 const xmlChar *name; /* Attribute name */
257 struct _xmlNode *children; /* NULL */
258 struct _xmlNode *last; /* NULL */
259 struct _xmlDtd *parent; /* -> DTD */
260 struct _xmlNode *next; /* next sibling link */
261 struct _xmlNode *prev; /* previous sibling link */
262 struct _xmlDoc *doc; /* the containing document */
264 struct _xmlAttribute *nexth; /* next in hash table */
265 xmlAttributeType atype; /* The attribute type */
266 xmlAttributeDefault def; /* the default */
267 const xmlChar *defaultValue; /* or the default value */
268 xmlEnumerationPtr tree; /* or the enumeration tree if any */
269 const xmlChar *prefix; /* the namespace prefix if any */
270 const xmlChar *elem; /* Element holding the attribute */
274 * a DTD Element definition.
277 XML_ELEMENT_CONTENT_PCDATA = 1,
278 XML_ELEMENT_CONTENT_ELEMENT,
279 XML_ELEMENT_CONTENT_SEQ,
280 XML_ELEMENT_CONTENT_OR
281 } xmlElementContentType;
284 XML_ELEMENT_CONTENT_ONCE = 1,
285 XML_ELEMENT_CONTENT_OPT,
286 XML_ELEMENT_CONTENT_MULT,
287 XML_ELEMENT_CONTENT_PLUS
288 } xmlElementContentOccur;
290 typedef struct _xmlElementContent xmlElementContent;
291 typedef xmlElementContent *xmlElementContentPtr;
292 struct _xmlElementContent {
293 xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
294 xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
295 const xmlChar *name; /* Element name */
296 struct _xmlElementContent *c1; /* first child */
297 struct _xmlElementContent *c2; /* second child */
298 struct _xmlElementContent *parent; /* parent */
302 XML_ELEMENT_TYPE_UNDEFINED = 0,
303 XML_ELEMENT_TYPE_EMPTY = 1,
304 XML_ELEMENT_TYPE_ANY,
305 XML_ELEMENT_TYPE_MIXED,
306 XML_ELEMENT_TYPE_ELEMENT
309 typedef struct _xmlElement xmlElement;
310 typedef xmlElement *xmlElementPtr;
312 #ifndef XML_WITHOUT_CORBA
313 void *_private; /* for Corba, must be first ! */
315 xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
316 const xmlChar *name; /* Element name */
317 struct _xmlNode *children; /* NULL */
318 struct _xmlNode *last; /* NULL */
319 struct _xmlDtd *parent; /* -> DTD */
320 struct _xmlNode *next; /* next sibling link */
321 struct _xmlNode *prev; /* previous sibling link */
322 struct _xmlDoc *doc; /* the containing document */
324 xmlElementTypeVal etype; /* The type */
325 xmlElementContentPtr content; /* the allowed element content */
326 xmlAttributePtr attributes; /* List of the declared attributes */
327 const xmlChar *prefix; /* the namespace prefix if any */
332 * Note that prefix == NULL is valid, it defines the default namespace
333 * within the subtree (until overriden).
335 * XML_GLOBAL_NAMESPACE is now deprecated for good
336 * xmlNsType is unified with xmlElementType
339 #define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
340 typedef xmlElementType xmlNsType;
342 typedef struct _xmlNs xmlNs;
343 typedef xmlNs *xmlNsPtr;
345 struct _xmlNs *next; /* next Ns link for this node */
346 xmlNsType type; /* global or local */
347 const xmlChar *href; /* URL for the namespace */
348 const xmlChar *prefix; /* prefix for the namespace */
352 * An XML DtD, as defined by <!DOCTYPE.
354 typedef struct _xmlDtd xmlDtd;
355 typedef xmlDtd *xmlDtdPtr;
357 #ifndef XML_WITHOUT_CORBA
358 void *_private; /* for Corba, must be first ! */
360 xmlElementType type; /* XML_DTD_NODE, must be second ! */
361 const xmlChar *name; /* Name of the DTD */
362 struct _xmlNode *children; /* the value of the property link */
363 struct _xmlNode *last; /* last child link */
364 struct _xmlDoc *parent; /* child->parent link */
365 struct _xmlNode *next; /* next sibling link */
366 struct _xmlNode *prev; /* previous sibling link */
367 struct _xmlDoc *doc; /* the containing document */
369 /* End of common part */
370 void *notations; /* Hash table for notations if any */
371 void *elements; /* Hash table for elements if any */
372 void *attributes; /* Hash table for attributes if any */
373 void *entities; /* Hash table for entities if any */
374 const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
375 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
376 void *pentities; /* Hash table for param entities if any */
380 * A attribute of an XML node.
382 typedef struct _xmlAttr xmlAttr;
383 typedef xmlAttr *xmlAttrPtr;
385 #ifndef XML_WITHOUT_CORBA
386 void *_private; /* for Corba, must be first ! */
388 xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
389 const xmlChar *name; /* the name of the property */
390 struct _xmlNode *children; /* the value of the property */
391 struct _xmlNode *last; /* NULL */
392 struct _xmlNode *parent; /* child->parent link */
393 struct _xmlAttr *next; /* next sibling link */
394 struct _xmlAttr *prev; /* previous sibling link */
395 struct _xmlDoc *doc; /* the containing document */
396 xmlNs *ns; /* pointer to the associated namespace */
397 xmlAttributeType atype; /* the attribute type if validating */
401 * An XML ID instance.
404 typedef struct _xmlID xmlID;
405 typedef xmlID *xmlIDPtr;
407 struct _xmlID *next; /* next ID */
408 const xmlChar *value; /* The ID name */
409 xmlAttrPtr attr; /* The attribut holding it */
413 * An XML IDREF instance.
416 typedef struct _xmlRef xmlRef;
417 typedef xmlRef *xmlRefPtr;
419 struct _xmlRef *next; /* next Ref */
420 const xmlChar *value; /* The Ref name */
421 xmlAttrPtr attr; /* The attribut holding it */
429 XML_BUFFER_ALLOC_DOUBLEIT,
430 XML_BUFFER_ALLOC_EXACT
431 } xmlBufferAllocationScheme;
433 typedef struct _xmlBuffer xmlBuffer;
434 typedef xmlBuffer *xmlBufferPtr;
436 xmlChar *content; /* The buffer content UTF8 */
437 unsigned int use; /* The buffer size used */
438 unsigned int size; /* The buffer size */
439 xmlBufferAllocationScheme alloc; /* The realloc method */
443 * A node in an XML tree.
445 typedef struct _xmlNode xmlNode;
446 typedef xmlNode *xmlNodePtr;
448 #ifndef XML_WITHOUT_CORBA
449 void *_private; /* for Corba, must be first ! */
451 xmlElementType type; /* type number, must be second ! */
452 const xmlChar *name; /* the name of the node, or the entity */
453 struct _xmlNode *children; /* parent->childs link */
454 struct _xmlNode *last; /* last child link */
455 struct _xmlNode *parent; /* child->parent link */
456 struct _xmlNode *next; /* next sibling link */
457 struct _xmlNode *prev; /* previous sibling link */
458 struct _xmlDoc *doc; /* the containing document */
459 xmlNs *ns; /* pointer to the associated namespace */
460 #ifndef XML_USE_BUFFER_CONTENT
461 xmlChar *content; /* the content */
463 xmlBufferPtr content; /* the content in a buffer */
466 /* End of common part */
467 struct _xmlAttr *properties;/* properties list */
468 xmlNs *nsDef; /* namespace definitions on this node */
474 typedef struct _xmlDoc xmlDoc;
475 typedef xmlDoc *xmlDocPtr;
477 #ifndef XML_WITHOUT_CORBA
478 void *_private; /* for Corba, must be first ! */
480 xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
481 char *name; /* name/filename/URI of the document */
482 struct _xmlNode *children; /* the document tree */
483 struct _xmlNode *last; /* last child link */
484 struct _xmlNode *parent; /* child->parent link */
485 struct _xmlNode *next; /* next sibling link */
486 struct _xmlNode *prev; /* previous sibling link */
487 struct _xmlDoc *doc; /* autoreference to itself */
489 /* End of common part */
490 int compression;/* level of zlib compression */
491 int standalone; /* standalone document (no external refs) */
492 struct _xmlDtd *intSubset; /* the document internal subset */
493 struct _xmlDtd *extSubset; /* the document external subset */
494 struct _xmlNs *oldNs; /* Global namespace, the old way */
495 const xmlChar *version; /* the XML version string */
496 const xmlChar *encoding; /* external initial encoding, if any */
497 void *ids; /* Hash table for ID attributes if any */
498 void *refs; /* Hash table for IDREFs attributes if any */
499 const xmlChar *URL; /* The URI for that document */
500 int charset; /* encoding of the in-memory content
501 actually an xmlCharEncoding */
505 * Predefined values for some standard encodings
506 * Libxml don't do beforehand translation on UTF8, ISOLatinX
507 * It also support UTF16 (LE and BE) by default.
509 * Anything else would have to be translated to UTF8 before being
510 * given to the parser itself. The BOM for UTF16 and the encoding
511 * declaration are looked at and a converter is looked for at that
512 * point. If not found the parser stops here as asked by the XML REC
513 * Converter can be registered by the user using xmlRegisterCharEncodingHandler
514 * but the currentl form doesn't allow stateful transcoding (a serious
515 * problem agreed !). If iconv has been found it will be used
516 * automatically and allow stateful transcoding, the simplest is then
517 * to be sure to enable icon and to provide iconv libs for the encoding
521 XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
522 XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
523 XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
524 XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
525 XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
526 XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
527 XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
528 XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
529 XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
530 XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
531 XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
532 XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
533 XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
534 XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
535 XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
536 XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
537 XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
538 XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
539 XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
540 XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
541 XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
542 XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
543 XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
544 XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
548 * xmlCharEncodingInputFunc:
549 * @out: a pointer ot an array of bytes to store the UTF-8 result
550 * @outlen: the lenght of @out
551 * @in: a pointer ot an array of chars in the original encoding
552 * @inlen: the lenght of @in
554 * Take a block of chars in the original encoding and try to convert
555 * it to an UTF-8 block of chars out.
557 * Returns the number of byte written, or -1 by lack of space, or -2
558 * if the transcoding failed.
559 * The value of @inlen after return is the number of octets consumed
560 * as the return value is positive, else unpredictiable.
561 * The value of @outlen after return is the number of ocetes consumed.
563 typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int *outlen,
564 const unsigned char* in, int *inlen);
568 * xmlCharEncodingOutputFunc:
569 * @out: a pointer ot an array of bytes to store the result
570 * @outlen: the lenght of @out
571 * @in: a pointer ot an array of UTF-8 chars
572 * @inlen: the lenght of @in
574 * Take a block of UTF-8 chars in and try to convert it to an other
576 * Note: a first call designed to produce heading info is called with
577 * in = NULL. If stateful this should also initialize the encoder state
579 * Returns the number of byte written, or -1 by lack of space, or -2
580 * if the transcoding failed.
581 * The value of @inlen after return is the number of octets consumed
582 * as the return value is positive, else unpredictiable.
583 * The value of @outlen after return is the number of ocetes consumed.
585 typedef int (* xmlCharEncodingOutputFunc)(unsigned char* out, int *outlen,
586 const unsigned char* in, int *inlen);
590 * Block defining the handlers for non UTF-8 encodings.
591 * If iconv is supported, there is two extra fields
594 typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
595 typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
596 struct _xmlCharEncodingHandler {
598 xmlCharEncodingInputFunc input;
599 xmlCharEncodingOutputFunc output;
600 #ifdef LIBXML_ICONV_ENABLED
603 #endif /* LIBXML_ICONV_ENABLED */
606 typedef int (*xmlInputMatchCallback) (char const *filename);
607 typedef void * (*xmlInputOpenCallback) (char const *filename);
608 typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
609 typedef void (*xmlInputCloseCallback) (void * context);
611 typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
612 typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
613 struct _xmlParserInputBuffer {
615 xmlInputReadCallback readcallback;
616 xmlInputCloseCallback closecallback;
618 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
620 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
621 xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
626 * Those are the functions and datatypes for the library output
630 typedef int (*xmlOutputMatchCallback) (char const *filename);
631 typedef void * (*xmlOutputOpenCallback) (char const *filename);
632 typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
634 typedef void (*xmlOutputCloseCallback) (void * context);
636 typedef struct _xmlOutputBuffer xmlOutputBuffer;
637 typedef xmlOutputBuffer *xmlOutputBufferPtr;
638 struct _xmlOutputBuffer {
640 xmlOutputWriteCallback writecallback;
641 xmlOutputCloseCallback closecallback;
643 xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
645 xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
646 xmlBufferPtr conv; /* if encoder != NULL buffer for output */
647 int written; /* total number of byte written */
650 #define XML_DEFAULT_VERSION "1.0"
653 * an xmlParserInput is an input flow for the XML processor.
654 * Each entity parsed is associated an xmlParserInput (except the
655 * few predefined ones). This is the case both for internal entities
656 * - in which case the flow is already completely in memory - or
657 * external entities - in which case we use the buf structure for
658 * progressive reading and I18N conversions to the internal UTF-8 format.
661 typedef void (* xmlParserInputDeallocate)(xmlChar *);
662 typedef struct _xmlParserInput xmlParserInput;
663 typedef xmlParserInput *xmlParserInputPtr;
664 struct _xmlParserInput {
666 xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
668 const char *filename; /* The file analyzed, if any */
669 const char *directory; /* the directory/base of teh file */
670 const xmlChar *base; /* Base of the array to parse */
671 const xmlChar *cur; /* Current char being parsed */
672 const xmlChar *end; /* end of the arry to parse */
673 int length; /* length if known */
674 int line; /* Current line */
675 int col; /* Current column */
676 int consumed; /* How many xmlChars already consumed */
677 xmlParserInputDeallocate free; /* function to deallocate the base */
678 const xmlChar *encoding; /* the encoding string for entity */
679 const xmlChar *version; /* the version string for entity */
680 int standalone; /* Was that entity marked standalone */
684 * the parser can be asked to collect Node informations, i.e. at what
685 * place in the file they were detected.
686 * NOTE: This is off by default and not very well tested.
688 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
689 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
691 struct _xmlParserNodeInfo {
692 const struct _xmlNode* node;
693 /* Position & line # that text that created the node begins & ends on */
694 unsigned long begin_pos;
695 unsigned long begin_line;
696 unsigned long end_pos;
697 unsigned long end_line;
700 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
701 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
702 struct _xmlParserNodeInfoSeq {
703 unsigned long maximum;
704 unsigned long length;
705 xmlParserNodeInfo* buffer;
709 * Validation state added for non-determinist content model
711 typedef struct _xmlValidState xmlValidState;
712 typedef xmlValidState *xmlValidStatePtr;
715 * an xmlValidCtxt is used for error reporting when validating
718 typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
719 typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
721 typedef struct _xmlValidCtxt xmlValidCtxt;
722 typedef xmlValidCtxt *xmlValidCtxtPtr;
723 struct _xmlValidCtxt {
724 void *userData; /* user specific data block */
725 xmlValidityErrorFunc error; /* the callback in case of errors */
726 xmlValidityWarningFunc warning; /* the callback in case of warning */
728 /* Node analysis stack used when validating within entities */
729 xmlNodePtr node; /* Current parsed Node */
730 int nodeNr; /* Depth of the parsing stack */
731 int nodeMax; /* Max depth of the parsing stack */
732 xmlNodePtr *nodeTab; /* array of nodes */
734 int finishDtd; /* finished validating the Dtd ? */
735 xmlDocPtr doc; /* the document */
736 int valid; /* temporary validity check result */
738 /* state state used for non-determinist content validation */
739 xmlValidState *vstate; /* current state */
740 int vstateNr; /* Depth of the validation stack */
741 int vstateMax; /* Max depth of the validation stack */
742 xmlValidState *vstateTab; /* array of validation states */
745 typedef struct _xmlLink xmlLink;
746 typedef xmlLink *xmlLinkPtr;
748 typedef struct _xmlList xmlList;
749 typedef xmlList *xmlListPtr;
751 typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
752 typedef int (*xmlListDataCompare) (const void *data0, const void *data1);
753 typedef int (*xmlListWalker) (const void *data, const void *user);
756 * ALl notation declarations are stored in a table
757 * there is one table per DTD
760 typedef struct _xmlHashTable xmlNotationTable;
761 typedef xmlNotationTable *xmlNotationTablePtr;
764 * ALl element declarations are stored in a table
765 * there is one table per DTD
768 typedef struct _xmlHashTable xmlElementTable;
769 typedef xmlElementTable *xmlElementTablePtr;
772 * ALl attribute declarations are stored in a table
773 * there is one table per DTD
776 typedef struct _xmlHashTable xmlAttributeTable;
777 typedef xmlAttributeTable *xmlAttributeTablePtr;
780 * ALl IDs attributes are stored in a table
781 * there is one table per document
784 typedef struct _xmlHashTable xmlIDTable;
785 typedef xmlIDTable *xmlIDTablePtr;
788 * ALl Refs attributes are stored in a table
789 * there is one table per document
792 typedef struct _xmlHashTable xmlRefTable;
793 typedef xmlRefTable *xmlRefTablePtr;
796 xmlChar * xmlSplitQName2 (const xmlChar *name,
800 * The parser is now working also as a state based parser
801 * The recursive one use the stagte info for entities processing
804 XML_PARSER_EOF = -1, /* nothing is to be parsed */
805 XML_PARSER_START = 0, /* nothing has been parsed */
806 XML_PARSER_MISC, /* Misc* before int subset */
807 XML_PARSER_PI, /* Whithin a processing instruction */
808 XML_PARSER_DTD, /* within some DTD content */
809 XML_PARSER_PROLOG, /* Misc* after internal subset */
810 XML_PARSER_COMMENT, /* within a comment */
811 XML_PARSER_START_TAG, /* within a start tag */
812 XML_PARSER_CONTENT, /* within the content */
813 XML_PARSER_CDATA_SECTION, /* within a CDATA section */
814 XML_PARSER_END_TAG, /* within a closing tag */
815 XML_PARSER_ENTITY_DECL, /* within an entity declaration */
816 XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
817 XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
818 XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
819 XML_PARSER_EPILOG, /* the Misc* after the last end tag */
820 XML_PARSER_IGNORE /* within an IGNORED section */
821 } xmlParserInputState;
824 * The parser context.
825 * NOTE This doesn't completely defines the parser state, the (current ?)
826 * design of the parser uses recursive function calls since this allow
827 * and easy mapping from the production rules of the specification
828 * to the actual code. The drawback is that the actual function call
829 * also reflect the parser state. However most of the parsing routines
830 * takes as the only argument the parser context pointer, so migrating
831 * to a state based parser for progressive parsing shouldn't be too hard.
833 typedef struct _xmlParserCtxt xmlParserCtxt;
834 typedef xmlParserCtxt *xmlParserCtxtPtr;
835 struct _xmlParserCtxt {
836 struct _xmlSAXHandler *sax; /* The SAX handler */
837 void *userData; /* For SAX interface only, used by DOM build */
838 xmlDocPtr myDoc; /* the document being built */
839 int wellFormed; /* is the document well formed */
840 int replaceEntities; /* shall we replace entities ? */
841 const xmlChar *version; /* the XML version string */
842 const xmlChar *encoding; /* the declared encoding, if any */
843 int standalone; /* standalone document */
844 int html; /* an HTML(1)/Docbook(2) document */
846 /* Input stream stack */
847 xmlParserInputPtr input; /* Current input stream */
848 int inputNr; /* Number of current input streams */
849 int inputMax; /* Max number of input streams */
850 xmlParserInputPtr *inputTab; /* stack of inputs */
852 /* Node analysis stack only used for DOM building */
853 xmlNodePtr node; /* Current parsed Node */
854 int nodeNr; /* Depth of the parsing stack */
855 int nodeMax; /* Max depth of the parsing stack */
856 xmlNodePtr *nodeTab; /* array of nodes */
858 int record_info; /* Whether node info should be kept */
859 xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
861 int errNo; /* error code */
863 int hasExternalSubset; /* reference and external subset */
864 int hasPErefs; /* the internal subset has PE refs */
865 int external; /* are we parsing an external entity */
867 int valid; /* is the document valid */
868 int validate; /* shall we try to validate ? */
869 xmlValidCtxt vctxt; /* The validity context */
871 xmlParserInputState instate; /* current type of input */
872 int token; /* next char look-ahead */
874 char *directory; /* the data directory */
876 /* Node name stack */
877 xmlChar *name; /* Current parsed Node */
878 int nameNr; /* Depth of the parsing stack */
879 int nameMax; /* Max depth of the parsing stack */
880 xmlChar * *nameTab; /* array of nodes */
882 long nbChars; /* number of xmlChar processed */
883 long checkIndex; /* used by progressive parsing lookup */
884 int keepBlanks; /* ugly but ... */
885 int disableSAX; /* SAX callbacks are disabled */
886 int inSubset; /* Parsing is in int 1/ext 2 subset */
887 xmlChar * intSubName; /* name of subset */
888 xmlChar * extSubURI; /* URI of external subset */
889 xmlChar * extSubSystem; /* SYSTEM ID of external subset */
891 /* xml:space values */
892 int * space; /* Should the parser preserve spaces */
893 int spaceNr; /* Depth of the parsing stack */
894 int spaceMax; /* Max depth of the parsing stack */
895 int * spaceTab; /* array of space infos */
897 int depth; /* to prevent entity substitution loops */
898 xmlParserInputPtr entity; /* used to check entities boundaries */
899 int charset; /* encoding of the in-memory content
900 actually an xmlCharEncoding */
901 int nodelen; /* Those two fields are there to */
902 int nodemem; /* Speed up large node parsing */
903 int pedantic; /* signal pedantic warnings */
904 void *_private; /* For user data, libxml won't touch it */
906 int loadsubset; /* should the external subset be loaded */
912 typedef struct _xmlSAXLocator xmlSAXLocator;
913 typedef xmlSAXLocator *xmlSAXLocatorPtr;
914 struct _xmlSAXLocator {
915 const xmlChar *(*getPublicId)(void *ctx);
916 const xmlChar *(*getSystemId)(void *ctx);
917 int (*getLineNumber)(void *ctx);
918 int (*getColumnNumber)(void *ctx);
922 * The different valid entity types
925 XML_INTERNAL_GENERAL_ENTITY = 1,
926 XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
927 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
928 XML_INTERNAL_PARAMETER_ENTITY = 4,
929 XML_EXTERNAL_PARAMETER_ENTITY = 5,
930 XML_INTERNAL_PREDEFINED_ENTITY = 6
934 * An unit of storage for an entity, contains the string, the value
935 * and the linkind data needed for the linking in the hash table.
938 typedef struct _xmlEntity xmlEntity;
939 typedef xmlEntity *xmlEntityPtr;
941 #ifndef XML_WITHOUT_CORBA
942 void *_private; /* for Corba, must be first ! */
944 xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
945 const xmlChar *name; /* Attribute name */
946 struct _xmlNode *children; /* NULL */
947 struct _xmlNode *last; /* NULL */
948 struct _xmlDtd *parent; /* -> DTD */
949 struct _xmlNode *next; /* next sibling link */
950 struct _xmlNode *prev; /* previous sibling link */
951 struct _xmlDoc *doc; /* the containing document */
953 xmlChar *orig; /* content without ref substitution */
954 xmlChar *content; /* content or ndata if unparsed */
955 int length; /* the content length */
956 xmlEntityType etype; /* The entity type */
957 const xmlChar *ExternalID; /* External identifier for PUBLIC */
958 const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
960 struct _xmlEntity *nexte; /* unused */
961 const xmlChar *URI; /* the full URI as computed */
965 * ALl entities are stored in an hash table
966 * there is 2 separate hash tables for global and parmeter entities
969 typedef struct _xmlHashTable xmlEntitiesTable;
970 typedef xmlEntitiesTable *xmlEntitiesTablePtr;
973 * External functions :
977 * a SAX handler is bunch of callbacks called by the parser when processing
978 * of the input generate data or structure informations.
981 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
982 const xmlChar *publicId, const xmlChar *systemId);
983 typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
984 const xmlChar *ExternalID, const xmlChar *SystemID);
985 typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
986 const xmlChar *ExternalID, const xmlChar *SystemID);
987 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
988 const xmlChar *name);
989 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
990 const xmlChar *name);
991 typedef void (*entityDeclSAXFunc) (void *ctx,
992 const xmlChar *name, int type, const xmlChar *publicId,
993 const xmlChar *systemId, xmlChar *content);
994 typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
995 const xmlChar *publicId, const xmlChar *systemId);
996 typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
997 const xmlChar *name, int type, int def,
998 const xmlChar *defaultValue, xmlEnumerationPtr tree);
999 typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
1000 int type, xmlElementContentPtr content);
1001 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
1002 const xmlChar *name, const xmlChar *publicId,
1003 const xmlChar *systemId, const xmlChar *notationName);
1004 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
1005 xmlSAXLocatorPtr loc);
1006 typedef void (*startDocumentSAXFunc) (void *ctx);
1007 typedef void (*endDocumentSAXFunc) (void *ctx);
1008 typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
1009 const xmlChar **atts);
1010 typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
1011 typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
1012 const xmlChar *value);
1013 typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
1014 typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
1016 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
1017 const xmlChar *ch, int len);
1018 typedef void (*processingInstructionSAXFunc) (void *ctx,
1019 const xmlChar *target, const xmlChar *data);
1020 typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
1021 typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
1022 typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
1023 typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
1024 typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
1025 typedef int (*isStandaloneSAXFunc) (void *ctx);
1026 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
1027 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
1029 typedef struct _xmlSAXHandler xmlSAXHandler;
1030 typedef xmlSAXHandler *xmlSAXHandlerPtr;
1031 struct _xmlSAXHandler {
1032 internalSubsetSAXFunc internalSubset;
1033 isStandaloneSAXFunc isStandalone;
1034 hasInternalSubsetSAXFunc hasInternalSubset;
1035 hasExternalSubsetSAXFunc hasExternalSubset;
1036 resolveEntitySAXFunc resolveEntity;
1037 getEntitySAXFunc getEntity;
1038 entityDeclSAXFunc entityDecl;
1039 notationDeclSAXFunc notationDecl;
1040 attributeDeclSAXFunc attributeDecl;
1041 elementDeclSAXFunc elementDecl;
1042 unparsedEntityDeclSAXFunc unparsedEntityDecl;
1043 setDocumentLocatorSAXFunc setDocumentLocator;
1044 startDocumentSAXFunc startDocument;
1045 endDocumentSAXFunc endDocument;
1046 startElementSAXFunc startElement;
1047 endElementSAXFunc endElement;
1048 referenceSAXFunc reference;
1049 charactersSAXFunc characters;
1050 ignorableWhitespaceSAXFunc ignorableWhitespace;
1051 processingInstructionSAXFunc processingInstruction;
1052 commentSAXFunc comment;
1053 warningSAXFunc warning;
1055 fatalErrorSAXFunc fatalError;
1056 getParameterEntitySAXFunc getParameterEntity;
1057 cdataBlockSAXFunc cdataBlock;
1058 externalSubsetSAXFunc externalSubset;
1062 * External entity loaders types
1064 typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
1066 xmlParserCtxtPtr context);
1069 * Compatibility naming layer with libxml1
1071 #ifndef xmlChildrenNode
1072 #define xmlChildrenNode children
1073 #define xmlRootNode children
1077 /*********************Xml routines and function pointers */
1081 #define XML_EXTERN extern
1086 xmlDocPtr (*xmlParseFile)(const char *filename);
1087 int (*xmlStrcmp)(const xmlChar *str1, const xmlChar *str2);
1088 xmlParserCtxtPtr (*xmlCreatePushParserCtxt)(xmlSAXHandlerPtr, void *, const char *,
1090 int (*xmlParseChunk)(xmlParserCtxtPtr, const char *, int, int);
1091 void (*xmlFreeParserCtxt)(xmlParserCtxtPtr);
1092 xmlNodePtr (*xmlDocGetRootElement)(xmlDocPtr);
1093 void (*xmlFreeDoc)(xmlDocPtr);
1094 char *(*xmlNodeListGetString)(xmlDocPtr, xmlNodePtr, int);
1095 char *(*xmlGetProp)(xmlNodePtr, char *);
1096 int (*xmlKeepBlanksDefault)(int);
1097 int (*xmlSubstituteEntitiesDefault)(int);
1098 #ifdef ETHEREAL_XML_DO_VALIDITY_CHECKING
1099 int *xmlDoValidityCheckingDefaultValue;
1103 XML_EXTERN XML_STUB XmlStub;
1104 XML_EXTERN int XmlStubInitialized;
1107 /* We're in windows, use the windows filename */
1108 #define XML_LIBRARY "libxml2.dll"
1110 #define XML_LIBRARY "libxml2.so"
1114 * This needs to be called before the library is used. It
1115 * returns zero on success. Any non-zero return means that
1116 * either dynamic libraries are not supported, or that libxml
1117 * is not installed on the current system. (Or it's not in
1120 int loadLibXML(void);