ReactOS 0.4.15-dev-5893-g1bb4167
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:2243

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

778{
779 return(xsltAddStackElem(ctxt, elems));
780}
static int xsltAddStackElem(xsltTransformContextPtr ctxt, xsltStackElemPtr elem)
Definition: variables.c:731

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

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

Referenced by xsltApplyStylesheetInternal().

◆ xsltEvalOneUserParam()

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

Definition at line 1727 of file variables.c.

1729 {
1731 1 /* xpath eval ? */);
1732}
Definition: name.c:39
Definition: pdh_main.c:94
static int xsltProcessUserParamInternal(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value, int eval)
Definition: variables.c:1438

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

1662 {
1663 int indx = 0;
1664 const xmlChar *name;
1665 const xmlChar *value;
1666
1667 if (params == NULL)
1668 return(0);
1669 while (params[indx] != NULL) {
1670 name = (const xmlChar *) params[indx++];
1671 value = (const xmlChar *) params[indx++];
1672 if (xsltEvalOneUserParam(ctxt, name, value) != 0)
1673 return(-1);
1674 }
1675 return 0;
1676}
GLenum const GLfloat * params
Definition: glext.h:5645
int xsltEvalOneUserParam(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
Definition: variables.c:1727
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 2227 of file variables.c.

2227 {
2229}
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:322
static void xsltFreeStackElemEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: variables.c:591

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

2087 {
2088#ifdef XSLT_REFACTORED
2089 xsltStyleItemParamPtr comp;
2090#else
2092#endif
2093
2094 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
2095 return;
2096
2097#ifdef XSLT_REFACTORED
2098 /*
2099 * Note that xsltStylePreCompute() will be called from
2100 * xslt.c only.
2101 */
2102 comp = (xsltStyleItemParamPtr) cur->psvi;
2103#else
2105 comp = (xsltStylePreCompPtr) cur->psvi;
2106#endif
2107 if (comp == NULL) {
2109 "xsl:param : compilation failed\n");
2110 return;
2111 }
2112
2113 if (comp->name == NULL) {
2115 "xsl:param : missing name attribute\n");
2116 return;
2117 }
2118
2119 /*
2120 * Parse the content (a sequence constructor) of xsl:param.
2121 */
2122 if (cur->children != NULL) {
2123#ifdef XSLT_REFACTORED
2124 xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
2125#else
2127#endif
2128 }
2129
2130#ifdef WITH_XSLT_DEBUG_VARIABLE
2132 "Registering global param %s\n", comp->name);
2133#endif
2134
2135 xsltRegisterGlobalVariable(style, comp->name, comp->ns,
2136 comp->select, cur->children, (xsltStylePreCompPtr) comp,
2137 NULL);
2138}
void xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst)
Definition: preproc.c:2177
FxCollectionEntry * cur
if(dx< 0)
Definition: linetemp.h:194
@ XML_ELEMENT_NODE
Definition: tree.h:160
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:1345
xsltStylePreComp * xsltStylePreCompPtr
void xsltParseTemplateContent(xsltStylesheetPtr style, xmlNodePtr templ)
Definition: xslt.c:4878

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

2025{
2026#ifdef XSLT_REFACTORED
2027 xsltStyleItemVariablePtr comp;
2028#else
2030#endif
2031
2032 if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE))
2033 return;
2034
2035#ifdef XSLT_REFACTORED
2036 /*
2037 * Note that xsltStylePreCompute() will be called from
2038 * xslt.c only.
2039 */
2040 comp = (xsltStyleItemVariablePtr) cur->psvi;
2041#else
2043 comp = (xsltStylePreCompPtr) cur->psvi;
2044#endif
2045 if (comp == NULL) {
2047 "xsl:variable : compilation failed\n");
2048 return;
2049 }
2050
2051 if (comp->name == NULL) {
2053 "xsl:variable : missing name attribute\n");
2054 return;
2055 }
2056
2057 /*
2058 * Parse the content (a sequence constructor) of xsl:variable.
2059 */
2060 if (cur->children != NULL) {
2061#ifdef XSLT_REFACTORED
2062 xsltParseSequenceConstructor(XSLT_CCTXT(style), cur->children);
2063#else
2065#endif
2066 }
2067#ifdef WITH_XSLT_DEBUG_VARIABLE
2069 "Registering global variable %s\n", comp->name);
2070#endif
2071
2072 xsltRegisterGlobalVariable(style, comp->name, comp->ns,
2073 comp->select, cur->children, (xsltStylePreCompPtr) comp,
2074 NULL);
2075}

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

1963{
1964#ifdef XSLT_REFACTORED
1965 xsltStyleBasicItemVariablePtr comp;
1966#else
1968#endif
1969 xmlNodePtr tree = NULL; /* The first child node of the instruction or
1970 the instruction itself. */
1972
1973 if ((ctxt == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
1974 return(NULL);
1975
1976#ifdef XSLT_REFACTORED
1977 comp = (xsltStyleBasicItemVariablePtr) inst->psvi;
1978#else
1979 comp = (xsltStylePreCompPtr) inst->psvi;
1980#endif
1981
1982 if (comp == NULL) {
1983 xsltTransformError(ctxt, NULL, inst,
1984 "Internal error in xsltParseStylesheetCallerParam(): "
1985 "The XSLT 'with-param' instruction was not compiled.\n");
1986 return(NULL);
1987 }
1988 if (comp->name == NULL) {
1989 xsltTransformError(ctxt, NULL, inst,
1990 "Internal error in xsltParseStylesheetCallerParam(): "
1991 "XSLT 'with-param': The attribute 'name' was not compiled.\n");
1992 return(NULL);
1993 }
1994
1995#ifdef WITH_XSLT_DEBUG_VARIABLE
1997 "Handling xsl:with-param %s\n", comp->name));
1998#endif
1999
2000 if (comp->select == NULL) {
2001 tree = inst->children;
2002 } else {
2003#ifdef WITH_XSLT_DEBUG_VARIABLE
2005 " select %s\n", comp->select));
2006#endif
2007 tree = inst;
2008 }
2009
2011
2012 return(param);
2013}
GLfloat param
Definition: glext.h:5796
Definition: tree.h:489
struct _xmlNode * children
Definition: tree.h:493
void * psvi
Definition: tree.h:505
xmlElementType type
Definition: tree.h:491
static xsltStackElemPtr xsltBuildVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree)
Definition: variables.c:1766

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

2192{
2193#ifdef XSLT_REFACTORED
2194 xsltStyleItemParamPtr comp;
2195#else
2197#endif
2198
2199 if ((cur == NULL) || (ctxt == NULL) || (cur->type != XML_ELEMENT_NODE))
2200 return;
2201
2202 comp = cur->psvi;
2203 if ((comp == NULL) || (comp->name == NULL)) {
2205 "Internal error in xsltParseStylesheetParam(): "
2206 "The XSLT 'param' declaration was not compiled correctly.\n");
2207 return;
2208 }
2209
2210#ifdef WITH_XSLT_DEBUG_VARIABLE
2212 "Registering param %s\n", comp->name));
2213#endif
2214
2215 xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, cur->children, 1);
2216}
static int xsltRegisterVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree, int isParam)
Definition: variables.c:1813

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

2150{
2151#ifdef XSLT_REFACTORED
2152 xsltStyleItemVariablePtr comp;
2153#else
2155#endif
2156
2157 if ((inst == NULL) || (ctxt == NULL) || (inst->type != XML_ELEMENT_NODE))
2158 return;
2159
2160 comp = inst->psvi;
2161 if (comp == NULL) {
2162 xsltTransformError(ctxt, NULL, inst,
2163 "Internal error in xsltParseStylesheetVariable(): "
2164 "The XSLT 'variable' instruction was not compiled.\n");
2165 return;
2166 }
2167 if (comp->name == NULL) {
2168 xsltTransformError(ctxt, NULL, inst,
2169 "Internal error in xsltParseStylesheetVariable(): "
2170 "The attribute 'name' was not compiled.\n");
2171 return;
2172 }
2173
2174#ifdef WITH_XSLT_DEBUG_VARIABLE
2176 "Registering variable '%s'\n", comp->name));
2177#endif
2178
2179 xsltRegisterVariable(ctxt, (xsltStylePreCompPtr) comp, inst->children, 0);
2180}

Referenced by xsltApplySequenceConstructor().

◆ xsltQuoteOneUserParam()

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

Definition at line 1748 of file variables.c.

1750 {
1752 0 /* xpath eval ? */);
1753}

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

1692 {
1693 int indx = 0;
1694 const xmlChar *name;
1695 const xmlChar *value;
1696
1697 if (params == NULL)
1698 return(0);
1699 while (params[indx] != NULL) {
1700 name = (const xmlChar *) params[indx++];
1701 value = (const xmlChar *) params[indx++];
1702 if (xsltQuoteOneUserParam(ctxt, name, value) != 0)
1703 return(-1);
1704 }
1705 return 0;
1706}
int xsltQuoteOneUserParam(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
Definition: variables.c:1748

◆ xsltVariableLookup()

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

Definition at line 1920 of file variables.c.

1921 {
1923
1924 if (ctxt == NULL)
1925 return(NULL);
1926
1927 elem = xsltStackLookup(ctxt, name, ns_uri);
1928 if (elem == NULL) {
1929 return(xsltGlobalVariableLookup(ctxt, name, ns_uri));
1930 }
1931 if (elem->computed == 0) {
1932#ifdef WITH_XSLT_DEBUG_VARIABLE
1934 "uncomputed variable %s\n", name));
1935#endif
1936 elem->value = xsltEvalVariable(ctxt, elem, NULL);
1937 elem->computed = 1;
1938 }
1939 if (elem->value != NULL)
1940 return(xmlXPathObjectCopy(elem->value));
1941#ifdef WITH_XSLT_DEBUG_VARIABLE
1943 "variable not found %s\n", name));
1944#endif
1945 return(NULL);
1946}
static xmlXPathObjectPtr xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr variable, xsltStylePreCompPtr castedComp)
Definition: variables.c:799
static xmlXPathObjectPtr xsltGlobalVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri)
Definition: variables.c:1873
static xsltStackElemPtr xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: variables.c:627

◆ xsltXPathVariableLookup()

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

Definition at line 2243 of file variables.c.

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