libxml2
Loading...
Searching...
No Matches
entities.h File Reference

XML entities. More...

Data Structures

struct  _xmlEntity
 An entity declaration. More...

Enumerations

enum  xmlEntityType
 The different entity types. More...

Functions

xmlEntityxmlNewEntity (xmlDoc *doc, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *content)
 Create a new entity.
void xmlFreeEntity (xmlEntity *entity)
 Frees the entity.
int xmlAddEntity (xmlDoc *doc, int extSubset, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *content, xmlEntity **out)
 Register a new entity for this document.
xmlEntityxmlAddDocEntity (xmlDoc *doc, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *content)
 Add a new entity to the document's internal subset.
xmlEntityxmlAddDtdEntity (xmlDoc *doc, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *content)
 Add a new entity to the document's external subset.
xmlEntityxmlGetPredefinedEntity (const xmlChar *name)
 Look up a predefined entity.
xmlEntityxmlGetDocEntity (const xmlDoc *doc, const xmlChar *name)
 Look up a general entity in the internal and external subset of doc.
xmlEntityxmlGetDtdEntity (xmlDoc *doc, const xmlChar *name)
 Look up a general entity in the external subset of doc.
xmlEntityxmlGetParameterEntity (xmlDoc *doc, const xmlChar *name)
 Look up a paramater entity in the internal and external subset of doc.
xmlCharxmlEncodeEntitiesReentrant (xmlDoc *doc, const xmlChar *input)
 Replace special characters with predefined entities or numeric character references.
xmlCharxmlEncodeSpecialChars (const xmlDoc *doc, const xmlChar *input)
 Replace special characters with predefined entities or numeric character references.
xmlEntitiesTable * xmlCreateEntitiesTable (void)
 Create and initialize an empty entities hash table.
xmlEntitiesTable * xmlCopyEntitiesTable (xmlEntitiesTable *table)
 Build a copy of an entity table.
void xmlFreeEntitiesTable (xmlEntitiesTable *table)
 Deallocate the memory used by an entities hash table.
void xmlDumpEntitiesTable (xmlBuffer *buf, xmlEntitiesTable *table)
 This will dump the content of the entity table as an XML DTD definition.
void xmlDumpEntityDecl (xmlBuffer *buf, xmlEntity *ent)
 This will dump the content of the entity table as an XML DTD definition.

Detailed Description

XML entities.

This module provides an API to work with XML entities.

Author
Daniel Veillard

Enumeration Type Documentation

◆ xmlEntityType

The different entity types.

Enumerator
XML_INTERNAL_GENERAL_ENTITY 

internal general entity

XML_EXTERNAL_GENERAL_PARSED_ENTITY 

external general parsed entity

XML_EXTERNAL_GENERAL_UNPARSED_ENTITY 

external general unparsed entity

XML_INTERNAL_PARAMETER_ENTITY 

internal parameter entity

XML_EXTERNAL_PARAMETER_ENTITY 

external parameter entity

XML_INTERNAL_PREDEFINED_ENTITY 

internal predefined entity

Function Documentation

◆ xmlAddDocEntity()

xmlEntity * xmlAddDocEntity ( xmlDoc * doc,
const xmlChar * name,
int type,
const xmlChar * publicId,
const xmlChar * systemId,
const xmlChar * content )

Add a new entity to the document's internal subset.

xmlAddEntity offers better error handling.

Parameters
docthe document
namethe entity name
typean xmlEntityType value
publicIdthe publid identifier (optional)
systemIdthe system identifier (URL) (optional)
contentthe entity content
Returns
a pointer to the entity or NULL in case of error

◆ xmlAddDtdEntity()

xmlEntity * xmlAddDtdEntity ( xmlDoc * doc,
const xmlChar * name,
int type,
const xmlChar * publicId,
const xmlChar * systemId,
const xmlChar * content )

Add a new entity to the document's external subset.

xmlAddEntity offers better error handling.

Parameters
docthe document
namethe entity name
typean xmlEntityType value
publicIdthe publid identifier (optional)
systemIdthe system identifier (URL) (optional)
contentthe entity content
Returns
a pointer to the entity or NULL in case of error

◆ xmlAddEntity()

int xmlAddEntity ( xmlDoc * doc,
int extSubset,
const xmlChar * name,
int type,
const xmlChar * publicId,
const xmlChar * systemId,
const xmlChar * content,
xmlEntity ** out )

Register a new entity for this document.

Since
2.13.0
Parameters
docthe document
extSubsetadd to the external or internal subset
namethe entity name
typean xmlEntityType value
publicIdthe publid identifier (optional)
systemIdthe system identifier (URL) (optional)
contentthe entity content
outpointer to resulting entity (optional)
Returns
an xmlParserErrors error code.

◆ xmlCopyEntitiesTable()

xmlEntitiesTable * xmlCopyEntitiesTable ( xmlEntitiesTable * table)

Build a copy of an entity table.

Deprecated
Internal function, don't use.
Parameters
tableAn entity table
Returns
the new xmlEntitiesTable or NULL in case of error.

◆ xmlCreateEntitiesTable()

xmlEntitiesTable * xmlCreateEntitiesTable ( void )

Create and initialize an empty entities hash table.

Deprecated
Internal function, don't use.
Returns
the xmlEntitiesTable just created or NULL in case of error.

◆ xmlDumpEntitiesTable()

void xmlDumpEntitiesTable ( xmlBuffer * buf,
xmlEntitiesTable * table )

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

Deprecated
Internal function, don't use.
Parameters
bufAn XML buffer.
tableAn entity table

◆ xmlDumpEntityDecl()

void xmlDumpEntityDecl ( xmlBuffer * buf,
xmlEntity * ent )

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

Deprecated
Internal function, don't use.
Parameters
bufAn XML buffer.
entAn entity table

◆ xmlEncodeEntitiesReentrant()

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

Replace special characters with predefined entities or numeric character references.

If doc is NULL or an XML document, replaces <, > and & with predefined entities. Carriage return is replaced with &#13;. If doc or its encoding are NULL, non-ASCII characters are replaced with a hexadecimal character reference.

If doc is an HTML document, follows the HTML serialization rules.

Silently removes some invalid characters like ASCII control codes.

See xmlEncodeSpecialChars for an alternative.

Parameters
docthe document containing the string (optional)
inputA string to convert to XML.
Returns
a newly allocated string with substitutions.

◆ xmlEncodeSpecialChars()

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

Replace special characters with predefined entities or numeric character references.

Replaces <, >, & and " with predefined entities. Carriage return is replaced with &#13;.

Parameters
docunused
inputA string to convert to XML.
Returns
a newly allocated string with substitutions.

◆ xmlFreeEntitiesTable()

void xmlFreeEntitiesTable ( xmlEntitiesTable * table)

Deallocate the memory used by an entities hash table.

Deprecated
Internal function, don't use.
Parameters
tableAn entity table

◆ xmlFreeEntity()

void xmlFreeEntity ( xmlEntity * entity)

Frees the entity.

Parameters
entityan entity

◆ xmlGetDocEntity()

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

Look up a general entity in the internal and external subset of doc.

Also checks for predefined entities.

Parameters
docthe document referencing the entity
namethe entity name
Returns
a pointer to the entity or NULL if not found.

◆ xmlGetDtdEntity()

xmlEntity * xmlGetDtdEntity ( xmlDoc * doc,
const xmlChar * name )

Look up a general entity in the external subset of doc.

Parameters
docthe document
namethe entity name
Returns
a pointer to the entity or NULL if not found.

◆ xmlGetParameterEntity()

xmlEntity * xmlGetParameterEntity ( xmlDoc * doc,
const xmlChar * name )

Look up a paramater entity in the internal and external subset of doc.

Parameters
docthe document
namethe entity name
Returns
a pointer to the entity or NULL if not found.

◆ xmlGetPredefinedEntity()

xmlEntity * xmlGetPredefinedEntity ( const xmlChar * name)

Look up a predefined entity.

Parameters
namethe entity name
Returns
the entity, or NULL if not found.

◆ xmlNewEntity()

xmlEntity * xmlNewEntity ( xmlDoc * doc,
const xmlChar * name,
int type,
const xmlChar * publicId,
const xmlChar * systemId,
const xmlChar * content )

Create a new entity.

Like xmlAddDocEntity, but if doc is NULL or has no internal subset defined, an unlinked entity 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.

Parameters
docthe document (optional)
namethe entity name
typean xmlEntityType value
publicIdthe publid identifier (optional)
systemIdthe system identifier (URL) (optional)
contentthe entity content
Returns
a pointer to the entity or NULL in case of error