ReactOS  0.4.15-dev-341-g17c5fb8
variables.h File Reference
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include "xsltexports.h"
#include "xsltInternals.h"
#include "functions.h"
Include dependency graph for variables.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XSLT_REGISTER_VARIABLE_LOOKUP(ctxt)
 
#define XSLT_RVT_LOCAL   ((void *)1)
 
#define XSLT_RVT_FUNC_RESULT   ((void *)2)
 
#define XSLT_RVT_GLOBAL   ((void *)3)
 

Functions

XSLTPUBFUN int XSLTCALL xsltEvalGlobalVariables (xsltTransformContextPtr ctxt)
 
XSLTPUBFUN int XSLTCALL xsltEvalUserParams (xsltTransformContextPtr ctxt, const char **params)
 
XSLTPUBFUN int XSLTCALL xsltQuoteUserParams (xsltTransformContextPtr ctxt, const char **params)
 
XSLTPUBFUN int XSLTCALL xsltEvalOneUserParam (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
 
XSLTPUBFUN int XSLTCALL xsltQuoteOneUserParam (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
 
XSLTPUBFUN void XSLTCALL xsltParseGlobalVariable (xsltStylesheetPtr style, xmlNodePtr cur)
 
XSLTPUBFUN void XSLTCALL xsltParseGlobalParam (xsltStylesheetPtr style, xmlNodePtr cur)
 
XSLTPUBFUN void XSLTCALL xsltParseStylesheetVariable (xsltTransformContextPtr ctxt, xmlNodePtr cur)
 
XSLTPUBFUN void XSLTCALL xsltParseStylesheetParam (xsltTransformContextPtr ctxt, xmlNodePtr cur)
 
XSLTPUBFUN xsltStackElemPtr XSLTCALL xsltParseStylesheetCallerParam (xsltTransformContextPtr ctxt, xmlNodePtr cur)
 
XSLTPUBFUN int XSLTCALL xsltAddStackElemList (xsltTransformContextPtr ctxt, xsltStackElemPtr elems)
 
XSLTPUBFUN void XSLTCALL xsltFreeGlobalVariables (xsltTransformContextPtr ctxt)
 
XSLTPUBFUN xmlXPathObjectPtr XSLTCALL xsltVariableLookup (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri)
 
XSLTPUBFUN xmlXPathObjectPtr XSLTCALL xsltXPathVariableLookup (void *ctxt, const xmlChar *name, const xmlChar *ns_uri)
 

Macro Definition Documentation

◆ XSLT_REGISTER_VARIABLE_LOOKUP

#define XSLT_REGISTER_VARIABLE_LOOKUP (   ctxt)
Value:
xmlXPathRegisterVariableLookup((ctxt)->xpathCtxt, \
xsltXPathVariableLookup, (void *)(ctxt)); \
xsltRegisterAllFunctions((ctxt)->xpathCtxt); \
xsltRegisterAllElement(ctxt); \
(ctxt)->xpathCtxt->extra = ctxt
XSLTPUBFUN xmlXPathObjectPtr XSLTCALL xsltXPathVariableLookup(void *ctxt, const xmlChar *name, const xmlChar *ns_uri)
Definition: variables.c:2240

XSLT_REGISTER_VARIABLE_LOOKUP:

Registering macro, not general purpose at all but used in different modules.

Definition at line 30 of file variables.h.

◆ XSLT_RVT_FUNC_RESULT

#define XSLT_RVT_FUNC_RESULT   ((void *)2)

XSLT_RVT_FUNC_RESULT:

RVT is part of results returned with func:result. The RVT won't be destroyed after exiting a template and will be reset to XSLT_RVT_LOCAL or XSLT_RVT_VARIABLE in the template that receives the return value.

Definition at line 55 of file variables.h.

◆ XSLT_RVT_GLOBAL

#define XSLT_RVT_GLOBAL   ((void *)3)

XSLT_RVT_GLOBAL:

RVT is part of a global variable.

Definition at line 62 of file variables.h.

◆ XSLT_RVT_LOCAL

#define XSLT_RVT_LOCAL   ((void *)1)

XSLT_RVT_LOCAL:

RVT is destroyed after the current instructions ends.

Definition at line 46 of file variables.h.

Function Documentation

◆ xsltAddStackElemList()

XSLTPUBFUN int XSLTCALL xsltAddStackElemList ( xsltTransformContextPtr  ctxt,
xsltStackElemPtr  elems 
)

xsltAddStackElemList: @ctxt: xn XSLT transformation context @elems: a stack element list

Push an element list onto the stack.

Returns 0 in case of success, -1 in case of failure.

Definition at line 782 of file variables.c.

783 {
784  return(xsltAddStackElem(ctxt, elems));
785 }
static int xsltAddStackElem(xsltTransformContextPtr ctxt, xsltStackElemPtr elem)
Definition: variables.c:736

◆ xsltEvalGlobalVariables()

XSLTPUBFUN int XSLTCALL xsltEvalGlobalVariables ( xsltTransformContextPtr  ctxt)

xsltEvalGlobalVariables: @ctxt: the XSLT transformation context

Evaluates all global variables and parameters of a stylesheet. For internal use only. This is called at start of a transformation.

Returns 0 in case of success, -1 in case of error

Definition at line 1257 of file variables.c.

1257  {
1260 
1261  if ((ctxt == NULL) || (ctxt->document == NULL))
1262  return(-1);
1263 
1264 #ifdef WITH_XSLT_DEBUG_VARIABLE
1266  "Registering global variables\n"));
1267 #endif
1268  /*
1269  * Walk the list from the stylesheets and populate the hash table
1270  */
1271  style = ctxt->style;
1272  while (style != NULL) {
1273  elem = style->variables;
1274 
1275 #ifdef WITH_XSLT_DEBUG_VARIABLE
1276  if ((style->doc != NULL) && (style->doc->URL != NULL)) {
1278  "Registering global variables from %s\n",
1279  style->doc->URL));
1280  }
1281 #endif
1282 
1283  while (elem != NULL) {
1284  xsltStackElemPtr def;
1285 
1286  /*
1287  * Global variables are stored in the variables pool.
1288  */
1289  def = (xsltStackElemPtr)
1290  xmlHashLookup2(ctxt->globalVars,
1291  elem->name, elem->nameURI);
1292  if (def == NULL) {
1293 
1294  def = xsltCopyStackElem(elem);
1296  elem->name, elem->nameURI, def);
1297  } else if ((elem->comp != NULL) &&
1298  (elem->comp->type == XSLT_FUNC_VARIABLE)) {
1299  /*
1300  * Redefinition of variables from a different stylesheet
1301  * should not generate a message.
1302  */
1303  if ((elem->comp->inst != NULL) &&
1304  (def->comp != NULL) && (def->comp->inst != NULL) &&
1305  (elem->comp->inst->doc == def->comp->inst->doc))
1306  {
1307  xsltTransformError(ctxt, style, elem->comp->inst,
1308  "Global variable %s already defined\n", elem->name);
1309  if (style != NULL) style->errors++;
1310  }
1311  }
1312  elem = elem->next;
1313  }
1314 
1316  }
1317 
1318  /*
1319  * This part does the actual evaluation
1320  */
1322 
1323  return(0);
1324 }
XMLPUBFUN void XMLCALL xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data)
Definition: hash.c:864
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:251
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:411
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
struct _xmlDoc * doc
Definition: tree.h:498
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
xsltDocumentPtr document
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
static xsltStackElemPtr xsltCopyStackElem(xsltStackElemPtr elem)
Definition: variables.c:521
xsltStylePreCompPtr comp
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xsltStylesheetPtr style
static void xsltEvalGlobalVariableWrapper(void *payload, void *data, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: variables.c:1241
xsltStackElem * xsltStackElemPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Arabic default style
Definition: afstyles.h:93
xmlHashTablePtr globalVars

Referenced by xsltApplyStylesheetInternal().

◆ xsltEvalOneUserParam()

XSLTPUBFUN int XSLTCALL xsltEvalOneUserParam ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar value 
)

Definition at line 1724 of file variables.c.

1726  {
1727  return xsltProcessUserParamInternal(ctxt, name, value,
1728  1 /* xpath eval ? */);
1729 }
static int xsltProcessUserParamInternal(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value, int eval)
Definition: variables.c:1435
Definition: name.c:38

Referenced by xsltEvalUserParams().

◆ xsltEvalUserParams()

XSLTPUBFUN int XSLTCALL xsltEvalUserParams ( xsltTransformContextPtr  ctxt,
const char **  params 
)

xsltEvalUserParams:

@ctxt: the XSLT transformation context @params: a NULL terminated array of parameters name/value tuples

Evaluate the global variables of a stylesheet. This needs to be done on parsed stylesheets before starting to apply transformations. Each of the parameters is evaluated as an XPath expression and stored in the global variables/parameter hash table. If you want your parameter used literally, use xsltQuoteUserParams.

Returns 0 in case of success, -1 in case of error

Definition at line 1659 of file variables.c.

1659  {
1660  int indx = 0;
1661  const xmlChar *name;
1662  const xmlChar *value;
1663 
1664  if (params == NULL)
1665  return(0);
1666  while (params[indx] != NULL) {
1667  name = (const xmlChar *) params[indx++];
1668  value = (const xmlChar *) params[indx++];
1669  if (xsltEvalOneUserParam(ctxt, name, value) != 0)
1670  return(-1);
1671  }
1672  return 0;
1673 }
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
int xsltEvalOneUserParam(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
Definition: variables.c:1724
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
Definition: name.c:38
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xsltApplyStylesheetInternal().

◆ xsltFreeGlobalVariables()

XSLTPUBFUN void XSLTCALL xsltFreeGlobalVariables ( xsltTransformContextPtr  ctxt)

xsltFreeGlobalVariables: @ctxt: the XSLT transformation context

Free up the data associated to the global variables its value.

Definition at line 2224 of file variables.c.

2224  {
2226 }
static void xsltFreeStackElemEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: variables.c:596
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:327
xmlHashTablePtr globalVars

Referenced by xsltFreeTransformContext().

◆ xsltParseGlobalParam()

XSLTPUBFUN void XSLTCALL xsltParseGlobalParam ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)

xsltParseGlobalParam: @style: the XSLT stylesheet @cur: the "param" element

parse an XSLT transformation param declaration and record its value.

Definition at line 2084 of file variables.c.

2084  {
2085 #ifdef XSLT_REFACTORED
2086  xsltStyleItemParamPtr comp;
2087 #else
2088  xsltStylePreCompPtr comp;
2089 #endif
2090 
2091  if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
2092  return;
2093 
2094 #ifdef XSLT_REFACTORED
2095  /*
2096  * Note that xsltStylePreCompute() will be called from
2097  * xslt.c only.
2098  */
2099  comp = (xsltStyleItemParamPtr) cur->psvi;
2100 #else
2101  xsltStylePreCompute(style, cur);
2102  comp = (xsltStylePreCompPtr) cur->psvi;
2103 #endif
2104  if (comp == NULL) {
2106  "xsl:param : compilation failed\n");
2107  return;
2108  }
2109 
2110  if (comp->name == NULL) {
2112  "xsl:param : missing name attribute\n");
2113  return;
2114  }
2115 
2116  /*
2117  * Parse the content (a sequence constructor) of xsl:param.
2118  */
2119  if (cur->children != NULL) {
2120 #ifdef XSLT_REFACTORED
2121  xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
2122 #else
2124 #endif
2125  }
2126 
2127 #ifdef WITH_XSLT_DEBUG_VARIABLE
2129  "Registering global param %s\n", comp->name);
2130 #endif
2131 
2132  xsltRegisterGlobalVariable(style, comp->name, comp->ns,
2133  comp->select, cur->children, (xsltStylePreCompPtr) comp,
2134  NULL);
2135 }
void * psvi
Definition: tree.h:505
static int xsltRegisterGlobalVariable(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns_uri, const xmlChar *sel, xmlNodePtr tree, xsltStylePreCompPtr comp, const xmlChar *value)
Definition: variables.c:1342
const xmlChar * ns
smooth NULL
Definition: ftsmooth.c:416
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2175
void * xsltGenericDebugContext
Definition: xsltutils.c:549
if(!(yy_init))
Definition: macro.lex.yy.c:714
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
xmlElementType type
Definition: tree.h:491
xsltStylePreComp * xsltStylePreCompPtr
const xmlChar * name
const xmlChar * select
struct _xmlNode * children
Definition: tree.h:493
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4882
Arabic default style
Definition: afstyles.h:93

Referenced by xsltParseStylesheetTop().

◆ xsltParseGlobalVariable()

XSLTPUBFUN void XSLTCALL xsltParseGlobalVariable ( xsltStylesheetPtr  style,
xmlNodePtr  cur 
)

xsltParseGlobalVariable: @style: the XSLT stylesheet @cur: the "variable" element

Parses a global XSLT 'variable' declaration at compilation time and registers it

Definition at line 2021 of file variables.c.

2022 {
2023 #ifdef XSLT_REFACTORED
2024  xsltStyleItemVariablePtr comp;
2025 #else
2026  xsltStylePreCompPtr comp;
2027 #endif
2028 
2029  if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
2030  return;
2031 
2032 #ifdef XSLT_REFACTORED
2033  /*
2034  * Note that xsltStylePreCompute() will be called from
2035  * xslt.c only.
2036  */
2037  comp = (xsltStyleItemVariablePtr) cur->psvi;
2038 #else
2039  xsltStylePreCompute(style, cur);
2040  comp = (xsltStylePreCompPtr) cur->psvi;
2041 #endif
2042  if (comp == NULL) {
2044  "xsl:variable : compilation failed\n");
2045  return;
2046  }
2047 
2048  if (comp->name == NULL) {
2050  "xsl:variable : missing name attribute\n");
2051  return;
2052  }
2053 
2054  /*
2055  * Parse the content (a sequence constructor) of xsl:variable.
2056  */
2057  if (cur->children != NULL) {
2058 #ifdef XSLT_REFACTORED
2059  xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
2060 #else
2062 #endif
2063  }
2064 #ifdef WITH_XSLT_DEBUG_VARIABLE
2066  "Registering global variable %s\n", comp->name);
2067 #endif
2068 
2069  xsltRegisterGlobalVariable(style, comp->name, comp->ns,
2070  comp->select, cur->children, (xsltStylePreCompPtr) comp,
2071  NULL);
2072 }
void * psvi
Definition: tree.h:505
static int xsltRegisterGlobalVariable(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns_uri, const xmlChar *sel, xmlNodePtr tree, xsltStylePreCompPtr comp, const xmlChar *value)
Definition: variables.c:1342
const xmlChar * ns
smooth NULL
Definition: ftsmooth.c:416
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2175
void * xsltGenericDebugContext
Definition: xsltutils.c:549
if(!(yy_init))
Definition: macro.lex.yy.c:714
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
xmlElementType type
Definition: tree.h:491
xsltStylePreComp * xsltStylePreCompPtr
const xmlChar * name
const xmlChar * select
struct _xmlNode * children
Definition: tree.h:493
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4882
Arabic default style
Definition: afstyles.h:93

Referenced by xsltParseStylesheetTop().

◆ xsltParseStylesheetCallerParam()

XSLTPUBFUN xsltStackElemPtr XSLTCALL xsltParseStylesheetCallerParam ( xsltTransformContextPtr  ctxt,
xmlNodePtr  inst 
)

xsltParseStylesheetCallerParam: @ctxt: the XSLT transformation context @inst: the xsl:with-param instruction element

Processes an xsl:with-param instruction at transformation time. The value is computed, but not recorded. NOTE that this is also called with an xsl:param element from exsltFuncFunctionFunction().

Returns the new xsltStackElemPtr or NULL

Definition at line 1959 of file variables.c.

1960 {
1961 #ifdef XSLT_REFACTORED
1962  xsltStyleBasicItemVariablePtr comp;
1963 #else
1964  xsltStylePreCompPtr comp;
1965 #endif
1966  xmlNodePtr tree = NULL; /* The first child node of the instruction or
1967  the instruction itself. */
1969 
1970  if ((ctxt == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
1971  return(NULL);
1972 
1973 #ifdef XSLT_REFACTORED
1974  comp = (xsltStyleBasicItemVariablePtr) inst->psvi;
1975 #else
1976  comp = (xsltStylePreCompPtr) inst->psvi;
1977 #endif
1978 
1979  if (comp == NULL) {
1980  xsltTransformError(ctxt, NULL, inst,
1981  "Internal error in xsltParseStylesheetCallerParam(): "
1982  "The XSLT 'with-param' instruction was not compiled.\n");
1983  return(NULL);
1984  }
1985  if (comp->name == NULL) {
1986  xsltTransformError(ctxt, NULL, inst,
1987  "Internal error in xsltParseStylesheetCallerParam(): "
1988  "XSLT 'with-param': The attribute 'name' was not compiled.\n");
1989  return(NULL);
1990  }
1991 
1992 #ifdef WITH_XSLT_DEBUG_VARIABLE
1994  "Handling xsl:with-param %s\n", comp->name));
1995 #endif
1996 
1997  if (comp->select == NULL) {
1998  tree = inst->children;
1999  } else {
2000 #ifdef WITH_XSLT_DEBUG_VARIABLE
2002  " select %s\n", comp->select));
2003 #endif
2004  tree = inst;
2005  }
2006 
2008 
2009  return(param);
2010 }
void * psvi
Definition: tree.h:505
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
GLfloat param
Definition: glext.h:5796
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlElementType type
Definition: tree.h:491
static xsltStackElemPtr xsltBuildVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree)
Definition: variables.c:1763
const xmlChar * name
const xmlChar * select
struct _xmlNode * children
Definition: tree.h:493
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

Referenced by xsltApplyTemplates(), and xsltCallTemplate().

◆ xsltParseStylesheetParam()

XSLTPUBFUN void XSLTCALL xsltParseStylesheetParam ( xsltTransformContextPtr  ctxt,
xmlNodePtr  cur 
)

xsltParseStylesheetParam: @ctxt: the XSLT transformation context @cur: the XSLT 'param' element

Registers a local XSLT 'param' declaration at transformation time and evaluates its value.

Definition at line 2188 of file variables.c.

2189 {
2190 #ifdef XSLT_REFACTORED
2191  xsltStyleItemParamPtr comp;
2192 #else
2193  xsltStylePreCompPtr comp;
2194 #endif
2195 
2196  if ((cur == NULL) || (ctxt == NULL) || (cur->type != XML_ELEMENT_NODE))
2197  return;
2198 
2199  comp = cur->psvi;
2200  if ((comp == NULL) || (comp->name == NULL)) {
2201  xsltTransformError(ctxt, NULL, cur,
2202  "Internal error in xsltParseStylesheetParam(): "
2203  "The XSLT 'param' declaration was not compiled correctly.\n");
2204  return;
2205  }
2206 
2207 #ifdef WITH_XSLT_DEBUG_VARIABLE
2209  "Registering param %s\n", comp->name));
2210 #endif
2211 
2212  xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, cur->children, 1);
2213 }
void * psvi
Definition: tree.h:505
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
static int xsltRegisterVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree, int isParam)
Definition: variables.c:1810
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlElementType type
Definition: tree.h:491
const xmlChar * name
struct _xmlNode * children
Definition: tree.h:493
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

Referenced by xsltApplyXSLTTemplate().

◆ xsltParseStylesheetVariable()

XSLTPUBFUN void XSLTCALL xsltParseStylesheetVariable ( xsltTransformContextPtr  ctxt,
xmlNodePtr  inst 
)

xsltParseStylesheetVariable: @ctxt: the XSLT transformation context @inst: the xsl:variable instruction element

Registers a local XSLT 'variable' instruction at transformation time and evaluates its value.

Definition at line 2146 of file variables.c.

2147 {
2148 #ifdef XSLT_REFACTORED
2149  xsltStyleItemVariablePtr comp;
2150 #else
2151  xsltStylePreCompPtr comp;
2152 #endif
2153 
2154  if ((inst == NULL) || (ctxt == NULL) || (inst->type != XML_ELEMENT_NODE))
2155  return;
2156 
2157  comp = inst->psvi;
2158  if (comp == NULL) {
2159  xsltTransformError(ctxt, NULL, inst,
2160  "Internal error in xsltParseStylesheetVariable(): "
2161  "The XSLT 'variable' instruction was not compiled.\n");
2162  return;
2163  }
2164  if (comp->name == NULL) {
2165  xsltTransformError(ctxt, NULL, inst,
2166  "Internal error in xsltParseStylesheetVariable(): "
2167  "The attribute 'name' was not compiled.\n");
2168  return;
2169  }
2170 
2171 #ifdef WITH_XSLT_DEBUG_VARIABLE
2173  "Registering variable '%s'\n", comp->name));
2174 #endif
2175 
2176  xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, inst->children, 0);
2177 }
void * psvi
Definition: tree.h:505
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
static int xsltRegisterVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree, int isParam)
Definition: variables.c:1810
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xmlElementType type
Definition: tree.h:491
const xmlChar * name
struct _xmlNode * children
Definition: tree.h:493
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

Referenced by xsltApplySequenceConstructor().

◆ xsltQuoteOneUserParam()

XSLTPUBFUN int XSLTCALL xsltQuoteOneUserParam ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar value 
)

Definition at line 1745 of file variables.c.

1747  {
1748  return xsltProcessUserParamInternal(ctxt, name, value,
1749  0 /* xpath eval ? */);
1750 }
static int xsltProcessUserParamInternal(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value, int eval)
Definition: variables.c:1435
Definition: name.c:38

Referenced by xsltQuoteUserParams().

◆ xsltQuoteUserParams()

XSLTPUBFUN int XSLTCALL xsltQuoteUserParams ( xsltTransformContextPtr  ctxt,
const char **  params 
)

xsltQuoteUserParams:

@ctxt: the XSLT transformation context @params: a NULL terminated arry of parameters names/values tuples

Similar to xsltEvalUserParams, but the values are treated literally and are * not evaluated as XPath expressions. This should be done on parsed stylesheets before starting to apply transformations.

Returns 0 in case of success, -1 in case of error.

Definition at line 1689 of file variables.c.

1689  {
1690  int indx = 0;
1691  const xmlChar *name;
1692  const xmlChar *value;
1693 
1694  if (params == NULL)
1695  return(0);
1696  while (params[indx] != NULL) {
1697  name = (const xmlChar *) params[indx++];
1698  value = (const xmlChar *) params[indx++];
1699  if (xsltQuoteOneUserParam(ctxt, name, value) != 0)
1700  return(-1);
1701  }
1702  return 0;
1703 }
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
int xsltQuoteOneUserParam(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
Definition: variables.c:1745
Definition: name.c:38
GLuint const GLchar * name
Definition: glext.h:6031

◆ xsltVariableLookup()

XSLTPUBFUN xmlXPathObjectPtr XSLTCALL xsltVariableLookup ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar ns_uri 
)

Definition at line 1917 of file variables.c.

1918  {
1920 
1921  if (ctxt == NULL)
1922  return(NULL);
1923 
1924  elem = xsltStackLookup(ctxt, name, ns_uri);
1925  if (elem == NULL) {
1926  return(xsltGlobalVariableLookup(ctxt, name, ns_uri));
1927  }
1928  if (elem->computed == 0) {
1929 #ifdef WITH_XSLT_DEBUG_VARIABLE
1931  "uncomputed variable %s\n", name));
1932 #endif
1933  elem->value = xsltEvalVariable(ctxt, elem, NULL);
1934  elem->computed = 1;
1935  }
1936  if (elem->value != NULL)
1937  return(xmlXPathObjectCopy(elem->value));
1938 #ifdef WITH_XSLT_DEBUG_VARIABLE
1940  "variable not found %s\n", name));
1941 #endif
1942  return(NULL);
1943 }
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
static xmlXPathObjectPtr xsltGlobalVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri)
Definition: variables.c:1870
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
static xmlXPathObjectPtr xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr variable, xsltStylePreCompPtr castedComp)
Definition: variables.c:804
Definition: name.c:38
static xsltStackElemPtr xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: variables.c:632

◆ xsltXPathVariableLookup()

XSLTPUBFUN xmlXPathObjectPtr XSLTCALL xsltXPathVariableLookup ( void ctxt,
const xmlChar name,
const xmlChar ns_uri 
)

Definition at line 2240 of file variables.c.

2241  {
2243  xmlXPathObjectPtr valueObj = NULL;
2244 
2245  if ((ctxt == NULL) || (name == NULL))
2246  return(NULL);
2247 
2248 #ifdef WITH_XSLT_DEBUG_VARIABLE
2250  "Lookup variable '%s'\n", name));
2251 #endif
2252 
2253  tctxt = (xsltTransformContextPtr) ctxt;
2254  /*
2255  * Local variables/params ---------------------------------------------
2256  *
2257  * Do the lookup from the top of the stack, but
2258  * don't use params being computed in a call-param
2259  * First lookup expects the variable name and URI to
2260  * come from the disctionnary and hence pointer comparison.
2261  */
2262  if (tctxt->varsNr != 0) {
2263  int i;
2265 
2266  for (i = tctxt->varsNr; i > tctxt->varsBase; i--) {
2267  cur = tctxt->varsTab[i-1];
2268  if ((cur->name == name) && (cur->nameURI == ns_uri)) {
2269 #if 0
2270  stack_addr++;
2271 #endif
2272  variable = cur;
2273  goto local_variable_found;
2274  }
2275  cur = cur->next;
2276  }
2277  /*
2278  * Redo the lookup with interned strings to avoid string comparison.
2279  *
2280  * OPTIMIZE TODO: The problem here is, that if we request a
2281  * global variable, then this will be also executed.
2282  */
2283  {
2284  const xmlChar *tmpName = name, *tmpNsName = ns_uri;
2285 
2286  name = xmlDictLookup(tctxt->dict, name, -1);
2287  if (ns_uri)
2288  ns_uri = xmlDictLookup(tctxt->dict, ns_uri, -1);
2289  if ((tmpName != name) || (tmpNsName != ns_uri)) {
2290  for (i = tctxt->varsNr; i > tctxt->varsBase; i--) {
2291  cur = tctxt->varsTab[i-1];
2292  if ((cur->name == name) && (cur->nameURI == ns_uri)) {
2293 #if 0
2294  stack_cmp++;
2295 #endif
2296  variable = cur;
2297  goto local_variable_found;
2298  }
2299  }
2300  }
2301  }
2302 
2303 local_variable_found:
2304 
2305  if (variable) {
2306  if (variable->computed == 0) {
2307 
2308 #ifdef WITH_XSLT_DEBUG_VARIABLE
2310  "uncomputed variable '%s'\n", name));
2311 #endif
2312  variable->value = xsltEvalVariable(tctxt, variable, NULL);
2313  variable->computed = 1;
2314  }
2315  if (variable->value != NULL) {
2316  valueObj = xmlXPathObjectCopy(variable->value);
2317  }
2318  return(valueObj);
2319  }
2320  }
2321  /*
2322  * Global variables/params --------------------------------------------
2323  */
2324  if (tctxt->globalVars) {
2325  valueObj = xsltGlobalVariableLookup(tctxt, name, ns_uri);
2326  }
2327 
2328  if (valueObj == NULL) {
2329 
2330 #ifdef WITH_XSLT_DEBUG_VARIABLE
2332  "variable not found '%s'\n", name));
2333 #endif
2334 
2335  if (ns_uri) {
2336  xsltTransformError(tctxt, NULL, tctxt->inst,
2337  "Variable '{%s}%s' has not been declared.\n", ns_uri, name);
2338  } else {
2339  xsltTransformError(tctxt, NULL, tctxt->inst,
2340  "Variable '%s' has not been declared.\n", name);
2341  }
2342  } else {
2343 
2344 #ifdef WITH_XSLT_DEBUG_VARIABLE
2346  "found variable '%s'\n", name));
2347 #endif
2348  }
2349 
2350  return(valueObj);
2351 }
struct _xsltStackElem * next
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
xsltTransformContext * xsltTransformContextPtr
smooth NULL
Definition: ftsmooth.c:416
GLenum GLenum variable
Definition: glext.h:9031
void * xsltGenericDebugContext
Definition: xsltutils.c:549
static xmlXPathObjectPtr xsltGlobalVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri)
Definition: variables.c:1870
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
unsigned char xmlChar
Definition: xmlstring.h:28
xsltStackElemPtr * varsTab
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
static xmlXPathObjectPtr xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr variable, xsltStylePreCompPtr castedComp)
Definition: variables.c:804
Definition: name.c:38
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
xmlHashTablePtr globalVars
GLuint const GLchar * name
Definition: glext.h:6031