ReactOS 0.4.16-dev-2208-g6350669
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   1
 
#define XSLT_RVT_FUNC_RESULT   2
 
#define XSLT_RVT_GLOBAL   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:2270

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

793{
794 return(xsltAddStackElem(ctxt, elems));
795}
static int xsltAddStackElem(xsltTransformContextPtr ctxt, xsltStackElemPtr elem)
Definition: variables.c:754

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

1279 {
1282
1283 if ((ctxt == NULL) || (ctxt->document == NULL))
1284 return(-1);
1285
1286#ifdef WITH_XSLT_DEBUG_VARIABLE
1288 "Registering global variables\n"));
1289#endif
1290 /*
1291 * Walk the list from the stylesheets and populate the hash table
1292 */
1293 style = ctxt->style;
1294 while (style != NULL) {
1295 elem = style->variables;
1296
1297#ifdef WITH_XSLT_DEBUG_VARIABLE
1298 if ((style->doc != NULL) && (style->doc->URL != NULL)) {
1300 "Registering global variables from %s\n",
1301 style->doc->URL));
1302 }
1303#endif
1304
1305 while (elem != NULL) {
1306 xsltStackElemPtr def;
1307
1308 /*
1309 * Global variables are stored in the variables pool.
1310 */
1311 def = (xsltStackElemPtr)
1313 elem->name, elem->nameURI);
1314 if (def == NULL) {
1315
1316 def = xsltCopyStackElem(elem);
1317 if (xmlHashAddEntry2(ctxt->globalVars,
1318 elem->name, elem->nameURI, def) < 0) {
1320 "hash update failed\n");
1321 xsltFreeStackElem(def);
1322 return(-1);
1323 }
1324 } else if ((elem->comp != NULL) &&
1325 (elem->comp->type == XSLT_FUNC_VARIABLE)) {
1326 /*
1327 * Redefinition of variables from a different stylesheet
1328 * should not generate a message.
1329 */
1330 if ((elem->comp->inst != NULL) &&
1331 (def->comp != NULL) && (def->comp->inst != NULL) &&
1332 (elem->comp->inst->doc == def->comp->inst->doc))
1333 {
1334 xsltTransformError(ctxt, style, elem->comp->inst,
1335 "Global variable %s already defined\n", elem->name);
1336 if (style != NULL) style->errors++;
1337 }
1338 }
1339 elem = elem->next;
1340 }
1341
1343 }
1344
1345 /*
1346 * This part does the actual evaluation
1347 */
1349
1350 return(0);
1351}
Arabic default style
Definition: afstyles.h:94
#define NULL
Definition: types.h:112
xsltStylesheetPtr xsltNextImport(xsltStylesheetPtr cur)
Definition: imports.c:297
static size_t elem
Definition: string.c:71
void * xmlGenericErrorContext
Definition: globals.c:410
xmlGenericErrorFunc xmlGenericError
Definition: globals.c:396
void xmlHashScan(xmlHashTablePtr hash, xmlHashScanner scan, void *data)
Definition: hash.c:898
void * xmlHashLookup2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2)
Definition: hash.c:754
int xmlHashAddEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, void *payload)
Definition: hash.c:639
xsltStylePreCompPtr comp
xsltDocumentPtr document
xmlHashTablePtr globalVars
xsltStylesheetPtr style
static xsltStackElemPtr xsltCopyStackElem(xsltStackElemPtr elem)
Definition: variables.c:539
static void xsltEvalGlobalVariableWrapper(void *payload, void *data, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: variables.c:1263
static void xsltFreeStackElem(xsltStackElemPtr elem)
Definition: variables.c:565
@ XSLT_FUNC_VARIABLE
xsltStackElem * xsltStackElemPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:762
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:632
void * xsltGenericDebugContext
Definition: xsltutils.c:633
@ XSLT_TRACE_VARIABLES
Definition: xsltutils.h:124
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:132

Referenced by xsltApplyStylesheetInternal().

◆ xsltEvalOneUserParam()

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

Definition at line 1751 of file variables.c.

1753 {
1755 1 /* xpath eval ? */);
1756}
Definition: name.c:39
Definition: pdh_main.c:96
static int xsltProcessUserParamInternal(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value, int eval)
Definition: variables.c:1462

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

1686 {
1687 size_t indx = 0;
1688 const xmlChar *name;
1689 const xmlChar *value;
1690
1691 if (params == NULL)
1692 return(0);
1693 while (params[indx] != NULL) {
1694 name = (const xmlChar *) params[indx++];
1695 value = (const xmlChar *) params[indx++];
1696 if (xsltEvalOneUserParam(ctxt, name, value) != 0)
1697 return(-1);
1698 }
1699 return 0;
1700}
GLenum const GLfloat * params
Definition: glext.h:5645
int xsltEvalOneUserParam(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
Definition: variables.c:1751
unsigned char xmlChar
Definition: xmlstring.h:28

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

2254 {
2256}
void xmlHashFree(xmlHashTablePtr hash, xmlHashDeallocator dealloc)
Definition: hash.c:229
static void xsltFreeStackElemEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: variables.c:614

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

2114 {
2115#ifdef XSLT_REFACTORED
2116 xsltStyleItemParamPtr comp;
2117#else
2119#endif
2120
2121 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
2122 return;
2123
2124#ifdef XSLT_REFACTORED
2125 /*
2126 * Note that xsltStylePreCompute() will be called from
2127 * xslt.c only.
2128 */
2129 comp = (xsltStyleItemParamPtr) cur->psvi;
2130#else
2132 comp = (xsltStylePreCompPtr) cur->psvi;
2133#endif
2134 if (comp == NULL) {
2136 "xsl:param : compilation failed\n");
2137 return;
2138 }
2139
2140 if (comp->name == NULL) {
2142 "xsl:param : missing name attribute\n");
2143 return;
2144 }
2145
2146 /*
2147 * Parse the content (a sequence constructor) of xsl:param.
2148 */
2149 if (cur->children != NULL) {
2150#ifdef XSLT_REFACTORED
2151 xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
2152#else
2154#endif
2155 }
2156
2157#ifdef WITH_XSLT_DEBUG_VARIABLE
2159 "Registering global param %s\n", comp->name);
2160#endif
2161
2162 xsltRegisterGlobalVariable(style, comp->name, comp->ns,
2163 comp->select, cur->children, (xsltStylePreCompPtr) comp,
2164 NULL);
2165}
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2191
FxCollectionEntry * cur
if(dx< 0)
Definition: linetemp.h:194
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:1369
xsltStylePreComp * xsltStylePreCompPtr
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4894

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

2052{
2053#ifdef XSLT_REFACTORED
2054 xsltStyleItemVariablePtr comp;
2055#else
2057#endif
2058
2059 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
2060 return;
2061
2062#ifdef XSLT_REFACTORED
2063 /*
2064 * Note that xsltStylePreCompute() will be called from
2065 * xslt.c only.
2066 */
2067 comp = (xsltStyleItemVariablePtr) cur->psvi;
2068#else
2070 comp = (xsltStylePreCompPtr) cur->psvi;
2071#endif
2072 if (comp == NULL) {
2074 "xsl:variable : compilation failed\n");
2075 return;
2076 }
2077
2078 if (comp->name == NULL) {
2080 "xsl:variable : missing name attribute\n");
2081 return;
2082 }
2083
2084 /*
2085 * Parse the content (a sequence constructor) of xsl:variable.
2086 */
2087 if (cur->children != NULL) {
2088#ifdef XSLT_REFACTORED
2089 xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
2090#else
2092#endif
2093 }
2094#ifdef WITH_XSLT_DEBUG_VARIABLE
2096 "Registering global variable %s\n", comp->name);
2097#endif
2098
2099 xsltRegisterGlobalVariable(style, comp->name, comp->ns,
2100 comp->select, cur->children, (xsltStylePreCompPtr) comp,
2101 NULL);
2102}

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

1990{
1991#ifdef XSLT_REFACTORED
1992 xsltStyleBasicItemVariablePtr comp;
1993#else
1995#endif
1996 xmlNodePtr tree = NULL; /* The first child node of the instruction or
1997 the instruction itself. */
1999
2000 if ((ctxt == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
2001 return(NULL);
2002
2003#ifdef XSLT_REFACTORED
2004 comp = (xsltStyleBasicItemVariablePtr) inst->psvi;
2005#else
2006 comp = (xsltStylePreCompPtr) inst->psvi;
2007#endif
2008
2009 if (comp == NULL) {
2010 xsltTransformError(ctxt, NULL, inst,
2011 "Internal error in xsltParseStylesheetCallerParam(): "
2012 "The XSLT 'with-param' instruction was not compiled.\n");
2013 return(NULL);
2014 }
2015 if (comp->name == NULL) {
2016 xsltTransformError(ctxt, NULL, inst,
2017 "Internal error in xsltParseStylesheetCallerParam(): "
2018 "XSLT 'with-param': The attribute 'name' was not compiled.\n");
2019 return(NULL);
2020 }
2021
2022#ifdef WITH_XSLT_DEBUG_VARIABLE
2024 "Handling xsl:with-param %s\n", comp->name));
2025#endif
2026
2027 if (comp->select == NULL) {
2028 tree = inst->children;
2029 } else {
2030#ifdef WITH_XSLT_DEBUG_VARIABLE
2032 " select %s\n", comp->select));
2033#endif
2034 tree = inst;
2035 }
2036
2038
2039 return(param);
2040}
GLfloat param
Definition: glext.h:5796
static xsltStackElemPtr xsltBuildVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree)
Definition: variables.c:1790

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

2219{
2220#ifdef XSLT_REFACTORED
2221 xsltStyleItemParamPtr comp;
2222#else
2224#endif
2225
2226 if ((cur == NULL) || (ctxt == NULL) || (cur->type != XML_ELEMENT_NODE))
2227 return;
2228
2229 comp = cur->psvi;
2230 if ((comp == NULL) || (comp->name == NULL)) {
2232 "Internal error in xsltParseStylesheetParam(): "
2233 "The XSLT 'param' declaration was not compiled correctly.\n");
2234 return;
2235 }
2236
2237#ifdef WITH_XSLT_DEBUG_VARIABLE
2239 "Registering param %s\n", comp->name));
2240#endif
2241
2242 xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, cur->children, 1);
2243}
static int xsltRegisterVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree, int isParam)
Definition: variables.c:1837

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

2177{
2178#ifdef XSLT_REFACTORED
2179 xsltStyleItemVariablePtr comp;
2180#else
2182#endif
2183
2184 if ((inst == NULL) || (ctxt == NULL) || (inst->type != XML_ELEMENT_NODE))
2185 return;
2186
2187 comp = inst->psvi;
2188 if (comp == NULL) {
2189 xsltTransformError(ctxt, NULL, inst,
2190 "Internal error in xsltParseStylesheetVariable(): "
2191 "The XSLT 'variable' instruction was not compiled.\n");
2192 return;
2193 }
2194 if (comp->name == NULL) {
2195 xsltTransformError(ctxt, NULL, inst,
2196 "Internal error in xsltParseStylesheetVariable(): "
2197 "The attribute 'name' was not compiled.\n");
2198 return;
2199 }
2200
2201#ifdef WITH_XSLT_DEBUG_VARIABLE
2203 "Registering variable '%s'\n", comp->name));
2204#endif
2205
2206 xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, inst->children, 0);
2207}

Referenced by xsltApplySequenceConstructor().

◆ xsltQuoteOneUserParam()

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

Definition at line 1772 of file variables.c.

1774 {
1776 0 /* xpath eval ? */);
1777}

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

1716 {
1717 size_t indx = 0;
1718 const xmlChar *name;
1719 const xmlChar *value;
1720
1721 if (params == NULL)
1722 return(0);
1723 while (params[indx] != NULL) {
1724 name = (const xmlChar *) params[indx++];
1725 value = (const xmlChar *) params[indx++];
1726 if (xsltQuoteOneUserParam(ctxt, name, value) != 0)
1727 return(-1);
1728 }
1729 return 0;
1730}
int xsltQuoteOneUserParam(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
Definition: variables.c:1772

Referenced by node_transform_node_params().

◆ xsltVariableLookup()

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

Definition at line 1947 of file variables.c.

1948 {
1950
1951 if (ctxt == NULL)
1952 return(NULL);
1953
1954 elem = xsltStackLookup(ctxt, name, ns_uri);
1955 if (elem == NULL) {
1956 return(xsltGlobalVariableLookup(ctxt, name, ns_uri));
1957 }
1958 if (elem->computed == 0) {
1959#ifdef WITH_XSLT_DEBUG_VARIABLE
1961 "uncomputed variable %s\n", name));
1962#endif
1963 elem->value = xsltEvalVariable(ctxt, elem, NULL);
1964 elem->computed = 1;
1965 }
1966 if (elem->value != NULL)
1967 return(xmlXPathObjectCopy(elem->value));
1968#ifdef WITH_XSLT_DEBUG_VARIABLE
1970 "variable not found %s\n", name));
1971#endif
1972 return(NULL);
1973}
static xmlXPathObjectPtr xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr variable, xsltStylePreCompPtr castedComp)
Definition: variables.c:814
static xmlXPathObjectPtr xsltGlobalVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri)
Definition: variables.c:1900
static xsltStackElemPtr xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: variables.c:650

◆ xsltXPathVariableLookup()

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

Definition at line 2270 of file variables.c.

2271 {
2273 xmlXPathObjectPtr valueObj = NULL;
2274
2275 if ((ctxt == NULL) || (name == NULL))
2276 return(NULL);
2277
2278#ifdef WITH_XSLT_DEBUG_VARIABLE
2280 "Lookup variable '%s'\n", name));
2281#endif
2282
2283 tctxt = (xsltTransformContextPtr) ctxt;
2284 /*
2285 * Local variables/params ---------------------------------------------
2286 *
2287 * Do the lookup from the top of the stack, but
2288 * don't use params being computed in a call-param
2289 * First lookup expects the variable name and URI to
2290 * come from the disctionnary and hence pointer comparison.
2291 */
2292 if (tctxt->varsNr != 0) {
2293 int i;
2295
2296 for (i = tctxt->varsNr; i > tctxt->varsBase; i--) {
2297 cur = tctxt->varsTab[i-1];
2298 if ((cur->name == name) && (cur->nameURI == ns_uri)) {
2299#if 0
2300 stack_addr++;
2301#endif
2302 variable = cur;
2303 goto local_variable_found;
2304 }
2305 cur = cur->next;
2306 }
2307 /*
2308 * Redo the lookup with interned strings to avoid string comparison.
2309 *
2310 * OPTIMIZE TODO: The problem here is, that if we request a
2311 * global variable, then this will be also executed.
2312 */
2313 {
2314 const xmlChar *tmpName = name, *tmpNsName = ns_uri;
2315
2316 name = xmlDictLookup(tctxt->dict, name, -1);
2317 if (ns_uri)
2318 ns_uri = xmlDictLookup(tctxt->dict, ns_uri, -1);
2319 if ((tmpName != name) || (tmpNsName != ns_uri)) {
2320 for (i = tctxt->varsNr; i > tctxt->varsBase; i--) {
2321 cur = tctxt->varsTab[i-1];
2322 if ((cur->name == name) && (cur->nameURI == ns_uri)) {
2323#if 0
2324 stack_cmp++;
2325#endif
2326 variable = cur;
2327 goto local_variable_found;
2328 }
2329 }
2330 }
2331 }
2332
2333local_variable_found:
2334
2335 if (variable) {
2336 if (variable->computed == 0) {
2337
2338#ifdef WITH_XSLT_DEBUG_VARIABLE
2340 "uncomputed variable '%s'\n", name));
2341#endif
2342 variable->value = xsltEvalVariable(tctxt, variable, NULL);
2343 variable->computed = 1;
2344 }
2345 if (variable->value != NULL) {
2346 valueObj = xmlXPathObjectCopy(variable->value);
2347 }
2348 return(valueObj);
2349 }
2350 }
2351 /*
2352 * Global variables/params --------------------------------------------
2353 */
2354 if (tctxt->globalVars) {
2355 valueObj = xsltGlobalVariableLookup(tctxt, name, ns_uri);
2356 }
2357
2358 if (valueObj == NULL) {
2359
2360#ifdef WITH_XSLT_DEBUG_VARIABLE
2362 "variable not found '%s'\n", name));
2363#endif
2364
2365 if (ns_uri) {
2366 xsltTransformError(tctxt, NULL, tctxt->inst,
2367 "Variable '{%s}%s' has not been declared.\n", ns_uri, name);
2368 } else {
2369 xsltTransformError(tctxt, NULL, tctxt->inst,
2370 "Variable '%s' has not been declared.\n", name);
2371 }
2372 } else {
2373
2374#ifdef WITH_XSLT_DEBUG_VARIABLE
2376 "found variable '%s'\n", name));
2377#endif
2378 }
2379
2380 return(valueObj);
2381}
GLenum GLenum variable
Definition: glext.h:9031
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
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
xsltStackElemPtr * varsTab
xsltTransformContext * xsltTransformContextPtr