1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-27 04:55:04 +03:00
libxml2/include/libxml/tree.h

1256 lines
36 KiB
C
Raw Normal View History

2001-02-23 20:55:21 +03:00
/*
* Summary: interfaces for tree manipulation
* Description: this module describes the structures found in an tree resulting
* from an XML or HTML parsing, as well as the API provided for
* various processing on that tree
2001-02-23 20:55:21 +03:00
*
* Copy: See Copyright for the status of this software.
2001-02-23 20:55:21 +03:00
*
* Author: Daniel Veillard
2001-02-23 20:55:21 +03:00
*/
#ifndef __XML_TREE_H__
#define __XML_TREE_H__
#include <stdio.h>
#include <libxml/xmlversion.h>
#include <libxml/xmlstring.h>
2002-11-08 20:18:52 +03:00
2001-02-23 20:55:21 +03:00
#ifdef __cplusplus
extern "C" {
#endif
/*
* Some of the basic types pointer to structures:
*/
/* xmlIO.h */
typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
typedef struct _xmlOutputBuffer xmlOutputBuffer;
typedef xmlOutputBuffer *xmlOutputBufferPtr;
/* parser.h */
typedef struct _xmlParserInput xmlParserInput;
typedef xmlParserInput *xmlParserInputPtr;
typedef struct _xmlParserCtxt xmlParserCtxt;
typedef xmlParserCtxt *xmlParserCtxtPtr;
typedef struct _xmlSAXLocator xmlSAXLocator;
typedef xmlSAXLocator *xmlSAXLocatorPtr;
typedef struct _xmlSAXHandler xmlSAXHandler;
typedef xmlSAXHandler *xmlSAXHandlerPtr;
/* entities.h */
typedef struct _xmlEntity xmlEntity;
typedef xmlEntity *xmlEntityPtr;
/**
* BASE_BUFFER_SIZE:
*
* default buffer size 4000.
*/
#define BASE_BUFFER_SIZE 4096
/**
* LIBXML_NAMESPACE_DICT:
*
* Defines experimental behaviour:
* 1) xmlNs gets an additional field @context (a xmlDoc)
* 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc.
*/
/* #define LIBXML_NAMESPACE_DICT */
/**
* xmlBufferAllocationScheme:
*
* A buffer allocation scheme can be defined to either match exactly the
* need or double it's allocated size each time it is found too small.
*/
typedef enum {
XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */
XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */
XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
Use a hybrid allocation scheme in xmlNodeSetContent On Fri, May 11, 2012 at 9:10 AM, Daniel Veillard <veillard@redhat.com> wrote: >  Hi Conrad, > > that's interesting ! I was initially afraid of a sudden explosion of > memory allocations for building a tree since by default buffers tend to > "waste" memory by using doubling allocations, but that's not the case. >  xmllint --noout doc/libxml2-api.xml > when compiled with memory debug produce > > paphio:~/XML -> cat .memdump >      MEMORY ALLOCATED : 0, MAX was 12756699 > > and without your patch 12755657, i.e. the increase is minimal. Heh, I thought that too. Actually you're looking at the result with XML_ALLOC_EXACT! This is because EXACT adds 10bytes "spare" on each alloc, and that interestingly wastes about the same amount of space as XML_ALLOC_DOUBLEIT on this example (see below). So it turns out that the default realloc() on my system actually handles this case really well — and I guess that all the time in xmlRealloc() was actually in xmlStrlen, not the underlying realloc() after all (sorry for misleading you). If you replace the realloc() with a bad one (like valgrind's), then the performance degrades severely. This patch implements a HYBRID allocator which has the behaviour you describe (it's like EXACT to start with, though without the spare 10 bytes; and switches to DOUBLEIT after 4kb) — that gets the memory back down to 12755657, with no noticeable impact on the performance of the synthetic pathological example under valgrind. In summary: max_memory on ./xmllint --noout doc/libxml2-api.xml, valgrind time on https://gist.github.com/2656940 max_memory valgrind time before | 12755657 | 29:18.2 EXACT | 12756699 | 2:58.6 <-- this is the state after the first patch. DOUBLEIT | 12756727 | 0:02.7 HYBRID | 12755754 | 0:02.7 <-- this is the state with both patches. > > There is also the cost of creating the buffers all the time. > I need to read the code and check but I may be interested in an hybrid > approach where we switch to buffer only when the text node starts to > become too big (4k would remove nearly all usuall types of "document" > usage, i.e. not blocks of data) I tried to avoid too much buffer creation by introducing the xmlBufferDetach function, which allows re-using one buffer to construct many strings. It's maybe a bit of a "hack" in API terms though I thought the gains would be worth it. Conrad ------8<------ To keep memory usage tight in normal conditions it's desirable to only allocate as much space as is needed. Unfortunately this can lead to problems when constructing a long string out of small chunks, because every chunk you add will need to resize the buffer. To fix this XML_ALLOC_HYBRID will switch (when the buffer is 4kb big) from using exact allocations to doubling buffer size every time it is full. This limits the number of buffer resizes to O(log n) (down from O(n)), and thus greatly increases the performance of constructing very large strings in this manner.
2012-05-14 10:18:58 +04:00
XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */
XML_BUFFER_ALLOC_HYBRID /* exact up to a threshold, and doubleit thereafter */
} xmlBufferAllocationScheme;
/**
* xmlBuffer:
*
* A buffer structure.
*/
typedef struct _xmlBuffer xmlBuffer;
typedef xmlBuffer *xmlBufferPtr;
struct _xmlBuffer {
xmlChar *content; /* The buffer content UTF8 */
unsigned int use; /* The buffer size used */
unsigned int size; /* The buffer size */
xmlBufferAllocationScheme alloc; /* The realloc method */
xmlChar *contentIO; /* in IO mode we may have a different base */
};
/**
* XML_XML_NAMESPACE:
*
* This is the namespace for the special xml: prefix predefined in the
* XML Namespace specification.
*/
2001-02-23 20:55:21 +03:00
#define XML_XML_NAMESPACE \
(const xmlChar *) "http://www.w3.org/XML/1998/namespace"
/**
* XML_XML_ID:
*
* This is the name for the special xml:id attribute
*/
#define XML_XML_ID (const xmlChar *) "xml:id"
2001-02-23 20:55:21 +03:00
/*
* The different element types carried by an XML tree.
2001-02-23 20:55:21 +03:00
*
* NOTE: This is synchronized with DOM Level1 values
* See http://www.w3.org/TR/REC-DOM-Level-1/
*
* Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
* be deprecated to use an XML_DTD_NODE.
*/
typedef enum {
XML_ELEMENT_NODE= 1,
XML_ATTRIBUTE_NODE= 2,
XML_TEXT_NODE= 3,
XML_CDATA_SECTION_NODE= 4,
XML_ENTITY_REF_NODE= 5,
XML_ENTITY_NODE= 6,
XML_PI_NODE= 7,
XML_COMMENT_NODE= 8,
XML_DOCUMENT_NODE= 9,
XML_DOCUMENT_TYPE_NODE= 10,
XML_DOCUMENT_FRAG_NODE= 11,
XML_NOTATION_NODE= 12,
XML_HTML_DOCUMENT_NODE= 13,
XML_DTD_NODE= 14,
XML_ELEMENT_DECL= 15,
XML_ATTRIBUTE_DECL= 16,
XML_ENTITY_DECL= 17,
XML_NAMESPACE_DECL= 18,
XML_XINCLUDE_START= 19,
XML_XINCLUDE_END= 20
#ifdef LIBXML_DOCB_ENABLED
,XML_DOCB_DOCUMENT_NODE= 21
2001-02-23 20:55:21 +03:00
#endif
} xmlElementType;
/**
* xmlNotation:
*
* A DTD Notation definition.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlNotation xmlNotation;
typedef xmlNotation *xmlNotationPtr;
struct _xmlNotation {
const xmlChar *name; /* Notation name */
2001-02-23 20:55:21 +03:00
const xmlChar *PublicID; /* Public identifier, if any */
const xmlChar *SystemID; /* System identifier, if any */
};
/**
* xmlAttributeType:
*
* A DTD Attribute type definition.
2001-02-23 20:55:21 +03:00
*/
typedef enum {
XML_ATTRIBUTE_CDATA = 1,
XML_ATTRIBUTE_ID,
XML_ATTRIBUTE_IDREF ,
XML_ATTRIBUTE_IDREFS,
XML_ATTRIBUTE_ENTITY,
XML_ATTRIBUTE_ENTITIES,
XML_ATTRIBUTE_NMTOKEN,
XML_ATTRIBUTE_NMTOKENS,
XML_ATTRIBUTE_ENUMERATION,
XML_ATTRIBUTE_NOTATION
} xmlAttributeType;
/**
* xmlAttributeDefault:
*
* A DTD Attribute default definition.
*/
2001-02-23 20:55:21 +03:00
typedef enum {
XML_ATTRIBUTE_NONE = 1,
XML_ATTRIBUTE_REQUIRED,
XML_ATTRIBUTE_IMPLIED,
XML_ATTRIBUTE_FIXED
} xmlAttributeDefault;
/**
* xmlEnumeration:
*
* List structure used when there is an enumeration in DTDs.
*/
2001-02-23 20:55:21 +03:00
typedef struct _xmlEnumeration xmlEnumeration;
typedef xmlEnumeration *xmlEnumerationPtr;
struct _xmlEnumeration {
struct _xmlEnumeration *next; /* next one */
const xmlChar *name; /* Enumeration name */
};
/**
* xmlAttribute:
*
* An Attribute declaration in a DTD.
*/
2001-02-23 20:55:21 +03:00
typedef struct _xmlAttribute xmlAttribute;
typedef xmlAttribute *xmlAttributePtr;
struct _xmlAttribute {
void *_private; /* application data */
2001-02-23 20:55:21 +03:00
xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */
const xmlChar *name; /* Attribute name */
struct _xmlNode *children; /* NULL */
struct _xmlNode *last; /* NULL */
struct _xmlDtd *parent; /* -> DTD */
struct _xmlNode *next; /* next sibling link */
struct _xmlNode *prev; /* previous sibling link */
struct _xmlDoc *doc; /* the containing document */
struct _xmlAttribute *nexth; /* next in hash table */
xmlAttributeType atype; /* The attribute type */
xmlAttributeDefault def; /* the default */
const xmlChar *defaultValue; /* or the default value */
xmlEnumerationPtr tree; /* or the enumeration tree if any */
const xmlChar *prefix; /* the namespace prefix if any */
const xmlChar *elem; /* Element holding the attribute */
};
/**
* xmlElementContentType:
*
* Possible definitions of element content types.
2001-02-23 20:55:21 +03:00
*/
typedef enum {
XML_ELEMENT_CONTENT_PCDATA = 1,
XML_ELEMENT_CONTENT_ELEMENT,
XML_ELEMENT_CONTENT_SEQ,
XML_ELEMENT_CONTENT_OR
} xmlElementContentType;
/**
* xmlElementContentOccur:
*
* Possible definitions of element content occurrences.
*/
2001-02-23 20:55:21 +03:00
typedef enum {
XML_ELEMENT_CONTENT_ONCE = 1,
XML_ELEMENT_CONTENT_OPT,
XML_ELEMENT_CONTENT_MULT,
XML_ELEMENT_CONTENT_PLUS
} xmlElementContentOccur;
/**
* xmlElementContent:
*
* An XML Element content as stored after parsing an element definition
* in a DTD.
*/
2001-02-23 20:55:21 +03:00
typedef struct _xmlElementContent xmlElementContent;
typedef xmlElementContent *xmlElementContentPtr;
struct _xmlElementContent {
xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */
xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */
const xmlChar *name; /* Element name */
2001-02-23 20:55:21 +03:00
struct _xmlElementContent *c1; /* first child */
struct _xmlElementContent *c2; /* second child */
struct _xmlElementContent *parent; /* parent */
const xmlChar *prefix; /* Namespace prefix */
2001-02-23 20:55:21 +03:00
};
/**
* xmlElementTypeVal:
*
* The different possibilities for an element content type.
*/
2001-02-23 20:55:21 +03:00
typedef enum {
XML_ELEMENT_TYPE_UNDEFINED = 0,
2001-02-23 20:55:21 +03:00
XML_ELEMENT_TYPE_EMPTY = 1,
XML_ELEMENT_TYPE_ANY,
XML_ELEMENT_TYPE_MIXED,
XML_ELEMENT_TYPE_ELEMENT
} xmlElementTypeVal;
#ifdef __cplusplus
}
#endif
#include <libxml/xmlregexp.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* xmlElement:
*
* An XML Element declaration from a DTD.
*/
2001-02-23 20:55:21 +03:00
typedef struct _xmlElement xmlElement;
typedef xmlElement *xmlElementPtr;
struct _xmlElement {
void *_private; /* application data */
2001-02-23 20:55:21 +03:00
xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */
const xmlChar *name; /* Element name */
struct _xmlNode *children; /* NULL */
struct _xmlNode *last; /* NULL */
struct _xmlDtd *parent; /* -> DTD */
struct _xmlNode *next; /* next sibling link */
struct _xmlNode *prev; /* previous sibling link */
struct _xmlDoc *doc; /* the containing document */
xmlElementTypeVal etype; /* The type */
xmlElementContentPtr content; /* the allowed element content */
xmlAttributePtr attributes; /* List of the declared attributes */
const xmlChar *prefix; /* the namespace prefix if any */
#ifdef LIBXML_REGEXP_ENABLED
xmlRegexpPtr contModel; /* the validating regexp */
#else
void *contModel;
#endif
2001-02-23 20:55:21 +03:00
};
/**
* XML_LOCAL_NAMESPACE:
*
* A namespace declaration node.
*/
#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
typedef xmlElementType xmlNsType;
/**
* xmlNs:
*
2001-02-23 20:55:21 +03:00
* An XML namespace.
* Note that prefix == NULL is valid, it defines the default namespace
* within the subtree (until overridden).
2001-02-23 20:55:21 +03:00
*
* xmlNsType is unified with xmlElementType.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlNs xmlNs;
typedef xmlNs *xmlNsPtr;
struct _xmlNs {
struct _xmlNs *next; /* next Ns link for this node */
xmlNsType type; /* global or local */
const xmlChar *href; /* URL for the namespace */
const xmlChar *prefix; /* prefix for the namespace */
void *_private; /* application data */
struct _xmlDoc *context; /* normally an xmlDoc */
2001-02-23 20:55:21 +03:00
};
/**
* xmlDtd:
*
* An XML DTD, as defined by <!DOCTYPE ... There is actually one for
* the internal subset and for the external subset.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlDtd xmlDtd;
typedef xmlDtd *xmlDtdPtr;
struct _xmlDtd {
void *_private; /* application data */
2001-02-23 20:55:21 +03:00
xmlElementType type; /* XML_DTD_NODE, must be second ! */
const xmlChar *name; /* Name of the DTD */
struct _xmlNode *children; /* the value of the property link */
struct _xmlNode *last; /* last child link */
struct _xmlDoc *parent; /* child->parent link */
struct _xmlNode *next; /* next sibling link */
struct _xmlNode *prev; /* previous sibling link */
struct _xmlDoc *doc; /* the containing document */
/* End of common part */
void *notations; /* Hash table for notations if any */
void *elements; /* Hash table for elements if any */
void *attributes; /* Hash table for attributes if any */
void *entities; /* Hash table for entities if any */
const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */
const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
void *pentities; /* Hash table for param entities if any */
};
/**
* xmlAttr:
*
* An attribute on an XML node.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlAttr xmlAttr;
typedef xmlAttr *xmlAttrPtr;
struct _xmlAttr {
void *_private; /* application data */
2001-02-23 20:55:21 +03:00
xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */
const xmlChar *name; /* the name of the property */
struct _xmlNode *children; /* the value of the property */
struct _xmlNode *last; /* NULL */
struct _xmlNode *parent; /* child->parent link */
struct _xmlAttr *next; /* next sibling link */
struct _xmlAttr *prev; /* previous sibling link */
struct _xmlDoc *doc; /* the containing document */
xmlNs *ns; /* pointer to the associated namespace */
xmlAttributeType atype; /* the attribute type if validating */
void *psvi; /* for type/PSVI informations */
2001-02-23 20:55:21 +03:00
};
/**
* xmlID:
*
2001-02-23 20:55:21 +03:00
* An XML ID instance.
*/
typedef struct _xmlID xmlID;
typedef xmlID *xmlIDPtr;
struct _xmlID {
struct _xmlID *next; /* next ID */
const xmlChar *value; /* The ID name */
xmlAttrPtr attr; /* The attribute holding it */
const xmlChar *name; /* The attribute if attr is not available */
int lineno; /* The line number if attr is not available */
struct _xmlDoc *doc; /* The document holding the ID */
2001-02-23 20:55:21 +03:00
};
/**
* xmlRef:
*
2001-02-23 20:55:21 +03:00
* An XML IDREF instance.
*/
typedef struct _xmlRef xmlRef;
typedef xmlRef *xmlRefPtr;
struct _xmlRef {
struct _xmlRef *next; /* next Ref */
const xmlChar *value; /* The Ref name */
xmlAttrPtr attr; /* The attribute holding it */
const xmlChar *name; /* The attribute if attr is not available */
int lineno; /* The line number if attr is not available */
2001-02-23 20:55:21 +03:00
};
/**
* xmlNode:
*
2001-02-23 20:55:21 +03:00
* A node in an XML tree.
*/
typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
struct _xmlNode {
void *_private; /* application data */
2001-02-23 20:55:21 +03:00
xmlElementType type; /* type number, must be second ! */
const xmlChar *name; /* the name of the node, or the entity */
struct _xmlNode *children; /* parent->childs link */
struct _xmlNode *last; /* last child link */
struct _xmlNode *parent; /* child->parent link */
struct _xmlNode *next; /* next sibling link */
struct _xmlNode *prev; /* previous sibling link */
struct _xmlDoc *doc; /* the containing document */
/* End of common part */
2001-02-23 20:55:21 +03:00
xmlNs *ns; /* pointer to the associated namespace */
xmlChar *content; /* the content */
struct _xmlAttr *properties;/* properties list */
xmlNs *nsDef; /* namespace definitions on this node */
void *psvi; /* for type/PSVI informations */
unsigned short line; /* line number */
unsigned short extra; /* extra data for XPath/XSLT */
2001-02-23 20:55:21 +03:00
};
/**
* XML_GET_CONTENT:
*
* Macro to extract the content pointer of a node.
*/
#define XML_GET_CONTENT(n) \
((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content)
/**
* XML_GET_LINE:
*
* Macro to extract the line number of an element node.
*/
#define XML_GET_LINE(n) \
(xmlGetLineNo(n))
/**
* xmlDocProperty
*
* Set of properties of the document as found by the parser
* Some of them are linked to similary named xmlParserOption
*/
typedef enum {
XML_DOC_WELLFORMED = 1<<0, /* document is XML well formed */
XML_DOC_NSVALID = 1<<1, /* document is Namespace valid */
XML_DOC_OLD10 = 1<<2, /* parsed with old XML-1.0 parser */
XML_DOC_DTDVALID = 1<<3, /* DTD validation was successful */
XML_DOC_XINCLUDE = 1<<4, /* XInclude substitution was done */
XML_DOC_USERBUILT = 1<<5, /* Document was built using the API
and not by parsing an instance */
XML_DOC_INTERNAL = 1<<6, /* built for internal processing */
XML_DOC_HTML = 1<<7 /* parsed or built HTML document */
} xmlDocProperties;
/**
* xmlDoc:
*
2001-02-23 20:55:21 +03:00
* An XML document.
*/
typedef struct _xmlDoc xmlDoc;
typedef xmlDoc *xmlDocPtr;
struct _xmlDoc {
void *_private; /* application data */
2001-02-23 20:55:21 +03:00
xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */
char *name; /* name/filename/URI of the document */
struct _xmlNode *children; /* the document tree */
struct _xmlNode *last; /* last child link */
struct _xmlNode *parent; /* child->parent link */
struct _xmlNode *next; /* next sibling link */
struct _xmlNode *prev; /* previous sibling link */
struct _xmlDoc *doc; /* autoreference to itself */
/* End of common part */
int compression;/* level of zlib compression */
int standalone; /* standalone document (no external refs)
1 if standalone="yes"
0 if standalone="no"
-1 if there is no XML declaration
-2 if there is an XML declaration, but no
standalone attribute was specified */
2001-02-23 20:55:21 +03:00
struct _xmlDtd *intSubset; /* the document internal subset */
struct _xmlDtd *extSubset; /* the document external subset */
struct _xmlNs *oldNs; /* Global namespace, the old way */
const xmlChar *version; /* the XML version string */
const xmlChar *encoding; /* external initial encoding, if any */
void *ids; /* Hash table for ID attributes if any */
void *refs; /* Hash table for IDREFs attributes if any */
const xmlChar *URL; /* The URI for that document */
int charset; /* encoding of the in-memory content
actually an xmlCharEncoding */
struct _xmlDict *dict; /* dict used to allocate names or NULL */
void *psvi; /* for type/PSVI informations */
int parseFlags; /* set of xmlParserOption used to parse the
document */
int properties; /* set of xmlDocProperties for this document
set at the end of parsing */
2001-02-23 20:55:21 +03:00
};
typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt;
typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr;
/**
* xmlDOMWrapAcquireNsFunction:
* @ctxt: a DOM wrapper context
* @node: the context node (element or attribute)
* @nsName: the requested namespace name
* @nsPrefix: the requested namespace prefix
*
* A function called to acquire namespaces (xmlNs) from the wrapper.
*
* Returns an xmlNsPtr or NULL in case of an error.
*/
typedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt,
xmlNodePtr node,
const xmlChar *nsName,
const xmlChar *nsPrefix);
/**
* xmlDOMWrapCtxt:
*
* Context for DOM wrapper-operations.
*/
struct _xmlDOMWrapCtxt {
void * _private;
/*
* The type of this context, just in case we need specialized
* contexts in the future.
*/
int type;
/*
* Internal namespace map used for various operations.
*/
void * namespaceMap;
/*
* Use this one to acquire an xmlNsPtr intended for node->ns.
* (Note that this is not intended for elem->nsDef).
*/
xmlDOMWrapAcquireNsFunction getNsForNodeFunc;
};
/**
* xmlChildrenNode:
*
* Macro for compatibility naming layer with libxml1. Maps
* to "children."
2001-02-23 20:55:21 +03:00
*/
#ifndef xmlChildrenNode
#define xmlChildrenNode children
#endif
/**
* xmlRootNode:
*
* Macro for compatibility naming layer with libxml1. Maps
* to "children".
*/
#ifndef xmlRootNode
2001-02-23 20:55:21 +03:00
#define xmlRootNode children
#endif
/*
* Variables.
*/
/*
* Some helper functions
*/
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
2003-08-25 13:05:12 +04:00
XMLPUBFUN int XMLCALL
xmlValidateNCName (const xmlChar *value,
int space);
2005-01-02 12:53:13 +03:00
#endif
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateQName (const xmlChar *value,
int space);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateName (const xmlChar *value,
int space);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateNMToken (const xmlChar *value,
int space);
2005-01-02 12:53:13 +03:00
#endif
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlBuildQName (const xmlChar *ncname,
const xmlChar *prefix,
xmlChar *memory,
int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlSplitQName2 (const xmlChar *name,
xmlChar **prefix);
2003-08-27 12:59:58 +04:00
XMLPUBFUN const xmlChar * XMLCALL
xmlSplitQName3 (const xmlChar *name,
int *len);
2001-02-23 20:55:21 +03:00
/*
* Handling Buffers.
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);
XMLPUBFUN xmlBufferAllocationScheme XMLCALL
xmlGetBufferAllocationScheme(void);
XMLPUBFUN xmlBufferPtr XMLCALL
xmlBufferCreate (void);
XMLPUBFUN xmlBufferPtr XMLCALL
xmlBufferCreateSize (size_t size);
XMLPUBFUN xmlBufferPtr XMLCALL
xmlBufferCreateStatic (void *mem,
size_t size);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlBufferResize (xmlBufferPtr buf,
unsigned int size);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlBufferFree (xmlBufferPtr buf);
XMLPUBFUN int XMLCALL
xmlBufferDump (FILE *file,
2001-02-23 20:55:21 +03:00
xmlBufferPtr buf);
XMLPUBFUN int XMLCALL
2003-08-27 12:59:58 +04:00
xmlBufferAdd (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
const xmlChar *str,
int len);
XMLPUBFUN int XMLCALL
2003-08-27 12:59:58 +04:00
xmlBufferAddHead (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
const xmlChar *str,
int len);
XMLPUBFUN int XMLCALL
2003-08-27 12:59:58 +04:00
xmlBufferCat (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
const xmlChar *str);
XMLPUBFUN int XMLCALL
2003-08-27 12:59:58 +04:00
xmlBufferCCat (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
const char *str);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlBufferShrink (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
unsigned int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlBufferGrow (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
unsigned int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlBufferEmpty (xmlBufferPtr buf);
XMLPUBFUN const xmlChar* XMLCALL
xmlBufferContent (const xmlBufferPtr buf);
Use buffers when constructing string node lists. Hi Veillard and all, Firstly, thanks for libxml: it's awesome! I noticed recently that libxml was taking a surprisingly long time to perform some operations (many minutes instead of milliseconds), and so I did some digging. It turns out that the problem was caused by the realloc()ing done in xmlNodeAddContentLen() which can be called many (many) times when assigning some content into a node. For background, I'm dealing with XML that contains emails, these can have large attachments (~6MB) which are base-64 encoded, line-wrapped at 78 chars, and each line ends with &#13;. This means that xmlNodeAddContentLen() is being called about 200,000 times, and so there are 200,000 reallocs of a 6MB string, which takes a while... (I put a synthetic example of this at https://gist.github.com/2656940) The attached patch works around that problem by using the existing buffer API to merge the strings together before even creating the text node, this keeps the number of realloc()s at a managable level. I'd love feedback on the patch, and am happy to fix problems with it, or explore other solutions if you think that this is barking up the wrong tree :). Thanks, Conrad P.S. Should I create a bug for this too? ------8<------ Before this change xmlStringGetNodeList would perform a realloc() of the entire new content for every XML entity in the assigned text in order to merge together adjacent text nodes. This had the effect of making xmlSetNodeContent O(n^2), which led to unexpectedly bad performance on inputs that contained a large number of XML entities. After this change the memory management is done by the buffer API, avoiding the need to continually re-measure and realloc() the string. For my test data (6MB of 80 character lines, each ending with &#13;) this takes the time to xmlSetNodeContent from about 500 seconds to around 50ms. I have not profiled smaller cases, though I tried to minimize the performance impact of my change by avoiding unnecessary string copying. Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com>
2012-05-11 07:17:25 +04:00
XMLPUBFUN xmlChar* XMLCALL
xmlBufferDetach (const xmlBufferPtr buf);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlBufferSetAllocationScheme(xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlBufferAllocationScheme scheme);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlBufferLength (const xmlBufferPtr buf);
2001-02-23 20:55:21 +03:00
/*
* Creating/freeing new structures.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlDtdPtr XMLCALL
xmlCreateIntSubset (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlDtdPtr XMLCALL
xmlNewDtd (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlDtdPtr XMLCALL
xmlGetIntSubset (xmlDocPtr doc);
XMLPUBFUN void XMLCALL
xmlFreeDtd (xmlDtdPtr cur);
2005-01-02 12:53:13 +03:00
#ifdef LIBXML_LEGACY_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNsPtr XMLCALL
xmlNewGlobalNs (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *href,
const xmlChar *prefix);
2005-01-02 12:53:13 +03:00
#endif /* LIBXML_LEGACY_ENABLED */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNsPtr XMLCALL
xmlNewNs (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
const xmlChar *href,
const xmlChar *prefix);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlFreeNs (xmlNsPtr cur);
XMLPUBFUN void XMLCALL
xmlFreeNsList (xmlNsPtr cur);
XMLPUBFUN xmlDocPtr XMLCALL
xmlNewDoc (const xmlChar *version);
XMLPUBFUN void XMLCALL
xmlFreeDoc (xmlDocPtr cur);
XMLPUBFUN xmlAttrPtr XMLCALL
xmlNewDocProp (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *name,
const xmlChar *value);
2005-01-02 12:53:13 +03:00
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
defined(LIBXML_SCHEMAS_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttrPtr XMLCALL
xmlNewProp (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
const xmlChar *name,
const xmlChar *value);
2005-01-02 12:53:13 +03:00
#endif
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttrPtr XMLCALL
xmlNewNsProp (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *value);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttrPtr XMLCALL
xmlNewNsPropEatName (xmlNodePtr node,
xmlNsPtr ns,
xmlChar *name,
const xmlChar *value);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlFreePropList (xmlAttrPtr cur);
XMLPUBFUN void XMLCALL
xmlFreeProp (xmlAttrPtr cur);
XMLPUBFUN xmlAttrPtr XMLCALL
xmlCopyProp (xmlNodePtr target,
2001-02-23 20:55:21 +03:00
xmlAttrPtr cur);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttrPtr XMLCALL
xmlCopyPropList (xmlNodePtr target,
2001-02-23 20:55:21 +03:00
xmlAttrPtr cur);
#ifdef LIBXML_TREE_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlDtdPtr XMLCALL
xmlCopyDtd (xmlDtdPtr dtd);
2005-01-02 12:53:13 +03:00
#endif /* LIBXML_TREE_ENABLED */
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlDocPtr XMLCALL
xmlCopyDoc (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
int recursive);
2005-01-02 12:53:13 +03:00
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
2001-02-23 20:55:21 +03:00
/*
* Creating new nodes.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocNode (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocNodeEatName (xmlDocPtr doc,
xmlNsPtr ns,
xmlChar *name,
const xmlChar *content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewNode (xmlNsPtr ns,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewNodeEatName (xmlNsPtr ns,
xmlChar *name);
2005-01-02 12:53:13 +03:00
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewChild (xmlNodePtr parent,
2001-02-23 20:55:21 +03:00
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
2005-01-02 12:53:13 +03:00
#endif
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocText (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewText (const xmlChar *content);
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocPI (xmlDocPtr doc,
const xmlChar *name,
const xmlChar *content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewPI (const xmlChar *name,
2001-02-23 20:55:21 +03:00
const xmlChar *content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocTextLen (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *content,
int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewTextLen (const xmlChar *content,
2001-02-23 20:55:21 +03:00
int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocComment (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewComment (const xmlChar *content);
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewCDataBlock (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *content,
int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewCharRef (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewReference (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlCopyNode (const xmlNodePtr node,
2001-02-23 20:55:21 +03:00
int recursive);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlDocCopyNode (const xmlNodePtr node,
xmlDocPtr doc,
int recursive);
XMLPUBFUN xmlNodePtr XMLCALL
xmlDocCopyNodeList (xmlDocPtr doc,
const xmlNodePtr node);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlCopyNodeList (const xmlNodePtr node);
#ifdef LIBXML_TREE_ENABLED
2005-01-02 12:53:13 +03:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewTextChild (xmlNodePtr parent,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocRawNode (xmlDocPtr doc,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocFragment (xmlDocPtr doc);
#endif /* LIBXML_TREE_ENABLED */
2001-02-23 20:55:21 +03:00
/*
* Navigating.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN long XMLCALL
xmlGetLineNo (xmlNodePtr node);
2005-01-02 12:53:13 +03:00
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlGetNodePath (xmlNodePtr node);
2005-01-02 12:53:13 +03:00
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlDocGetRootElement (xmlDocPtr doc);
XMLPUBFUN xmlNodePtr XMLCALL
xmlGetLastChild (xmlNodePtr parent);
XMLPUBFUN int XMLCALL
xmlNodeIsText (xmlNodePtr node);
XMLPUBFUN int XMLCALL
xmlIsBlankNode (xmlNodePtr node);
2001-02-23 20:55:21 +03:00
/*
* Changing the structure.
2001-02-23 20:55:21 +03:00
*/
2005-01-02 12:53:13 +03:00
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlDocSetRootElement (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr root);
2005-01-02 12:53:13 +03:00
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
#ifdef LIBXML_TREE_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeSetName (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
#endif /* LIBXML_TREE_ENABLED */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlAddChild (xmlNodePtr parent,
2001-02-23 20:55:21 +03:00
xmlNodePtr cur);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlAddChildList (xmlNodePtr parent,
2001-02-23 20:55:21 +03:00
xmlNodePtr cur);
2005-01-02 12:53:13 +03:00
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlReplaceNode (xmlNodePtr old,
2001-02-23 20:55:21 +03:00
xmlNodePtr cur);
2005-01-02 12:53:13 +03:00
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
defined(LIBXML_SCHEMAS_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlAddPrevSibling (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
xmlNodePtr elem);
2005-01-02 12:53:13 +03:00
#endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlAddSibling (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
xmlNodePtr elem);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlAddNextSibling (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
xmlNodePtr elem);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlUnlinkNode (xmlNodePtr cur);
XMLPUBFUN xmlNodePtr XMLCALL
xmlTextMerge (xmlNodePtr first,
2001-02-23 20:55:21 +03:00
xmlNodePtr second);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlTextConcat (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
const xmlChar *content,
int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlFreeNodeList (xmlNodePtr cur);
XMLPUBFUN void XMLCALL
xmlFreeNode (xmlNodePtr cur);
XMLPUBFUN void XMLCALL
xmlSetTreeDoc (xmlNodePtr tree,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlSetListDoc (xmlNodePtr list,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
/*
* Namespaces.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNsPtr XMLCALL
xmlSearchNs (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr node,
const xmlChar *nameSpace);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNsPtr XMLCALL
xmlSearchNsByHref (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr node,
const xmlChar *href);
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNsPtr * XMLCALL
xmlGetNsList (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr node);
2005-01-02 12:53:13 +03:00
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlSetNs (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
xmlNsPtr ns);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNsPtr XMLCALL
xmlCopyNamespace (xmlNsPtr cur);
XMLPUBFUN xmlNsPtr XMLCALL
xmlCopyNamespaceList (xmlNsPtr cur);
2001-02-23 20:55:21 +03:00
/*
* Changing the content.
*/
2005-01-02 12:53:13 +03:00
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttrPtr XMLCALL
xmlSetProp (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
const xmlChar *name,
const xmlChar *value);
2005-01-02 12:53:13 +03:00
XMLPUBFUN xmlAttrPtr XMLCALL
xmlSetNsProp (xmlNodePtr node,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *value);
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlGetNoNsProp (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlGetProp (xmlNodePtr node,
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttrPtr XMLCALL
xmlHasProp (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttrPtr XMLCALL
xmlHasNsProp (xmlNodePtr node,
const xmlChar *name,
const xmlChar *nameSpace);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlGetNsProp (xmlNodePtr node,
2001-02-23 20:55:21 +03:00
const xmlChar *name,
const xmlChar *nameSpace);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlStringGetNodeList (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *value);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNodePtr XMLCALL
xmlStringLenGetNodeList (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *value,
int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlNodeListGetString (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr list,
int inLine);
#ifdef LIBXML_TREE_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlNodeListGetRawString (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr list,
int inLine);
#endif /* LIBXML_TREE_ENABLED */
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeSetContent (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
const xmlChar *content);
#ifdef LIBXML_TREE_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeSetContentLen (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
const xmlChar *content,
int len);
#endif /* LIBXML_TREE_ENABLED */
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeAddContent (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
const xmlChar *content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeAddContentLen (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
const xmlChar *content,
int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlNodeGetContent (xmlNodePtr cur);
XMLPUBFUN int XMLCALL
xmlNodeBufGetContent (xmlBufferPtr buffer,
xmlNodePtr cur);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlNodeGetLang (xmlNodePtr cur);
XMLPUBFUN int XMLCALL
xmlNodeGetSpacePreserve (xmlNodePtr cur);
#ifdef LIBXML_TREE_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeSetLang (xmlNodePtr cur,
2001-02-23 20:55:21 +03:00
const xmlChar *lang);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeSetSpacePreserve (xmlNodePtr cur,
int val);
#endif /* LIBXML_TREE_ENABLED */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlNodeGetBase (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr cur);
2005-01-02 12:53:13 +03:00
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeSetBase (xmlNodePtr cur,
const xmlChar *uri);
2005-01-02 12:53:13 +03:00
#endif
2001-02-23 20:55:21 +03:00
/*
* Removing content.
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlRemoveProp (xmlAttrPtr cur);
2005-01-02 12:53:13 +03:00
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlUnsetNsProp (xmlNodePtr node,
xmlNsPtr ns,
const xmlChar *name);
2005-01-02 12:53:13 +03:00
XMLPUBFUN int XMLCALL
xmlUnsetProp (xmlNodePtr node,
const xmlChar *name);
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
2001-02-23 20:55:21 +03:00
/*
* Internal, don't use.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlBufferWriteCHAR (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
const xmlChar *string);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlBufferWriteChar (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
const char *string);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlBufferWriteQuotedString(xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
const xmlChar *string);
2005-01-02 12:53:13 +03:00
#ifdef LIBXML_OUTPUT_ENABLED
XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf,
xmlDocPtr doc,
xmlAttrPtr attr,
const xmlChar *string);
2005-01-02 12:53:13 +03:00
#endif /* LIBXML_OUTPUT_ENABLED */
2005-01-02 12:53:13 +03:00
#ifdef LIBXML_TREE_ENABLED
2001-02-23 20:55:21 +03:00
/*
* Namespace handling.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlReconciliateNs (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr tree);
2005-01-02 12:53:13 +03:00
#endif
2001-02-23 20:55:21 +03:00
#ifdef LIBXML_OUTPUT_ENABLED
2001-02-23 20:55:21 +03:00
/*
* Saving.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDocDumpFormatMemory (xmlDocPtr cur,
xmlChar **mem,
2001-02-23 20:55:21 +03:00
int *size,
int format);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDocDumpMemory (xmlDocPtr cur,
xmlChar **mem,
2001-02-23 20:55:21 +03:00
int *size);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDocDumpMemoryEnc (xmlDocPtr out_doc,
2001-02-23 20:55:21 +03:00
xmlChar **doc_txt_ptr,
int * doc_txt_len,
const char *txt_encoding);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,
2001-02-23 20:55:21 +03:00
xmlChar **doc_txt_ptr,
int * doc_txt_len,
const char *txt_encoding,
int format);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlDocFormatDump (FILE *f,
xmlDocPtr cur,
int format);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlDocDump (FILE *f,
2001-02-23 20:55:21 +03:00
xmlDocPtr cur);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlElemDump (FILE *f,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNodePtr cur);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlSaveFile (const char *filename,
2001-02-23 20:55:21 +03:00
xmlDocPtr cur);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlSaveFormatFile (const char *filename,
xmlDocPtr cur,
int format);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlNodeDump (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNodePtr cur,
int level,
int format);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlSaveFileTo (xmlOutputBufferPtr buf,
xmlDocPtr cur,
const char *encoding);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlSaveFormatFileTo (xmlOutputBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlDocPtr cur,
const char *encoding,
int format);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlNodeDumpOutput (xmlOutputBufferPtr buf,
xmlDocPtr doc,
xmlNodePtr cur,
int level,
int format,
2001-02-23 20:55:21 +03:00
const char *encoding);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlSaveFormatFileEnc (const char *filename,
xmlDocPtr cur,
const char *encoding,
int format);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlSaveFileEnc (const char *filename,
2001-02-23 20:55:21 +03:00
xmlDocPtr cur,
const char *encoding);
#endif /* LIBXML_OUTPUT_ENABLED */
/*
* XHTML
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlIsXHTML (const xmlChar *systemID,
const xmlChar *publicID);
2001-02-23 20:55:21 +03:00
/*
* Compression.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlGetDocCompressMode (xmlDocPtr doc);
XMLPUBFUN void XMLCALL
xmlSetDocCompressMode (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
int mode);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlGetCompressMode (void);
XMLPUBFUN void XMLCALL
xmlSetCompressMode (int mode);
2001-02-23 20:55:21 +03:00
/*
* DOM-wrapper helper functions.
*/
XMLPUBFUN xmlDOMWrapCtxtPtr XMLCALL
xmlDOMWrapNewCtxt (void);
XMLPUBFUN void XMLCALL
xmlDOMWrapFreeCtxt (xmlDOMWrapCtxtPtr ctxt);
XMLPUBFUN int XMLCALL
xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt,
xmlNodePtr elem,
int options);
XMLPUBFUN int XMLCALL
xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt,
xmlDocPtr sourceDoc,
xmlNodePtr node,
xmlDocPtr destDoc,
xmlNodePtr destParent,
int options);
XMLPUBFUN int XMLCALL
xmlDOMWrapRemoveNode (xmlDOMWrapCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr node,
int options);
XMLPUBFUN int XMLCALL
xmlDOMWrapCloneNode (xmlDOMWrapCtxtPtr ctxt,
xmlDocPtr sourceDoc,
xmlNodePtr node,
xmlNodePtr *clonedNode,
xmlDocPtr destDoc,
xmlNodePtr destParent,
int deep,
int options);
#ifdef LIBXML_TREE_ENABLED
/*
* 5 interfaces from DOM ElementTraversal, but different in entities
* traversal.
*/
XMLPUBFUN unsigned long XMLCALL
xmlChildElementCount (xmlNodePtr parent);
XMLPUBFUN xmlNodePtr XMLCALL
xmlNextElementSibling (xmlNodePtr node);
XMLPUBFUN xmlNodePtr XMLCALL
xmlFirstElementChild (xmlNodePtr parent);
XMLPUBFUN xmlNodePtr XMLCALL
xmlLastElementChild (xmlNodePtr parent);
XMLPUBFUN xmlNodePtr XMLCALL
xmlPreviousElementSibling (xmlNodePtr node);
#endif
2001-02-23 20:55:21 +03:00
#ifdef __cplusplus
}
#endif
#ifndef __XML_PARSER_H__
#include <libxml/xmlmemory.h>
#endif
2001-02-23 20:55:21 +03:00
#endif /* __XML_TREE_H__ */