## entities

entities - interface for the XML entities handling

this module provides some of the entity API needed for the parser and applications.

Author(s): Daniel Veillard

## Synopsis

    typedef struct _xmlHashTable xmlEntitiesTable;
    typedef xmlEntitiesTable * xmlEntitiesTablePtr;
    typedef enum xmlEntityType;
    xmlEntityPtr	xmlAddDocEntity		(xmlDocPtr doc,
    					 const xmlChar * name,
    					 int type,
    					 const xmlChar * ExternalID,
    					 const xmlChar * SystemID,
    					 const xmlChar * content);
    xmlEntityPtr	xmlAddDtdEntity		(xmlDocPtr doc,
    					 const xmlChar * name,
    					 int type,
    					 const xmlChar * ExternalID,
    					 const xmlChar * SystemID,
    					 const xmlChar * content);
    int	xmlAddEntity			(xmlDocPtr doc,
    					 int extSubset,
    					 const xmlChar * name,
    					 int type,
    					 const xmlChar * ExternalID,
    					 const xmlChar * SystemID,
    					 const xmlChar * content,
    					 xmlEntityPtr * out);
    xmlEntitiesTablePtr	xmlCopyEntitiesTable	(xmlEntitiesTablePtr table);
    xmlEntitiesTablePtr	xmlCreateEntitiesTable	(void);
    void	xmlDumpEntitiesTable		(xmlBufferPtr buf,
    					 xmlEntitiesTablePtr table);
    void	xmlDumpEntityDecl		(xmlBufferPtr buf,
    					 xmlEntityPtr ent);
    xmlChar *	xmlEncodeEntitiesReentrant	(xmlDocPtr doc,
    						 const xmlChar * input);
    xmlChar *	xmlEncodeSpecialChars	(const xmlDoc * doc,
    					 const xmlChar * input);
    void	xmlFreeEntitiesTable		(xmlEntitiesTablePtr table);
    void	xmlFreeEntity			(xmlEntityPtr entity);
    xmlEntityPtr	xmlGetDocEntity		(const xmlDoc * doc,
    					 const xmlChar * name);
    xmlEntityPtr	xmlGetDtdEntity		(xmlDocPtr doc,
    					 const xmlChar * name);
    xmlEntityPtr	xmlGetParameterEntity	(xmlDocPtr doc,
    					 const xmlChar * name);
    xmlEntityPtr	xmlGetPredefinedEntity	(const xmlChar * name);
    xmlEntityPtr	xmlNewEntity		(xmlDocPtr doc,
    					 const xmlChar * name,
    					 int type,
    					 const xmlChar * ExternalID,
    					 const xmlChar * SystemID,
    					 const xmlChar * content);

## Description

## Details

### Structure xmlEntitiesTable

    struct _xmlHashTable {
    The content of this structure is not made public by the API.
    } xmlEntitiesTable;

### Typedef xmlEntitiesTablePtr

    xmlEntitiesTable * xmlEntitiesTablePtr;

### Enum xmlEntityType

    enum xmlEntityType {
        XML_INTERNAL_GENERAL_ENTITY = 1
        XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2
        XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3
        XML_INTERNAL_PARAMETER_ENTITY = 4
        XML_EXTERNAL_PARAMETER_ENTITY = 5
        XML_INTERNAL_PREDEFINED_ENTITY = 6
    };

### xmlAddDocEntity ()

    xmlEntityPtr	xmlAddDocEntity		(xmlDocPtr doc,
    					 const xmlChar * name,
    					 int type,
    					 const xmlChar * ExternalID,
    					 const xmlChar * SystemID,
    					 const xmlChar * content)

Register a new entity for this document.

`doc`: | the document
`name`: | the entity name
`type`: | the entity type XML_xxx_yyy_ENTITY
`ExternalID`: | the entity external ID if available
`SystemID`: | the entity system ID if available
`content`: | the entity content
`Returns`: | a pointer to the entity or NULL in case of error

### xmlAddDtdEntity ()

    xmlEntityPtr	xmlAddDtdEntity		(xmlDocPtr doc,
    					 const xmlChar * name,
    					 int type,
    					 const xmlChar * ExternalID,
    					 const xmlChar * SystemID,
    					 const xmlChar * content)

Register a new entity for this document DTD external subset.

`doc`: | the document
`name`: | the entity name
`type`: | the entity type XML_xxx_yyy_ENTITY
`ExternalID`: | the entity external ID if available
`SystemID`: | the entity system ID if available
`content`: | the entity content
`Returns`: | a pointer to the entity or NULL in case of error

### xmlAddEntity ()

    int	xmlAddEntity			(xmlDocPtr doc,
    					 int extSubset,
    					 const xmlChar * name,
    					 int type,
    					 const xmlChar * ExternalID,
    					 const xmlChar * SystemID,
    					 const xmlChar * content,
    					 xmlEntityPtr * out)

Register a new entity for this document. Available since 2.13.0.

`doc`: | the document
`extSubset`: | add to the external or internal subset
`name`: | the entity name
`type`: | the entity type XML_xxx_yyy_ENTITY
`ExternalID`: | the entity external ID if available
`SystemID`: | the entity system ID if available
`content`: | the entity content
`out`: | pointer to resulting entity (optional)
`Returns`: | an xmlParserErrors error code.

### xmlCopyEntitiesTable ()

    xmlEntitiesTablePtr	xmlCopyEntitiesTable	(xmlEntitiesTablePtr table)

Build a copy of an entity table.

`table`: | An entity table
`Returns`: | the new xmlEntitiesTablePtr or NULL in case of error.

### xmlCreateEntitiesTable ()

    xmlEntitiesTablePtr	xmlCreateEntitiesTable	(void)

create and initialize an empty entities hash table. This really doesn't make sense and should be deprecated

`Returns`: | the xmlEntitiesTablePtr just created or NULL in case of error.

### xmlDumpEntitiesTable ()

    void	xmlDumpEntitiesTable		(xmlBufferPtr buf,
    					 xmlEntitiesTablePtr table)

This will dump the content of the entity table as an XML DTD definition

`buf`: | An XML buffer.
`table`: | An entity table

### xmlDumpEntityDecl ()

    void	xmlDumpEntityDecl		(xmlBufferPtr buf,
    					 xmlEntityPtr ent)

This will dump the content of the entity table as an XML DTD definition

`buf`: | An XML buffer.
`ent`: | An entity table

### xmlEncodeEntitiesReentrant ()

    xmlChar *	xmlEncodeEntitiesReentrant	(xmlDocPtr doc,
    						 const xmlChar * input)

Do a global encoding of a string, replacing the predefined entities and non ASCII values with their entities and CharRef counterparts. Contrary to xmlEncodeEntities, this routine is reentrant, and result must be deallocated. This escapes '<', '>', '&' and '\r'. If the document has no encoding, non-ASCII codepoints are escaped. There is some special handling for HTML documents.

`doc`: | the document containing the string
`input`: | A string to convert to XML.
`Returns`: | A newly allocated string with the substitution done.

### xmlEncodeSpecialChars ()

    xmlChar *	xmlEncodeSpecialChars	(const xmlDoc * doc,
    					 const xmlChar * input)

Do a global encoding of a string, replacing the predefined entities this routine is reentrant, and result must be deallocated. This escapes '<', '>', '&', '"' and '\r' chars.

`doc`: | unused
`input`: | A string to convert to XML.
`Returns`: | A newly allocated string with the substitution done.

### xmlFreeEntitiesTable ()

    void	xmlFreeEntitiesTable		(xmlEntitiesTablePtr table)

Deallocate the memory used by an entities hash table.

`table`: | An entity table

### xmlFreeEntity ()

    void	xmlFreeEntity			(xmlEntityPtr entity)

Frees the entity.

`entity`: | an entity

### xmlGetDocEntity ()

    xmlEntityPtr	xmlGetDocEntity		(const xmlDoc * doc,
    					 const xmlChar * name)

Do an entity lookup in the document entity hash table and

`doc`: | the document referencing the entity
`name`: | the entity name
`Returns`: | the corresponding entity, otherwise a lookup is done in the predefined entities too. Returns A pointer to the entity structure or NULL if not found.

### xmlGetDtdEntity ()

    xmlEntityPtr	xmlGetDtdEntity		(xmlDocPtr doc,
    					 const xmlChar * name)

Do an entity lookup in the DTD entity hash table and

`doc`: | the document referencing the entity
`name`: | the entity name
`Returns`: | the corresponding entity, if found. Note: the first argument is the document node, not the DTD node. Returns A pointer to the entity structure or NULL if not found.

### xmlGetParameterEntity ()

    xmlEntityPtr	xmlGetParameterEntity	(xmlDocPtr doc,
    					 const xmlChar * name)

Do an entity lookup in the internal and external subsets and

`doc`: | the document referencing the entity
`name`: | the entity name
`Returns`: | the corresponding parameter entity, if found. Returns A pointer to the entity structure or NULL if not found.

### xmlGetPredefinedEntity ()

    xmlEntityPtr	xmlGetPredefinedEntity	(const xmlChar * name)

Check whether this name is an predefined entity.

`name`: | the entity name
`Returns`: | NULL if not, otherwise the entity

### xmlNewEntity ()

    xmlEntityPtr	xmlNewEntity		(xmlDocPtr doc,
    					 const xmlChar * name,
    					 int type,
    					 const xmlChar * ExternalID,
    					 const xmlChar * SystemID,
    					 const xmlChar * content)

Create a new entity, this differs from xmlAddDocEntity() that if the document is NULL or has no internal subset defined, then an unlinked entity structure will be returned, it is then the responsibility of the caller to link it to the document later or free it when not needed anymore.

`doc`: | the document
`name`: | the entity name
`type`: | the entity type XML_xxx_yyy_ENTITY
`ExternalID`: | the entity external ID if available
`SystemID`: | the entity system ID if available
`content`: | the entity content
`Returns`: | a pointer to the entity or NULL in case of error