ReactOS  0.4.13-dev-982-g9853eab
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:2238

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 780 of file variables.c.

781 {
782  return(xsltAddStackElem(ctxt, elems));
783 }
static int xsltAddStackElem(xsltTransformContextPtr ctxt, xsltStackElemPtr elem)
Definition: variables.c:734

◆ 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 1255 of file variables.c.

1255  {
1258 
1259  if ((ctxt == NULL) || (ctxt->document == NULL))
1260  return(-1);
1261 
1262 #ifdef WITH_XSLT_DEBUG_VARIABLE
1264  "Registering global variables\n"));
1265 #endif
1266  /*
1267  * Walk the list from the stylesheets and populate the hash table
1268  */
1269  style = ctxt->style;
1270  while (style != NULL) {
1271  elem = style->variables;
1272 
1273 #ifdef WITH_XSLT_DEBUG_VARIABLE
1274  if ((style->doc != NULL) && (style->doc->URL != NULL)) {
1276  "Registering global variables from %s\n",
1277  style->doc->URL));
1278  }
1279 #endif
1280 
1281  while (elem != NULL) {
1282  xsltStackElemPtr def;
1283 
1284  /*
1285  * Global variables are stored in the variables pool.
1286  */
1287  def = (xsltStackElemPtr)
1288  xmlHashLookup2(ctxt->globalVars,
1289  elem->name, elem->nameURI);
1290  if (def == NULL) {
1291 
1292  def = xsltCopyStackElem(elem);
1294  elem->name, elem->nameURI, def);
1295  } else if ((elem->comp != NULL) &&
1296  (elem->comp->type == XSLT_FUNC_VARIABLE)) {
1297  /*
1298  * Redefinition of variables from a different stylesheet
1299  * should not generate a message.
1300  */
1301  if ((elem->comp->inst != NULL) &&
1302  (def->comp != NULL) && (def->comp->inst != NULL) &&
1303  (elem->comp->inst->doc == def->comp->inst->doc))
1304  {
1305  xsltTransformError(ctxt, style, elem->comp->inst,
1306  "Global variable %s already defined\n", elem->name);
1307  if (style != NULL) style->errors++;
1308  }
1309  }
1310  elem = elem->next;
1311  }
1312 
1314  }
1315 
1316  /*
1317  * This part does the actual evaluation
1318  */
1320 
1321  return(0);
1322 }
XMLPUBFUN void XMLCALL xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data)
Definition: hash.c:857
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:250
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:404
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:474
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:519
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:1239
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 1722 of file variables.c.

1724  {
1725  return xsltProcessUserParamInternal(ctxt, name, value,
1726  1 /* xpath eval ? */);
1727 }
static int xsltProcessUserParamInternal(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value, int eval)
Definition: variables.c:1433
Definition: name.c:36

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 1657 of file variables.c.

1657  {
1658  int indx = 0;
1659  const xmlChar *name;
1660  const xmlChar *value;
1661 
1662  if (params == NULL)
1663  return(0);
1664  while (params[indx] != NULL) {
1665  name = (const xmlChar *) params[indx++];
1666  value = (const xmlChar *) params[indx++];
1667  if (xsltEvalOneUserParam(ctxt, name, value) != 0)
1668  return(-1);
1669  }
1670  return 0;
1671 }
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:1722
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
Definition: name.c:36
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 2222 of file variables.c.

2222  {
2224 }
static void xsltFreeStackElemEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: variables.c:594
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:320
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 2082 of file variables.c.

2082  {
2083 #ifdef XSLT_REFACTORED
2084  xsltStyleItemParamPtr comp;
2085 #else
2086  xsltStylePreCompPtr comp;
2087 #endif
2088 
2089  if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
2090  return;
2091 
2092 #ifdef XSLT_REFACTORED
2093  /*
2094  * Note that xsltStylePreCompute() will be called from
2095  * xslt.c only.
2096  */
2097  comp = (xsltStyleItemParamPtr) cur->psvi;
2098 #else
2099  xsltStylePreCompute(style, cur);
2100  comp = (xsltStylePreCompPtr) cur->psvi;
2101 #endif
2102  if (comp == NULL) {
2104  "xsl:param : compilation failed\n");
2105  return;
2106  }
2107 
2108  if (comp->name == NULL) {
2110  "xsl:param : missing name attribute\n");
2111  return;
2112  }
2113 
2114  /*
2115  * Parse the content (a sequence constructor) of xsl:param.
2116  */
2117  if (cur->children != NULL) {
2118 #ifdef XSLT_REFACTORED
2119  xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
2120 #else
2122 #endif
2123  }
2124 
2125 #ifdef WITH_XSLT_DEBUG_VARIABLE
2127  "Registering global param %s\n", comp->name);
2128 #endif
2129 
2130  xsltRegisterGlobalVariable(style, comp->name, comp->ns,
2131  comp->select, cur->children, (xsltStylePreCompPtr) comp,
2132  NULL);
2133 }
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:1340
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:4863
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 2019 of file variables.c.

2020 {
2021 #ifdef XSLT_REFACTORED
2022  xsltStyleItemVariablePtr comp;
2023 #else
2024  xsltStylePreCompPtr comp;
2025 #endif
2026 
2027  if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
2028  return;
2029 
2030 #ifdef XSLT_REFACTORED
2031  /*
2032  * Note that xsltStylePreCompute() will be called from
2033  * xslt.c only.
2034  */
2035  comp = (xsltStyleItemVariablePtr) cur->psvi;
2036 #else
2037  xsltStylePreCompute(style, cur);
2038  comp = (xsltStylePreCompPtr) cur->psvi;
2039 #endif
2040  if (comp == NULL) {
2042  "xsl:variable : compilation failed\n");
2043  return;
2044  }
2045 
2046  if (comp->name == NULL) {
2048  "xsl:variable : missing name attribute\n");
2049  return;
2050  }
2051 
2052  /*
2053  * Parse the content (a sequence constructor) of xsl:variable.
2054  */
2055  if (cur->children != NULL) {
2056 #ifdef XSLT_REFACTORED
2057  xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
2058 #else
2060 #endif
2061  }
2062 #ifdef WITH_XSLT_DEBUG_VARIABLE
2064  "Registering global variable %s\n", comp->name);
2065 #endif
2066 
2067  xsltRegisterGlobalVariable(style, comp->name, comp->ns,
2068  comp->select, cur->children, (xsltStylePreCompPtr) comp,
2069  NULL);
2070 }
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:1340
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:4863
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 compute, 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 1957 of file variables.c.

1958 {
1959 #ifdef XSLT_REFACTORED
1960  xsltStyleBasicItemVariablePtr comp;
1961 #else
1962  xsltStylePreCompPtr comp;
1963 #endif
1964  xmlNodePtr tree = NULL; /* The first child node of the instruction or
1965  the instruction itself. */
1967 
1968  if ((ctxt == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
1969  return(NULL);
1970 
1971 #ifdef XSLT_REFACTORED
1972  comp = (xsltStyleBasicItemVariablePtr) inst->psvi;
1973 #else
1974  comp = (xsltStylePreCompPtr) inst->psvi;
1975 #endif
1976 
1977  if (comp == NULL) {
1978  xsltTransformError(ctxt, NULL, inst,
1979  "Internal error in xsltParseStylesheetCallerParam(): "
1980  "The XSLT 'with-param' instruction was not compiled.\n");
1981  return(NULL);
1982  }
1983  if (comp->name == NULL) {
1984  xsltTransformError(ctxt, NULL, inst,
1985  "Internal error in xsltParseStylesheetCallerParam(): "
1986  "XSLT 'with-param': The attribute 'name' was not compiled.\n");
1987  return(NULL);
1988  }
1989 
1990 #ifdef WITH_XSLT_DEBUG_VARIABLE
1992  "Handling xsl:with-param %s\n", comp->name));
1993 #endif
1994 
1995  if (comp->select == NULL) {
1996  tree = inst->children;
1997  } else {
1998 #ifdef WITH_XSLT_DEBUG_VARIABLE
2000  " select %s\n", comp->select));
2001 #endif
2002  tree = inst;
2003  }
2004 
2006 
2007  return(param);
2008 }
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:1761
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 2186 of file variables.c.

2187 {
2188 #ifdef XSLT_REFACTORED
2189  xsltStyleItemParamPtr comp;
2190 #else
2191  xsltStylePreCompPtr comp;
2192 #endif
2193 
2194  if ((cur == NULL) || (ctxt == NULL) || (cur->type != XML_ELEMENT_NODE))
2195  return;
2196 
2197  comp = cur->psvi;
2198  if ((comp == NULL) || (comp->name == NULL)) {
2199  xsltTransformError(ctxt, NULL, cur,
2200  "Internal error in xsltParseStylesheetParam(): "
2201  "The XSLT 'param' declaration was not compiled correctly.\n");
2202  return;
2203  }
2204 
2205 #ifdef WITH_XSLT_DEBUG_VARIABLE
2207  "Registering param %s\n", comp->name));
2208 #endif
2209 
2210  xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, cur->children, 1);
2211 }
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:1808
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 2144 of file variables.c.

2145 {
2146 #ifdef XSLT_REFACTORED
2147  xsltStyleItemVariablePtr comp;
2148 #else
2149  xsltStylePreCompPtr comp;
2150 #endif
2151 
2152  if ((inst == NULL) || (ctxt == NULL) || (inst->type != XML_ELEMENT_NODE))
2153  return;
2154 
2155  comp = inst->psvi;
2156  if (comp == NULL) {
2157  xsltTransformError(ctxt, NULL, inst,
2158  "Internal error in xsltParseStylesheetVariable(): "
2159  "The XSLT 'variable' instruction was not compiled.\n");
2160  return;
2161  }
2162  if (comp->name == NULL) {
2163  xsltTransformError(ctxt, NULL, inst,
2164  "Internal error in xsltParseStylesheetVariable(): "
2165  "The attribute 'name' was not compiled.\n");
2166  return;
2167  }
2168 
2169 #ifdef WITH_XSLT_DEBUG_VARIABLE
2171  "Registering variable '%s'\n", comp->name));
2172 #endif
2173 
2174  xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, inst->children, 0);
2175 }
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:1808
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 1743 of file variables.c.

1745  {
1746  return xsltProcessUserParamInternal(ctxt, name, value,
1747  0 /* xpath eval ? */);
1748 }
static int xsltProcessUserParamInternal(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value, int eval)
Definition: variables.c:1433
Definition: name.c:36

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 1687 of file variables.c.

1687  {
1688  int indx = 0;
1689  const xmlChar *name;
1690  const xmlChar *value;
1691 
1692  if (params == NULL)
1693  return(0);
1694  while (params[indx] != NULL) {
1695  name = (const xmlChar *) params[indx++];
1696  value = (const xmlChar *) params[indx++];
1697  if (xsltQuoteOneUserParam(ctxt, name, value) != 0)
1698  return(-1);
1699  }
1700  return 0;
1701 }
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:1743
Definition: name.c:36
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 1915 of file variables.c.

1916  {
1918 
1919  if (ctxt == NULL)
1920  return(NULL);
1921 
1922  elem = xsltStackLookup(ctxt, name, ns_uri);
1923  if (elem == NULL) {
1924  return(xsltGlobalVariableLookup(ctxt, name, ns_uri));
1925  }
1926  if (elem->computed == 0) {
1927 #ifdef WITH_XSLT_DEBUG_VARIABLE
1929  "uncomputed variable %s\n", name));
1930 #endif
1931  elem->value = xsltEvalVariable(ctxt, elem, NULL);
1932  elem->computed = 1;
1933  }
1934  if (elem->value != NULL)
1935  return(xmlXPathObjectCopy(elem->value));
1936 #ifdef WITH_XSLT_DEBUG_VARIABLE
1938  "variable not found %s\n", name));
1939 #endif
1940  return(NULL);
1941 }
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:1868
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:802
Definition: name.c:36
static xsltStackElemPtr xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: variables.c:630

◆ xsltXPathVariableLookup()

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

Definition at line 2238 of file variables.c.

2239  {
2241  xmlXPathObjectPtr valueObj = NULL;
2242 
2243  if ((ctxt == NULL) || (name == NULL))
2244  return(NULL);
2245 
2246 #ifdef WITH_XSLT_DEBUG_VARIABLE
2248  "Lookup variable '%s'\n", name));
2249 #endif
2250 
2251  tctxt = (xsltTransformContextPtr) ctxt;
2252  /*
2253  * Local variables/params ---------------------------------------------
2254  *
2255  * Do the lookup from the top of the stack, but
2256  * don't use params being computed in a call-param
2257  * First lookup expects the variable name and URI to
2258  * come from the disctionnary and hence pointer comparison.
2259  */
2260  if (tctxt->varsNr != 0) {
2261  int i;
2263 
2264  for (i = tctxt->varsNr; i > tctxt->varsBase; i--) {
2265  cur = tctxt->varsTab[i-1];
2266  if ((cur->name == name) && (cur->nameURI == ns_uri)) {
2267 #if 0
2268  stack_addr++;
2269 #endif
2270  variable = cur;
2271  goto local_variable_found;
2272  }
2273  cur = cur->next;
2274  }
2275  /*
2276  * Redo the lookup with interned strings to avoid string comparison.
2277  *
2278  * OPTIMIZE TODO: The problem here is, that if we request a
2279  * global variable, then this will be also executed.
2280  */
2281  {
2282  const xmlChar *tmpName = name, *tmpNsName = ns_uri;
2283 
2284  name = xmlDictLookup(tctxt->dict, name, -1);
2285  if (ns_uri)
2286  ns_uri = xmlDictLookup(tctxt->dict, ns_uri, -1);
2287  if ((tmpName != name) || (tmpNsName != ns_uri)) {
2288  for (i = tctxt->varsNr; i > tctxt->varsBase; i--) {
2289  cur = tctxt->varsTab[i-1];
2290  if ((cur->name == name) && (cur->nameURI == ns_uri)) {
2291 #if 0
2292  stack_cmp++;
2293 #endif
2294  variable = cur;
2295  goto local_variable_found;
2296  }
2297  }
2298  }
2299  }
2300 
2301 local_variable_found:
2302 
2303  if (variable) {
2304  if (variable->computed == 0) {
2305 
2306 #ifdef WITH_XSLT_DEBUG_VARIABLE
2308  "uncomputed variable '%s'\n", name));
2309 #endif
2310  variable->value = xsltEvalVariable(tctxt, variable, NULL);
2311  variable->computed = 1;
2312  }
2313  if (variable->value != NULL) {
2314  valueObj = xmlXPathObjectCopy(variable->value);
2315  }
2316  return(valueObj);
2317  }
2318  }
2319  /*
2320  * Global variables/params --------------------------------------------
2321  */
2322  if (tctxt->globalVars) {
2323  valueObj = xsltGlobalVariableLookup(tctxt, name, ns_uri);
2324  }
2325 
2326  if (valueObj == NULL) {
2327 
2328 #ifdef WITH_XSLT_DEBUG_VARIABLE
2330  "variable not found '%s'\n", name));
2331 #endif
2332 
2333  if (ns_uri) {
2334  xsltTransformError(tctxt, NULL, tctxt->inst,
2335  "Variable '{%s}%s' has not been declared.\n", ns_uri, name);
2336  } else {
2337  xsltTransformError(tctxt, NULL, tctxt->inst,
2338  "Variable '%s' has not been declared.\n", name);
2339  }
2340  } else {
2341 
2342 #ifdef WITH_XSLT_DEBUG_VARIABLE
2344  "found variable '%s'\n", name));
2345 #endif
2346  }
2347 
2348  return(valueObj);
2349 }
Char tmpName[FILE_NAME_LEN]
Definition: bzip2.c:207
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:1868
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:858
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:802
Definition: name.c:36
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