Estructura xmlXPathContext
La evaluación de la expresión se produce con respecto a un contexto.
El contexto consiste en:
- Un nodo (el nodo de contexto).
- Una lista de nodos (la lista de nodos de contexto).
- Un conjunto de enlaces de variables.
- Una biblioteca de funciones.
- El conjunto de declaraciones de espacios de nombres en el ámbito de la expresión.
Tras el cambio a las tablas hash, esto debe ser recortado en la próxima versión binaria incompatible.
El nodo puede ser modificado cuando el contexto se pasa a libxml2 para una evaluación XPath, por lo que puede ser necesario inicializarlo de nuevo antes de la siguiente llamada.
Sintaxis
/**
* xmlXPathContext:
*
* Expression evaluation occurs with respect to a context.
* he context consists of:
* - a node (the context node)
* - a node list (the context node list)
* - a set of variable bindings
* - a function library
* - the set of namespace declarations in scope for the expression
* Following the switch to hash tables, this need to be trimmed up at
* the next binary incompatible release.
* The node may be modified when the context is passed to libxml2
* for an XPath evaluation so you may need to initialize it again
* before the next call.
*/
struct _xmlXPathContext {
xmlDocPtr doc; /* The current document */
xmlNodePtr node; /* The current node */
int nb_variables_unused; /* unused (hash table) */
int max_variables_unused; /* unused (hash table) */
xmlHashTablePtr varHash; /* Hash table of defined variables */
int nb_types; /* number of defined types */
int max_types; /* max number of types */
xmlXPathTypePtr types; /* Array of defined types */
int nb_funcs_unused; /* unused (hash table) */
int max_funcs_unused; /* unused (hash table) */
xmlHashTablePtr funcHash; /* Hash table of defined funcs */
int nb_axis; /* number of defined axis */
int max_axis; /* max number of axis */
xmlXPathAxisPtr axis; /* Array of defined axis */
/* the namespace nodes of the context node */
xmlNsPtr *namespaces; /* Array of namespaces */
int nsNr; /* number of namespace in scope */
void *user; /* function to free */
/* extra variables */
int contextSize; /* the context size */
int proximityPosition; /* the proximity position */
/* extra stuff for XPointer */
int xptr; /* is this an XPointer context? */
xmlNodePtr here; /* for here() */
xmlNodePtr origin; /* for origin() */
/* the set of namespace declarations in scope for the expression */
xmlHashTablePtr nsHash; /* The namespaces hash table */
xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */
void *varLookupData; /* variable lookup data */
/* Possibility to link in an extra item */
void *extra; /* needed for XSLT */
/* The function name and URI when calling a function */
const xmlChar *function;
const xmlChar *functionURI;
/* function lookup function and data */
xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */
void *funcLookupData; /* function lookup data */
/* temporary namespace lists kept for walking the namespace axis */
xmlNsPtr *tmpNsList; /* Array of namespaces */
int tmpNsNr; /* number of namespaces in scope */
/* error reporting mechanism */
void *userData; /* user specific data block */
xmlStructuredErrorFunc error; /* the callback in case of errors */
xmlError lastError; /* the last error */
xmlNodePtr debugNode; /* the source node XSLT */
/* dictionary */
xmlDictPtr dict; /* dictionary if any */
int flags; /* flags to control compilation */
/* Cache for reusal of XPath objects */
void *cache;
};
Miembros
- doc
- El documento actual.
- node
- El nodo actual.
- nb_variables_unused
- No usado (tabla hash).
- max_variables_unused
- No usado (tabla hash).
- varHash
- Tabla hash de variables definidas.
- nb_types
- Número de tipos definidos.
- max_types
- Número máximo de tipos.
- types
- Array de tipos definidos.
- nb_funcs_unused
- No usado (tabla hash).
- max_funcs_unused
- No usado (tabla hash).
- funcHash
- Tabla hash de funciones definidas.
/* Array of defined axis */
- nb_axis
- Número de ejes definidos.
- max_axis
- Número máximo de ejes.
- axis
- Array de ejes definidos.
Los nodos del espacio de nombres del nodo de contexto.
- namespaces
- Array de espacios con nombre.
- nsNr
- Número de espacios con nombre en el ámbito.
- user
- Función para liberar.
Variables extra.
- contextSize
- El tamaño del contexto.
- proximityPosition
- La posición de proximidad.
Material extra para XPointer.
- xptr
- Indica si se trata de un contexto XPointer.
- here
- Puntero al nodo para here().
- origin
- Puntero al nodo para origin().
El conjunto de declaraciones de espacio con nombre en el ámbito de la expresión.
- nsHash
- La tabla hash de espacios con nombre.
- varLookupFunc
- Función de búsqueda de variables.
- varLookupData
- Datos de búsqueda de variables.
Possibility to link in an extra item.
- extra
- Necesario para XSLT.
- function
- functionURI
El nombre de la función y el URI cuando se llama a una función.
Función de búsqueda y datos.
- funcLookupFunc
- Función de búsqueda.
- funcLookupData
- Datos de búsqueda de la función.
Listas temporales de espacios con nombre guardadas para recorrer el eje de espacios con nombre.
- tmpNsList
- Array de espacios con nombre.
- tmpNsNr
- Número de espacios con nombre en el ámbito de aplicación.
Mecanismo de reporte de errores.
- userData
- Bloque de datos específicos de usuario.
- error
- La función de retrollamada en caso de error.
- lastError
- El último error.
- debugNode
- El nodo XSLT fuente.
Dicionario.
- dict
- Diccionario, si hay alguno.
- flags
- Banderas de control de compilación.
Caché para la reutilización de objetos XPath.
- cache