ReactOS  0.4.15-dev-1203-g0e5a4d5
variables.c File Reference
#include "precomp.h"
Include dependency graph for variables.c:

Go to the source code of this file.

Macros

#define XSLT_VAR_GLOBAL   (1<<0)
 
#define XSLT_VAR_IN_SELECT   (1<<1)
 
#define XSLT_TCTXT_VARIABLE(c)   ((xsltStackElemPtr) (c)->contextVariable)
 

Functions

xmlDocPtr xsltCreateRVT (xsltTransformContextPtr ctxt)
 
int xsltRegisterTmpRVT (xsltTransformContextPtr ctxt, xmlDocPtr RVT)
 
int xsltRegisterLocalRVT (xsltTransformContextPtr ctxt, xmlDocPtr RVT)
 
int xsltExtensionInstructionResultFinalize (xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED)
 
int xsltExtensionInstructionResultRegister (xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED, xmlXPathObjectPtr obj ATTRIBUTE_UNUSED)
 
int xsltFlagRVTs (xsltTransformContextPtr ctxt, xmlXPathObjectPtr obj, void *val)
 
void xsltReleaseRVT (xsltTransformContextPtr ctxt, xmlDocPtr RVT)
 
int xsltRegisterPersistRVT (xsltTransformContextPtr ctxt, xmlDocPtr RVT)
 
void xsltFreeRVTs (xsltTransformContextPtr ctxt)
 
static xsltStackElemPtr xsltNewStackElem (xsltTransformContextPtr ctxt)
 
static xsltStackElemPtr xsltCopyStackElem (xsltStackElemPtr elem)
 
static void xsltFreeStackElem (xsltStackElemPtr elem)
 
static void xsltFreeStackElemEntry (void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
 
void xsltFreeStackElemList (xsltStackElemPtr elem)
 
: the local part of the name

xsltStackLookup: @ctxt: an XSLT transformation context

@nameURI: the URI part of the name

Locate an element in the stack based on its name.

static xsltStackElemPtr xsltStackLookup (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
 
: the variable name

xsltXPathVariableLookup: @ctxt: a void * but the the XSLT transformation context actually

@ns_uri: the variable namespace URI

This is the entry point when a varibale is needed by the XPath interpretor.

Returns the value or NULL if not found

static int xsltCheckStackElem (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
 
static int xsltAddStackElem (xsltTransformContextPtr ctxt, xsltStackElemPtr elem)
 
int xsltAddStackElemList (xsltTransformContextPtr ctxt, xsltStackElemPtr elems)
 
static xmlXPathObjectPtr xsltEvalVariable (xsltTransformContextPtr ctxt, xsltStackElemPtr variable, xsltStylePreCompPtr castedComp)
 
static xmlXPathObjectPtr xsltEvalGlobalVariable (xsltStackElemPtr elem, xsltTransformContextPtr ctxt)
 
static void xsltEvalGlobalVariableWrapper (void *payload, void *data, const xmlChar *name ATTRIBUTE_UNUSED)
 
int xsltEvalGlobalVariables (xsltTransformContextPtr ctxt)
 
static int xsltRegisterGlobalVariable (xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns_uri, const xmlChar *sel, xmlNodePtr tree, xsltStylePreCompPtr comp, const xmlChar *value)
 
static xmlXPathObjectPtr xsltGlobalVariableLookup (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri)
 
xmlXPathObjectPtr xsltVariableLookup (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri)
 
xsltStackElemPtr xsltParseStylesheetCallerParam (xsltTransformContextPtr ctxt, xmlNodePtr inst)
 
void xsltParseGlobalVariable (xsltStylesheetPtr style, xmlNodePtr cur)
 
void xsltParseGlobalParam (xsltStylesheetPtr style, xmlNodePtr cur)
 
void xsltParseStylesheetVariable (xsltTransformContextPtr ctxt, xmlNodePtr inst)
 
void xsltParseStylesheetParam (xsltTransformContextPtr ctxt, xmlNodePtr cur)
 
void xsltFreeGlobalVariables (xsltTransformContextPtr ctxt)
 
xmlXPathObjectPtr xsltXPathVariableLookup (void *ctxt, const xmlChar *name, const xmlChar *ns_uri)
 
: a null terminated parameter name

xsltProcessUserParamInternal

@ctxt: the XSLT transformation context

@value: a null terminated value (may be an XPath expression) @eval: 0 to treat the value literally, else evaluate as XPath expression

If @eval is 0 then @value is treated literally and is stored in the global parameter/variable table without any change.

Uf @eval is 1 then @value is treated as an XPath expression and is evaluated. In this case, if you want to pass a string which will be interpreted literally then it must be enclosed in single or double quotes. If the string contains single quotes (double quotes) then it cannot be enclosed single quotes (double quotes). If the string which you want to be treated literally contains both single and double quotes (e.g. Meet at Joe's for "Twelfth Night" at 7 o'clock) then there is no suitable quoting character. You cannot use ' or " inside the string because the replacement of character entities with their equivalents is done at a different stage of processing. The solution is to call xsltQuoteUserParams or xsltQuoteOneUserParam.

This needs to be done on parsed stylesheets before starting to apply transformations. Normally this will be called (directly or indirectly) only from xsltEvalUserParams, xsltEvalOneUserParam, xsltQuoteUserParams, or xsltQuoteOneUserParam.

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

static int xsltProcessUserParamInternal (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value, int eval)
 
int xsltEvalUserParams (xsltTransformContextPtr ctxt, const char **params)
 
int xsltQuoteUserParams (xsltTransformContextPtr ctxt, const char **params)
 
: a null terminated string giving the name of the parameter

xsltQuoteOneUserParam: @ctxt: the XSLT transformation context

@value: a null terminated string giving the parameter value

This is normally called from xsltQuoteUserParams to process a single parameter from a list of parameters. The @value is stored in the context's global variable/parameter hash table.

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

int xsltEvalOneUserParam (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
 
int xsltQuoteOneUserParam (xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *value)
 
static xsltStackElemPtr xsltBuildVariable (xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree)
 
static int xsltRegisterVariable (xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree, int isParam)
 

Variables

static const xmlCharxsltComputingGlobalVarMarker
 

Macro Definition Documentation

◆ XSLT_TCTXT_VARIABLE

#define XSLT_TCTXT_VARIABLE (   c)    ((xsltStackElemPtr) (c)->contextVariable)

Definition at line 27 of file variables.c.

◆ XSLT_VAR_GLOBAL

#define XSLT_VAR_GLOBAL   (1<<0)

Definition at line 25 of file variables.c.

◆ XSLT_VAR_IN_SELECT

#define XSLT_VAR_IN_SELECT   (1<<1)

Definition at line 26 of file variables.c.

Function Documentation

◆ xsltAddStackElem()

static int xsltAddStackElem ( xsltTransformContextPtr  ctxt,
xsltStackElemPtr  elem 
)
static

xsltAddStackElem: @ctxt: xn XSLT transformation context @elem: a stack element

Push an element (or list) onto the stack. In case of a list, each member will be pushed into a seperate slot; i.e. there's always 1 stack entry for 1 stack element.

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

Definition at line 736 of file variables.c.

737 {
738  if ((ctxt == NULL) || (elem == NULL))
739  return(-1);
740 
741  do {
742  if (ctxt->varsMax == 0) {
743  ctxt->varsMax = 10;
744  ctxt->varsTab =
746  sizeof(ctxt->varsTab[0]));
747  if (ctxt->varsTab == NULL) {
748  xmlGenericError(xmlGenericErrorContext, "malloc failed !\n");
749  return (-1);
750  }
751  }
752  if (ctxt->varsNr >= ctxt->varsMax) {
753  ctxt->varsMax *= 2;
754  ctxt->varsTab =
756  ctxt->varsMax *
757  sizeof(ctxt->varsTab[0]));
758  if (ctxt->varsTab == NULL) {
759  xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
760  return (-1);
761  }
762  }
763  ctxt->varsTab[ctxt->varsNr++] = elem;
764  ctxt->vars = elem;
765 
766  elem = elem->next;
767  } while (elem != NULL);
768 
769  return(0);
770 }
xsltStackElemPtr vars
static size_t elem
Definition: string.c:68
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
xsltStackElemPtr * varsTab
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xsltAddStackElemList(), and xsltRegisterVariable().

◆ xsltAddStackElemList()

int 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

◆ xsltBuildVariable()

static xsltStackElemPtr xsltBuildVariable ( xsltTransformContextPtr  ctxt,
xsltStylePreCompPtr  castedComp,
xmlNodePtr  tree 
)
static

xsltBuildVariable: @ctxt: the XSLT transformation context @comp: the precompiled form @tree: the tree if select is NULL

Computes a new variable value.

Returns the xsltStackElemPtr or NULL in case of error

Definition at line 1763 of file variables.c.

1766 {
1767 #ifdef XSLT_REFACTORED
1768  xsltStyleBasicItemVariablePtr comp =
1769  (xsltStyleBasicItemVariablePtr) castedComp;
1770 #else
1771  xsltStylePreCompPtr comp = castedComp;
1772 #endif
1774 
1775 #ifdef WITH_XSLT_DEBUG_VARIABLE
1777  "Building variable %s", comp->name));
1778  if (comp->select != NULL)
1780  " select %s", comp->select));
1782 #endif
1783 
1784  elem = xsltNewStackElem(ctxt);
1785  if (elem == NULL)
1786  return(NULL);
1787  elem->comp = (xsltStylePreCompPtr) comp;
1788  elem->name = comp->name;
1789  elem->select = comp->select;
1790  elem->nameURI = comp->ns;
1791  elem->tree = tree;
1792  elem->value = xsltEvalVariable(ctxt, elem,
1793  (xsltStylePreCompPtr) comp);
1794  elem->computed = 1;
1795  return(elem);
1796 }
struct _tree tree
const xmlChar * ns
static xsltStackElemPtr xsltNewStackElem(xsltTransformContextPtr ctxt)
Definition: variables.c:485
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xsltStylePreComp * xsltStylePreCompPtr
static xmlXPathObjectPtr xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr variable, xsltStylePreCompPtr castedComp)
Definition: variables.c:804
const xmlChar * name
const xmlChar * select

Referenced by xsltParseStylesheetCallerParam(), and xsltRegisterVariable().

◆ xsltCheckStackElem()

static int xsltCheckStackElem ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar nameURI 
)
static

Definition at line 701 of file variables.c.

702  {
703  xsltStackElemPtr cur;
704 
705  if ((ctxt == NULL) || (name == NULL))
706  return(-1);
707 
708  cur = xsltStackLookup(ctxt, name, nameURI);
709  if (cur == NULL)
710  return(0);
711  if (cur->comp != NULL) {
712  if (cur->comp->type == XSLT_FUNC_WITHPARAM)
713  return(3);
714  else if (cur->comp->type == XSLT_FUNC_PARAM)
715  return(2);
716  }
717 
718  return(1);
719 }
smooth NULL
Definition: ftsmooth.c:416
xsltStyleType type
xsltStylePreCompPtr comp
Definition: name.c:38
static xsltStackElemPtr xsltStackLookup(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: variables.c:632

Referenced by xsltRegisterVariable().

◆ xsltCopyStackElem()

static xsltStackElemPtr xsltCopyStackElem ( xsltStackElemPtr  elem)
static

xsltCopyStackElem: @elem: an XSLT stack element

Makes a copy of the stack element

Returns the copy of NULL

Definition at line 521 of file variables.c.

521  {
522  xsltStackElemPtr cur;
523 
524  cur = (xsltStackElemPtr) xmlMalloc(sizeof(xsltStackElem));
525  if (cur == NULL) {
527  "xsltCopyStackElem : malloc failed\n");
528  return(NULL);
529  }
530  memset(cur, 0, sizeof(xsltStackElem));
531  cur->context = elem->context;
532  cur->name = elem->name;
533  cur->nameURI = elem->nameURI;
534  cur->select = elem->select;
535  cur->tree = elem->tree;
536  cur->comp = elem->comp;
537  return(cur);
538 }
xsltTransformContextPtr context
xmlNodePtr tree
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
const xmlChar * nameURI
xsltStylePreCompPtr comp
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
const xmlChar * select
xsltStackElem * xsltStackElemPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#define memset(x, y, z)
Definition: compat.h:39
const xmlChar * name

Referenced by xsltEvalGlobalVariables().

◆ xsltCreateRVT()

xmlDocPtr xsltCreateRVT ( xsltTransformContextPtr  ctxt)

xsltCreateRVT: @ctxt: an XSLT transformation context

Creates a Result Value Tree (the XSLT 1.0 term for this is "Result Tree Fragment")

Returns the result value tree or NULL in case of API or internal errors.

Definition at line 44 of file variables.c.

45 {
47 
48  /*
49  * Question: Why is this function public?
50  * Answer: It is called by the EXSLT module.
51  */
52  if (ctxt == NULL)
53  return(NULL);
54 
55  /*
56  * Reuse a RTF from the cache if available.
57  */
58  if (ctxt->cache->RVT) {
59  container = ctxt->cache->RVT;
60  ctxt->cache->RVT = (xmlDocPtr) container->next;
61  /* clear the internal pointers */
62  container->next = NULL;
63  container->prev = NULL;
64  if (ctxt->cache->nbRVT > 0)
65  ctxt->cache->nbRVT--;
66 #ifdef XSLT_DEBUG_PROFILE_CACHE
67  ctxt->cache->dbgReusedRVTs++;
68 #endif
69  return(container);
70  }
71 
73  if (container == NULL)
74  return(NULL);
75  container->dict = ctxt->dict;
78  container->doc = container;
79  container->parent = NULL;
80  return(container);
81 }
xsltTransformCachePtr cache
XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict)
Definition: dict.c:645
struct container container
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define XSLT_MARK_RES_TREE_FRAG(n)
Definition: xsltInternals.h:48
xmlDoc * xmlDocPtr
Definition: tree.h:550
Definition: tree.h:551
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)

Referenced by xsltEvalGlobalVariable(), and xsltEvalVariable().

◆ xsltEvalGlobalVariable()

static xmlXPathObjectPtr xsltEvalGlobalVariable ( xsltStackElemPtr  elem,
xsltTransformContextPtr  ctxt 
)
static

xsltEvalGlobalVariable: @elem: the variable or parameter @ctxt: the XSLT transformation context

Evaluates a the value of a global xsl:variable or xsl:param declaration.

Returns the XPath Object value or NULL in case of error

Definition at line 1029 of file variables.c.

1030 {
1031  xmlXPathObjectPtr result = NULL;
1032  xmlNodePtr oldInst;
1033  const xmlChar* oldVarName;
1034 
1035 #ifdef XSLT_REFACTORED
1036  xsltStyleBasicItemVariablePtr comp;
1037 #else
1038  xsltStylePreCompPtr comp;
1039 #endif
1040 
1041  if ((ctxt == NULL) || (elem == NULL))
1042  return(NULL);
1043  if (elem->computed)
1044  return(elem->value);
1045 
1046 
1047 #ifdef WITH_XSLT_DEBUG_VARIABLE
1049  "Evaluating global variable %s\n", elem->name));
1050 #endif
1051 
1052 #ifdef WITH_DEBUGGER
1053  if ((ctxt->debugStatus != XSLT_DEBUG_NONE) &&
1054  elem->comp && elem->comp->inst)
1055  xslHandleDebugger(elem->comp->inst, NULL, NULL, ctxt);
1056 #endif
1057 
1058  oldInst = ctxt->inst;
1059 #ifdef XSLT_REFACTORED
1060  comp = (xsltStyleBasicItemVariablePtr) elem->comp;
1061 #else
1062  comp = elem->comp;
1063 #endif
1064  oldVarName = elem->name;
1066  /*
1067  * OPTIMIZE TODO: We should consider instantiating global vars/params
1068  * on-demand. The vars/params don't need to be evaluated if never
1069  * called; and in the case of global params, if values for such params
1070  * are provided by the user.
1071  */
1072  if (elem->select != NULL) {
1073  xmlXPathCompExprPtr xpExpr = NULL;
1074  xmlDocPtr oldXPDoc;
1075  xmlNodePtr oldXPContextNode;
1076  int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
1077  xmlNsPtr *oldXPNamespaces;
1078  xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
1079 
1080  if ((comp != NULL) && (comp->comp != NULL)) {
1081  xpExpr = comp->comp;
1082  } else {
1083  xpExpr = xmlXPathCtxtCompile(ctxt->xpathCtxt, elem->select);
1084  }
1085  if (xpExpr == NULL)
1086  goto error;
1087 
1088 
1089  if (comp != NULL)
1090  ctxt->inst = comp->inst;
1091  else
1092  ctxt->inst = NULL;
1093  /*
1094  * SPEC XSLT 1.0:
1095  * "At top-level, the expression or template specifying the
1096  * variable value is evaluated with the same context as that used
1097  * to process the root node of the source document: the current
1098  * node is the root node of the source document and the current
1099  * node list is a list containing just the root node of the source
1100  * document."
1101  */
1102  /*
1103  * Save context states.
1104  */
1105  oldXPDoc = xpctxt->doc;
1106  oldXPContextNode = xpctxt->node;
1107  oldXPProximityPosition = xpctxt->proximityPosition;
1108  oldXPContextSize = xpctxt->contextSize;
1109  oldXPNamespaces = xpctxt->namespaces;
1110  oldXPNsNr = xpctxt->nsNr;
1111 
1112  xpctxt->node = ctxt->initialContextNode;
1113  xpctxt->doc = ctxt->initialContextDoc;
1114  xpctxt->contextSize = 1;
1115  xpctxt->proximityPosition = 1;
1116 
1117  if (comp != NULL) {
1118 
1119 #ifdef XSLT_REFACTORED
1120  if (comp->inScopeNs != NULL) {
1121  xpctxt->namespaces = comp->inScopeNs->list;
1122  xpctxt->nsNr = comp->inScopeNs->xpathNumber;
1123  } else {
1124  xpctxt->namespaces = NULL;
1125  xpctxt->nsNr = 0;
1126  }
1127 #else
1128  xpctxt->namespaces = comp->nsList;
1129  xpctxt->nsNr = comp->nsNr;
1130 #endif
1131  } else {
1132  xpctxt->namespaces = NULL;
1133  xpctxt->nsNr = 0;
1134  }
1135 
1136  result = xmlXPathCompiledEval(xpExpr, xpctxt);
1137 
1138  /*
1139  * Restore Context states.
1140  */
1141  xpctxt->doc = oldXPDoc;
1142  xpctxt->node = oldXPContextNode;
1143  xpctxt->contextSize = oldXPContextSize;
1144  xpctxt->proximityPosition = oldXPProximityPosition;
1145  xpctxt->namespaces = oldXPNamespaces;
1146  xpctxt->nsNr = oldXPNsNr;
1147 
1148  if ((comp == NULL) || (comp->comp == NULL))
1149  xmlXPathFreeCompExpr(xpExpr);
1150  if (result == NULL) {
1151  if (comp == NULL)
1152  xsltTransformError(ctxt, NULL, NULL,
1153  "Evaluating global variable %s failed\n", elem->name);
1154  else
1155  xsltTransformError(ctxt, NULL, comp->inst,
1156  "Evaluating global variable %s failed\n", elem->name);
1157  ctxt->state = XSLT_STATE_STOPPED;
1158  goto error;
1159  }
1160 
1161  /*
1162  * Mark all RVTs that are referenced from result as part
1163  * of this variable so they won't be freed too early.
1164  */
1166 
1167 #ifdef WITH_XSLT_DEBUG_VARIABLE
1168 #ifdef LIBXML_DEBUG_ENABLED
1169  if ((xsltGenericDebugContext == stdout) ||
1171  xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
1172  result, 0);
1173 #endif
1174 #endif
1175  } else {
1176  if (elem->tree == NULL) {
1177  result = xmlXPathNewCString("");
1178  } else {
1180  xmlNodePtr oldInsert;
1181  xmlDocPtr oldOutput, oldXPDoc;
1182  /*
1183  * Generate a result tree fragment.
1184  */
1185  container = xsltCreateRVT(ctxt);
1186  if (container == NULL)
1187  goto error;
1188  /*
1189  * Let the lifetime of the tree fragment be handled by
1190  * the Libxslt's garbage collector.
1191  */
1193 
1194  oldOutput = ctxt->output;
1195  oldInsert = ctxt->insert;
1196 
1197  oldXPDoc = ctxt->xpathCtxt->doc;
1198 
1199  ctxt->output = container;
1200  ctxt->insert = (xmlNodePtr) container;
1201 
1202  ctxt->xpathCtxt->doc = ctxt->initialContextDoc;
1203  /*
1204  * Process the sequence constructor.
1205  */
1206  xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree, NULL, NULL);
1207 
1208  ctxt->xpathCtxt->doc = oldXPDoc;
1209 
1210  ctxt->insert = oldInsert;
1211  ctxt->output = oldOutput;
1212 
1213  result = xmlXPathNewValueTree((xmlNodePtr) container);
1214  if (result == NULL) {
1215  result = xmlXPathNewCString("");
1216  } else {
1217  result->boolval = 0; /* Freeing is not handled there anymore */
1218  }
1219 #ifdef WITH_XSLT_DEBUG_VARIABLE
1220 #ifdef LIBXML_DEBUG_ENABLED
1221  if ((xsltGenericDebugContext == stdout) ||
1223  xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
1224  result, 0);
1225 #endif
1226 #endif
1227  }
1228  }
1229 
1230 error:
1231  elem->name = oldVarName;
1232  ctxt->inst = oldInst;
1233  if (result != NULL) {
1234  elem->value = result;
1235  elem->computed = 1;
1236  }
1237  return(result);
1238 }
xmlDocPtr xsltCreateRVT(xsltTransformContextPtr ctxt)
Definition: variables.c:44
int xsltFlagRVTs(xsltTransformContextPtr ctxt, xmlXPathObjectPtr obj, void *val)
Definition: variables.c:237
xmlNodePtr initialContextNode
#define error(str)
Definition: mkdosfs.c:1605
Definition: tree.h:389
#define XSLT_RVT_GLOBAL
Definition: variables.h:62
FILE * stdout
struct _xmlDoc * doc
Definition: tree.h:498
struct _xmlDoc * doc
Definition: tree.h:560
int xsltRegisterPersistRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
Definition: variables.c:399
XSLTPUBFUN void XSLTCALL xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, xsltTransformContextPtr ctxt)
struct container container
xsltTransformState state
static size_t elem
Definition: string.c:68
void xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ ATTRIBUTE_UNUSED, xsltStackElemPtr params)
Definition: transform.c:3315
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
xmlXPathContextPtr xpathCtxt
void * xsltGenericDebugContext
Definition: xsltutils.c:549
if(!(yy_init))
Definition: macro.lex.yy.c:714
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
Definition: tree.h:489
unsigned char xmlChar
Definition: xmlstring.h:28
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
static const xmlChar * xsltComputingGlobalVarMarker
Definition: variables.c:22
xmlXPathCompExprPtr comp
Definition: tree.h:551
FILE * stderr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
GLuint64EXT * result
Definition: glext.h:11304

Referenced by xsltEvalGlobalVariableWrapper(), and xsltGlobalVariableLookup().

◆ xsltEvalGlobalVariables()

int 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().

◆ xsltEvalGlobalVariableWrapper()

static void xsltEvalGlobalVariableWrapper ( void payload,
void data,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 1241 of file variables.c.

1242  {
1245 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static xmlXPathObjectPtr xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt)
Definition: variables.c:1029

Referenced by xsltEvalGlobalVariables().

◆ xsltEvalOneUserParam()

int 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()

int 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().

◆ xsltEvalVariable()

static xmlXPathObjectPtr xsltEvalVariable ( xsltTransformContextPtr  ctxt,
xsltStackElemPtr  variable,
xsltStylePreCompPtr  castedComp 
)
static

xsltEvalVariable: @ctxt: the XSLT transformation context @variable: the variable or parameter item @comp: the compiled XSLT instruction

Evaluate a variable value.

Returns the XPath Object value or NULL in case of error

Definition at line 804 of file variables.c.

806 {
807 #ifdef XSLT_REFACTORED
808  xsltStyleItemVariablePtr comp =
809  (xsltStyleItemVariablePtr) castedComp;
810 #else
811  xsltStylePreCompPtr comp = castedComp;
812 #endif
813  xmlXPathObjectPtr result = NULL;
814  xmlNodePtr oldInst;
815 
816  if ((ctxt == NULL) || (variable == NULL))
817  return(NULL);
818 
819  /*
820  * A variable or parameter are evaluated on demand; thus the
821  * context (of XSLT and XPath) need to be temporarily adjusted and
822  * restored on exit.
823  */
824  oldInst = ctxt->inst;
825 
826 #ifdef WITH_XSLT_DEBUG_VARIABLE
828  "Evaluating variable '%s'\n", variable->name));
829 #endif
830  if (variable->select != NULL) {
831  xmlXPathCompExprPtr xpExpr = NULL;
832  xmlDocPtr oldXPDoc;
833  xmlNodePtr oldXPContextNode;
834  int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
835  xmlNsPtr *oldXPNamespaces;
836  xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
837  xsltStackElemPtr oldVar = ctxt->contextVariable;
838 
839  if ((comp != NULL) && (comp->comp != NULL)) {
840  xpExpr = comp->comp;
841  } else {
842  xpExpr = xmlXPathCtxtCompile(ctxt->xpathCtxt, variable->select);
843  }
844  if (xpExpr == NULL)
845  return(NULL);
846  /*
847  * Save context states.
848  */
849  oldXPDoc = xpctxt->doc;
850  oldXPContextNode = xpctxt->node;
851  oldXPProximityPosition = xpctxt->proximityPosition;
852  oldXPContextSize = xpctxt->contextSize;
853  oldXPNamespaces = xpctxt->namespaces;
854  oldXPNsNr = xpctxt->nsNr;
855 
856  xpctxt->node = ctxt->node;
857  /*
858  * OPTIMIZE TODO: Lame try to set the context doc.
859  * Get rid of this somehow in xpath.c.
860  */
861  if ((ctxt->node->type != XML_NAMESPACE_DECL) &&
862  ctxt->node->doc)
863  xpctxt->doc = ctxt->node->doc;
864  /*
865  * BUG TODO: The proximity position and the context size will
866  * potentially be wrong.
867  * Example:
868  * <xsl:template select="foo">
869  * <xsl:variable name="pos" select="position()"/>
870  * <xsl:for-each select="bar">
871  * <xsl:value-of select="$pos"/>
872  * </xsl:for-each>
873  * </xsl:template>
874  * Here the proximity position and context size are changed
875  * to the context of <xsl:for-each select="bar">, but
876  * the variable needs to be evaluated in the context of
877  * <xsl:template select="foo">.
878  */
879  if (comp != NULL) {
880 
881 #ifdef XSLT_REFACTORED
882  if (comp->inScopeNs != NULL) {
883  xpctxt->namespaces = comp->inScopeNs->list;
884  xpctxt->nsNr = comp->inScopeNs->xpathNumber;
885  } else {
886  xpctxt->namespaces = NULL;
887  xpctxt->nsNr = 0;
888  }
889 #else
890  xpctxt->namespaces = comp->nsList;
891  xpctxt->nsNr = comp->nsNr;
892 #endif
893  } else {
894  xpctxt->namespaces = NULL;
895  xpctxt->nsNr = 0;
896  }
897 
898  /*
899  * We need to mark that we are "selecting" a var's value;
900  * if any tree fragments are created inside the expression,
901  * then those need to be stored inside the variable; otherwise
902  * we'll eventually free still referenced fragments, before
903  * we leave the scope of the variable.
904  */
905  ctxt->contextVariable = variable;
906  variable->flags |= XSLT_VAR_IN_SELECT;
907 
908  result = xmlXPathCompiledEval(xpExpr, xpctxt);
909 
910  variable->flags ^= XSLT_VAR_IN_SELECT;
911  /*
912  * Restore Context states.
913  */
914  ctxt->contextVariable = oldVar;
915 
916  xpctxt->doc = oldXPDoc;
917  xpctxt->node = oldXPContextNode;
918  xpctxt->contextSize = oldXPContextSize;
919  xpctxt->proximityPosition = oldXPProximityPosition;
920  xpctxt->namespaces = oldXPNamespaces;
921  xpctxt->nsNr = oldXPNsNr;
922 
923  if ((comp == NULL) || (comp->comp == NULL))
924  xmlXPathFreeCompExpr(xpExpr);
925  if (result == NULL) {
926  xsltTransformError(ctxt, NULL,
927  (comp != NULL) ? comp->inst : NULL,
928  "Failed to evaluate the expression of variable '%s'.\n",
929  variable->name);
930  ctxt->state = XSLT_STATE_STOPPED;
931 
932 #ifdef WITH_XSLT_DEBUG_VARIABLE
933 #ifdef LIBXML_DEBUG_ENABLED
934  } else {
935  if ((xsltGenericDebugContext == stdout) ||
937  xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
938  result, 0);
939 #endif
940 #endif
941  }
942  } else {
943  if (variable->tree == NULL) {
944  result = xmlXPathNewCString("");
945  } else {
946  if (variable->tree) {
948  xmlNodePtr oldInsert;
949  xmlDocPtr oldOutput;
950  xsltStackElemPtr oldVar = ctxt->contextVariable;
951 
952  /*
953  * Generate a result tree fragment.
954  */
955  container = xsltCreateRVT(ctxt);
956  if (container == NULL)
957  goto error;
958  /*
959  * NOTE: Local Result Tree Fragments of params/variables
960  * are not registered globally anymore; the life-time
961  * is not directly dependant of the param/variable itself.
962  *
963  * OLD: xsltRegisterTmpRVT(ctxt, container);
964  */
965  /*
966  * Attach the Result Tree Fragment to the variable;
967  * when the variable is freed, it will also free
968  * the Result Tree Fragment.
969  */
970  variable->fragment = container;
971  container->psvi = XSLT_RVT_LOCAL;
972 
973  oldOutput = ctxt->output;
974  oldInsert = ctxt->insert;
975 
976  ctxt->output = container;
977  ctxt->insert = (xmlNodePtr) container;
978  ctxt->contextVariable = variable;
979  /*
980  * Process the sequence constructor (variable->tree).
981  * The resulting tree will be held by @container.
982  */
983  xsltApplyOneTemplate(ctxt, ctxt->node, variable->tree,
984  NULL, NULL);
985 
986  ctxt->contextVariable = oldVar;
987  ctxt->insert = oldInsert;
988  ctxt->output = oldOutput;
989 
990  result = xmlXPathNewValueTree((xmlNodePtr) container);
991  }
992  if (result == NULL) {
993  result = xmlXPathNewCString("");
994  } else {
995  /*
996  * Freeing is not handled there anymore.
997  * QUESTION TODO: What does the above comment mean?
998  */
999  result->boolval = 0;
1000  }
1001 #ifdef WITH_XSLT_DEBUG_VARIABLE
1002 #ifdef LIBXML_DEBUG_ENABLED
1003 
1004  if ((xsltGenericDebugContext == stdout) ||
1006  xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
1007  result, 0);
1008 #endif
1009 #endif
1010  }
1011  }
1012 
1013 error:
1014  ctxt->inst = oldInst;
1015  return(result);
1016 }
xmlDocPtr xsltCreateRVT(xsltTransformContextPtr ctxt)
Definition: variables.c:44
#define error(str)
Definition: mkdosfs.c:1605
Definition: tree.h:389
#define XSLT_RVT_LOCAL
Definition: variables.h:46
FILE * stdout
struct _xmlDoc * doc
Definition: tree.h:498
struct _xmlDoc * doc
Definition: tree.h:560
struct container container
xsltTransformState state
void xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr contextNode, xmlNodePtr list, xsltTemplatePtr templ ATTRIBUTE_UNUSED, xsltStackElemPtr params)
Definition: transform.c:3315
smooth NULL
Definition: ftsmooth.c:416
#define XSLT_VAR_IN_SELECT
Definition: variables.c:26
xmlNode * xmlNodePtr
Definition: tree.h:488
xmlXPathContextPtr xpathCtxt
GLenum GLenum variable
Definition: glext.h:9031
void * xsltGenericDebugContext
Definition: xsltutils.c:549
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
xmlXPathCompExprPtr comp
Definition: tree.h:551
FILE * stderr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
GLuint64EXT * result
Definition: glext.h:11304

Referenced by xsltBuildVariable(), xsltVariableLookup(), and xsltXPathVariableLookup().

◆ xsltExtensionInstructionResultFinalize()

int xsltExtensionInstructionResultFinalize ( xsltTransformContextPtr ctxt  ATTRIBUTE_UNUSED)

xsltExtensionInstructionResultFinalize: @ctxt: an XSLT transformation context

Finalizes the data (e.g. result tree fragments) created within a value-returning process (e.g. EXSLT's function). Tree fragments marked as being returned by a function are set to normal state, which means that the fragment garbage collector will free them after the function-calling process exits.

Returns 0 in case of success and -1 in case of API or internal errors.

This function is unsupported in newer releases of libxslt.

Definition at line 187 of file variables.c.

189 {
191  "xsltExtensionInstructionResultFinalize is unsupported "
192  "in this release of libxslt.\n");
193  return(-1);
194 }
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ xsltExtensionInstructionResultRegister()

int xsltExtensionInstructionResultRegister ( xsltTransformContextPtr ctxt  ATTRIBUTE_UNUSED,
xmlXPathObjectPtr obj  ATTRIBUTE_UNUSED 
)

xsltExtensionInstructionResultRegister: @ctxt: an XSLT transformation context @obj: an XPath object to be inspected for result tree fragments

Marks the result of a value-returning extension instruction in order to avoid it being garbage collected before the extension instruction exits. Note that one still has to additionally register any newly created tree fragments (via xsltCreateRVT()) with xsltRegisterLocalRVT().

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

It isn't necessary to call this function in newer releases of libxslt.

Definition at line 213 of file variables.c.

216 {
217  return(0);
218 }

◆ xsltFlagRVTs()

int xsltFlagRVTs ( xsltTransformContextPtr  ctxt,
xmlXPathObjectPtr  obj,
void val 
)

xsltFlagRVTs: @ctxt: an XSLT transformation context @obj: an XPath object to be inspected for result tree fragments @val: the flag value

Updates ownership information of RVTs in @obj according to @val.

@val = XSLT_RVT_FUNC_RESULT for the result of an extension function, so its RVTs won't be destroyed after leaving the returning scope. @val = XSLT_RVT_LOCAL for the result of an extension function to reset the state of its RVTs after it was returned to a new scope. @val = XSLT_RVT_GLOBAL for parts of global variables.

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

Definition at line 237 of file variables.c.

237  {
238  int i;
239  xmlNodePtr cur;
240  xmlDocPtr doc;
241 
242  if ((ctxt == NULL) || (obj == NULL))
243  return(-1);
244 
245  /*
246  * OPTIMIZE TODO: If no local variables/params and no local tree
247  * fragments were created, then we don't need to analyse the XPath
248  * objects for tree fragments.
249  */
250 
251  if ((obj->type != XPATH_NODESET) && (obj->type != XPATH_XSLT_TREE))
252  return(0);
253  if ((obj->nodesetval == NULL) || (obj->nodesetval->nodeNr == 0))
254  return(0);
255 
256  for (i = 0; i < obj->nodesetval->nodeNr; i++) {
257  cur = obj->nodesetval->nodeTab[i];
258  if (cur->type == XML_NAMESPACE_DECL) {
259  /*
260  * The XPath module sets the owner element of a ns-node on
261  * the ns->next field.
262  */
263  if ((((xmlNsPtr) cur)->next != NULL) &&
264  (((xmlNsPtr) cur)->next->type == XML_ELEMENT_NODE))
265  {
266  cur = (xmlNodePtr) ((xmlNsPtr) cur)->next;
267  doc = cur->doc;
268  } else {
269  xsltTransformError(ctxt, NULL, ctxt->inst,
270  "Internal error in xsltFlagRVTs(): "
271  "Cannot retrieve the doc of a namespace node.\n");
272  return(-1);
273  }
274  } else {
275  doc = cur->doc;
276  }
277  if (doc == NULL) {
278  xsltTransformError(ctxt, NULL, ctxt->inst,
279  "Internal error in xsltFlagRVTs(): "
280  "Cannot retrieve the doc of a node.\n");
281  return(-1);
282  }
283  if (doc->name && (doc->name[0] == ' ') &&
284  doc->psvi != XSLT_RVT_GLOBAL) {
285  /*
286  * This is a result tree fragment.
287  * We store ownership information in the @psvi field.
288  * TODO: How do we know if this is a doc acquired via the
289  * document() function?
290  */
291 #ifdef WITH_XSLT_DEBUG_VARIABLE
293  "Flagging RVT %p: %p -> %p\n", doc, doc->psvi, val));
294 #endif
295 
296  if (val == XSLT_RVT_LOCAL) {
297  if (doc->psvi == XSLT_RVT_FUNC_RESULT)
298  doc->psvi = XSLT_RVT_LOCAL;
299  } else if (val == XSLT_RVT_GLOBAL) {
300  if (doc->psvi != XSLT_RVT_LOCAL) {
302  "xsltFlagRVTs: Invalid transition %p => GLOBAL\n",
303  doc->psvi);
304  doc->psvi = XSLT_RVT_GLOBAL;
305  return(-1);
306  }
307 
308  /* Will be registered as persistant in xsltReleaseLocalRVTs. */
309  doc->psvi = XSLT_RVT_GLOBAL;
310  } else if (val == XSLT_RVT_FUNC_RESULT) {
311  doc->psvi = val;
312  }
313  }
314  }
315 
316  return(0);
317 }
char * name
Definition: tree.h:554
Definition: tree.h:389
#define XSLT_RVT_GLOBAL
Definition: variables.h:62
#define XSLT_RVT_LOCAL
Definition: variables.h:46
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
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
GLuint GLfloat * val
Definition: glext.h:7180
void * psvi
Definition: tree.h:581
void * xsltGenericDebugContext
Definition: xsltutils.c:549
#define XSLT_RVT_FUNC_RESULT
Definition: variables.h:55
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 unsigned __int64 next
Definition: rand_nt.c:6
Definition: tree.h:551
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xsltEvalGlobalVariable().

◆ xsltFreeGlobalVariables()

void 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().

◆ xsltFreeRVTs()

void xsltFreeRVTs ( xsltTransformContextPtr  ctxt)

xsltFreeRVTs: @ctxt: an XSLT transformation context

Frees all registered result value trees (Result Tree Fragments) of the transformation. Internal function; should not be called by user-code.

Definition at line 421 of file variables.c.

422 {
423  xmlDocPtr cur, next;
424 
425  if (ctxt == NULL)
426  return;
427  /*
428  * Local fragments.
429  */
430  cur = ctxt->localRVT;
431  while (cur != NULL) {
432  next = (xmlDocPtr) cur->next;
433  if (cur->_private != NULL) {
435  xmlFree(cur->_private);
436  }
437  xmlFreeDoc(cur);
438  cur = next;
439  }
440  ctxt->localRVT = NULL;
441  /*
442  * User-created per-template fragments.
443  */
444  cur = ctxt->tmpRVT;
445  while (cur != NULL) {
446  next = (xmlDocPtr) cur->next;
447  if (cur->_private != NULL) {
449  xmlFree(cur->_private);
450  }
451  xmlFreeDoc(cur);
452  cur = next;
453  }
454  ctxt->tmpRVT = NULL;
455  /*
456  * Global fragments.
457  */
458  cur = ctxt->persistRVT;
459  while (cur != NULL) {
460  next = (xmlDocPtr) cur->next;
461  if (cur->_private != NULL) {
463  xmlFree(cur->_private);
464  }
465  xmlFreeDoc(cur);
466  cur = next;
467  }
468  ctxt->persistRVT = NULL;
469 }
smooth NULL
Definition: ftsmooth.c:416
void * _private
Definition: tree.h:552
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
struct _xmlNode * next
Definition: tree.h:558
void xsltFreeDocumentKeys(xsltDocumentPtr idoc)
Definition: keys.c:925
xmlDoc * xmlDocPtr
Definition: tree.h:550
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: tree.h:551

Referenced by xsltApplyStylesheetInternal(), and xsltFreeTransformContext().

◆ xsltFreeStackElem()

static void xsltFreeStackElem ( xsltStackElemPtr  elem)
static

xsltFreeStackElem: @elem: an XSLT stack element

Free up the memory allocated by @elem

Definition at line 547 of file variables.c.

547  {
548  if (elem == NULL)
549  return;
550  if (elem->value != NULL)
551  xmlXPathFreeObject(elem->value);
552  /*
553  * Release the list of temporary Result Tree Fragments.
554  */
555  if (elem->context) {
556  xmlDocPtr cur;
557 
558  while (elem->fragment != NULL) {
559  cur = elem->fragment;
560  elem->fragment = (xmlDocPtr) cur->next;
561 
562  if (cur->psvi == XSLT_RVT_LOCAL) {
563  xsltReleaseRVT(elem->context, cur);
564  } else if (cur->psvi == XSLT_RVT_FUNC_RESULT) {
565  xsltRegisterLocalRVT(elem->context, cur);
566  cur->psvi = XSLT_RVT_FUNC_RESULT;
567  } else {
569  "xsltFreeStackElem: Unexpected RVT flag %p\n",
570  cur->psvi);
571  }
572  }
573  }
574  /*
575  * Cache or free the variable structure.
576  */
577  if (elem->context && (elem->context->cache->nbStackItems < 50)) {
578  /*
579  * Store the item in the cache.
580  */
581  xsltTransformContextPtr ctxt = elem->context;
582  memset(elem, 0, sizeof(xsltStackElem));
583  elem->context = ctxt;
584  elem->next = ctxt->cache->stackItems;
585  ctxt->cache->stackItems = elem;
586  ctxt->cache->nbStackItems++;
587 #ifdef XSLT_DEBUG_PROFILE_CACHE
588  ctxt->cache->dbgCachedVars++;
589 #endif
590  return;
591  }
592  xmlFree(elem);
593 }
xsltTransformCachePtr cache
void xsltReleaseRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
Definition: variables.c:328
#define XSLT_RVT_LOCAL
Definition: variables.h:46
static size_t elem
Definition: string.c:68
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
void * psvi
Definition: tree.h:581
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define XSLT_RVT_FUNC_RESULT
Definition: variables.h:55
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
struct _xmlNode * next
Definition: tree.h:558
int xsltRegisterLocalRVT(xsltTransformContextPtr ctxt, xmlDocPtr RVT)
Definition: variables.c:138
xmlDoc * xmlDocPtr
Definition: tree.h:550
Definition: tree.h:551
#define memset(x, y, z)
Definition: compat.h:39
xsltStackElemPtr stackItems
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xsltFreeStackElemEntry(), xsltFreeStackElemList(), and xsltProcessUserParamInternal().

◆ xsltFreeStackElemEntry()

static void xsltFreeStackElemEntry ( void payload,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 596 of file variables.c.

596  {
598 }
static void xsltFreeStackElem(xsltStackElemPtr elem)
Definition: variables.c:547

Referenced by xsltFreeGlobalVariables().

◆ xsltFreeStackElemList()

void xsltFreeStackElemList ( xsltStackElemPtr  elem)

xsltFreeStackElemList: @elem: an XSLT stack element

Free up the memory allocated by @elem

Definition at line 608 of file variables.c.

608  {
610 
611  while (elem != NULL) {
612  next = elem->next;
614  elem = next;
615  }
616 }
static void xsltFreeStackElem(xsltStackElemPtr elem)
Definition: variables.c:547
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by xsltApplyStylesheetInternal(), xsltApplyTemplates(), xsltCallTemplate(), xsltFreeStylesheet(), xsltLocalVariablePop(), and xsltTemplateParamsCleanup().

◆ xsltGlobalVariableLookup()

static xmlXPathObjectPtr xsltGlobalVariableLookup ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar ns_uri 
)
static

Definition at line 1870 of file variables.c.

1871  {
1873  xmlXPathObjectPtr ret = NULL;
1874 
1875  /*
1876  * Lookup the global variables in XPath global variable hash table
1877  */
1878  if ((ctxt->xpathCtxt == NULL) || (ctxt->globalVars == NULL))
1879  return(NULL);
1881  xmlHashLookup2(ctxt->globalVars, name, ns_uri);
1882  if (elem == NULL) {
1883 #ifdef WITH_XSLT_DEBUG_VARIABLE
1885  "global variable not found %s\n", name));
1886 #endif
1887  return(NULL);
1888  }
1889  /*
1890  * URGENT TODO: Move the detection of recursive definitions
1891  * to compile-time.
1892  */
1893  if (elem->computed == 0) {
1894  if (elem->name == xsltComputingGlobalVarMarker) {
1895  xsltTransformError(ctxt, NULL, elem->comp->inst,
1896  "Recursive definition of %s\n", name);
1897  return(NULL);
1898  }
1899  ret = xsltEvalGlobalVariable(elem, ctxt);
1900  } else
1901  ret = elem->value;
1902  return(xmlXPathObjectCopy(ret));
1903 }
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
xmlXPathContextPtr xpathCtxt
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
int ret
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
static xmlXPathObjectPtr xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt)
Definition: variables.c:1029
static const xmlChar * xsltComputingGlobalVarMarker
Definition: variables.c:22
Definition: name.c:38
xsltStackElem * xsltStackElemPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
xmlHashTablePtr globalVars

Referenced by xsltVariableLookup(), and xsltXPathVariableLookup().

◆ xsltNewStackElem()

static xsltStackElemPtr xsltNewStackElem ( xsltTransformContextPtr  ctxt)
static

xsltNewStackElem:

Create a new XSLT ParserContext

Returns the newly allocated xsltParserStackElem or NULL in case of error

Definition at line 485 of file variables.c.

486 {
488  /*
489  * Reuse a stack item from the cache if available.
490  */
491  if (ctxt && ctxt->cache->stackItems) {
492  ret = ctxt->cache->stackItems;
493  ctxt->cache->stackItems = ret->next;
494  ret->next = NULL;
495  ctxt->cache->nbStackItems--;
496 #ifdef XSLT_DEBUG_PROFILE_CACHE
497  ctxt->cache->dbgReusedVars++;
498 #endif
499  return(ret);
500  }
502  if (ret == NULL) {
504  "xsltNewStackElem : malloc failed\n");
505  return(NULL);
506  }
507  memset(ret, 0, sizeof(xsltStackElem));
508  ret->context = ctxt;
509  return(ret);
510 }
xsltTransformCachePtr cache
smooth NULL
Definition: ftsmooth.c:416
int ret
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
xsltStackElem * xsltStackElemPtr
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
#define memset(x, y, z)
Definition: compat.h:39
xsltStackElemPtr stackItems

Referenced by xsltBuildVariable(), xsltProcessUserParamInternal(), and xsltRegisterGlobalVariable().

◆ xsltParseGlobalParam()

void 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()

void 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()

xsltStackElemPtr 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()

void 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()

void 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().

◆ xsltProcessUserParamInternal()

static int xsltProcessUserParamInternal ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar value,
int  eval 
)
static

Definition at line 1435 of file variables.c.

1438  {
1439 
1441  const xmlChar *prefix;
1442  const xmlChar *href;
1443  xmlXPathCompExprPtr xpExpr;
1444  xmlXPathObjectPtr result;
1445 
1447  int res;
1448  void *res_ptr;
1449 
1450  if (ctxt == NULL)
1451  return(-1);
1452  if (name == NULL)
1453  return(0);
1454  if (value == NULL)
1455  return(0);
1456 
1457  style = ctxt->style;
1458 
1459 #ifdef WITH_XSLT_DEBUG_VARIABLE
1461  "Evaluating user parameter %s=%s\n", name, value));
1462 #endif
1463 
1464  /*
1465  * Name lookup
1466  */
1467  href = NULL;
1468 
1469  if (name[0] == '{') {
1470  int len = 0;
1471 
1472  while ((name[len] != 0) && (name[len] != '}')) len++;
1473  if (name[len] == 0) {
1474  xsltTransformError(ctxt, style, NULL,
1475  "user param : malformed parameter name : %s\n", name);
1476  } else {
1477  href = xmlDictLookup(ctxt->dict, &name[1], len-1);
1478  name = xmlDictLookup(ctxt->dict, &name[len + 1], -1);
1479  }
1480  }
1481  else {
1482  name = xsltSplitQName(ctxt->dict, name, &prefix);
1483  if (prefix != NULL) {
1484  xmlNsPtr ns;
1485 
1487  prefix);
1488  if (ns == NULL) {
1489  xsltTransformError(ctxt, style, NULL,
1490  "user param : no namespace bound to prefix %s\n", prefix);
1491  href = NULL;
1492  } else {
1493  href = ns->href;
1494  }
1495  }
1496  }
1497 
1498  if (name == NULL)
1499  return (-1);
1500 
1501  res_ptr = xmlHashLookup2(ctxt->globalVars, name, href);
1502  if (res_ptr != 0) {
1503  xsltTransformError(ctxt, style, NULL,
1504  "Global parameter %s already defined\n", name);
1505  }
1506  if (ctxt->globalVars == NULL)
1507  ctxt->globalVars = xmlHashCreate(20);
1508 
1509  /*
1510  * do not overwrite variables with parameters from the command line
1511  */
1512  while (style != NULL) {
1513  elem = ctxt->style->variables;
1514  while (elem != NULL) {
1515  if ((elem->comp != NULL) &&
1516  (elem->comp->type == XSLT_FUNC_VARIABLE) &&
1517  (xmlStrEqual(elem->name, name)) &&
1518  (xmlStrEqual(elem->nameURI, href))) {
1519  return(0);
1520  }
1521  elem = elem->next;
1522  }
1524  }
1525  style = ctxt->style;
1526  elem = NULL;
1527 
1528  /*
1529  * Do the evaluation if @eval is non-zero.
1530  */
1531 
1532  result = NULL;
1533  if (eval != 0) {
1534  xpExpr = xmlXPathCtxtCompile(ctxt->xpathCtxt, value);
1535  if (xpExpr != NULL) {
1536  xmlDocPtr oldXPDoc;
1537  xmlNodePtr oldXPContextNode;
1538  int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
1539  xmlNsPtr *oldXPNamespaces;
1540  xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
1541 
1542  /*
1543  * Save context states.
1544  */
1545  oldXPDoc = xpctxt->doc;
1546  oldXPContextNode = xpctxt->node;
1547  oldXPProximityPosition = xpctxt->proximityPosition;
1548  oldXPContextSize = xpctxt->contextSize;
1549  oldXPNamespaces = xpctxt->namespaces;
1550  oldXPNsNr = xpctxt->nsNr;
1551 
1552  /*
1553  * SPEC XSLT 1.0:
1554  * "At top-level, the expression or template specifying the
1555  * variable value is evaluated with the same context as that used
1556  * to process the root node of the source document: the current
1557  * node is the root node of the source document and the current
1558  * node list is a list containing just the root node of the source
1559  * document."
1560  */
1561  xpctxt->doc = ctxt->initialContextDoc;
1562  xpctxt->node = ctxt->initialContextNode;
1563  xpctxt->contextSize = 1;
1564  xpctxt->proximityPosition = 1;
1565  /*
1566  * There is really no in scope namespace for parameters on the
1567  * command line.
1568  */
1569  xpctxt->namespaces = NULL;
1570  xpctxt->nsNr = 0;
1571 
1572  result = xmlXPathCompiledEval(xpExpr, xpctxt);
1573 
1574  /*
1575  * Restore Context states.
1576  */
1577  xpctxt->doc = oldXPDoc;
1578  xpctxt->node = oldXPContextNode;
1579  xpctxt->contextSize = oldXPContextSize;
1580  xpctxt->proximityPosition = oldXPProximityPosition;
1581  xpctxt->namespaces = oldXPNamespaces;
1582  xpctxt->nsNr = oldXPNsNr;
1583 
1584  xmlXPathFreeCompExpr(xpExpr);
1585  }
1586  if (result == NULL) {
1587  xsltTransformError(ctxt, style, NULL,
1588  "Evaluating user parameter %s failed\n", name);
1589  ctxt->state = XSLT_STATE_STOPPED;
1590  return(-1);
1591  }
1592  }
1593 
1594  /*
1595  * If @eval is 0 then @value is to be taken literally and result is NULL
1596  *
1597  * If @eval is not 0, then @value is an XPath expression and has been
1598  * successfully evaluated and result contains the resulting value and
1599  * is not NULL.
1600  *
1601  * Now create an xsltStackElemPtr for insertion into the context's
1602  * global variable/parameter hash table.
1603  */
1604 
1605 #ifdef WITH_XSLT_DEBUG_VARIABLE
1606 #ifdef LIBXML_DEBUG_ENABLED
1607  if ((xsltGenericDebugContext == stdout) ||
1609  xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
1610  result, 0);
1611 #endif
1612 #endif
1613 
1615  if (elem != NULL) {
1616  elem->name = name;
1617  elem->select = xmlDictLookup(ctxt->dict, value, -1);
1618  if (href != NULL)
1619  elem->nameURI = xmlDictLookup(ctxt->dict, href, -1);
1620  elem->tree = NULL;
1621  elem->computed = 1;
1622  if (eval == 0) {
1623  elem->value = xmlXPathNewString(value);
1624  }
1625  else {
1626  elem->value = result;
1627  }
1628  }
1629 
1630  /*
1631  * Global parameters are stored in the XPath context variables pool.
1632  */
1633 
1634  res = xmlHashAddEntry2(ctxt->globalVars, name, href, elem);
1635  if (res != 0) {
1637  xsltTransformError(ctxt, style, NULL,
1638  "Global parameter %s already defined\n", name);
1639  }
1640  return(0);
1641 }
xmlNodePtr initialContextNode
xsltStackElemPtr variables
Definition: tree.h:389
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
static xsltStackElemPtr xsltNewStackElem(xsltTransformContextPtr ctxt)
Definition: variables.c:485
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
FILE * stdout
struct _xmlDoc * doc
Definition: tree.h:560
static void xsltFreeStackElem(xsltStackElemPtr elem)
Definition: variables.c:547
xsltTransformState state
static size_t elem
Definition: string.c:68
XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace)
smooth NULL
Definition: ftsmooth.c:416
xmlXPathContextPtr xpathCtxt
void * xsltGenericDebugContext
Definition: xsltutils.c:549
const xmlChar * xsltSplitQName(xmlDictPtr dict, const xmlChar *name, const xmlChar **prefix)
Definition: xsltutils.c:720
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreate(int size)
Definition: hash.c:181
Definition: tree.h:489
Definition: mxnamespace.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
xsltStylesheetPtr style
Definition: tree.h:551
Definition: name.c:38
GLuint res
Definition: glext.h:9613
XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement(const xmlDoc *doc)
FILE * stderr
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Arabic default style
Definition: afstyles.h:93
GLuint64EXT * result
Definition: glext.h:11304
xmlHashTablePtr globalVars
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xsltEvalOneUserParam(), and xsltQuoteOneUserParam().

◆ xsltQuoteOneUserParam()

int 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()

int 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

◆ xsltRegisterGlobalVariable()

static int xsltRegisterGlobalVariable ( xsltStylesheetPtr  style,
const xmlChar name,
const xmlChar ns_uri,
const xmlChar sel,
xmlNodePtr  tree,
xsltStylePreCompPtr  comp,
const xmlChar value 
)
static

Definition at line 1342 of file variables.c.

1345  {
1346  xsltStackElemPtr elem, tmp;
1347  if (style == NULL)
1348  return(-1);
1349  if (name == NULL)
1350  return(-1);
1351  if (comp == NULL)
1352  return(-1);
1353 
1354 #ifdef WITH_XSLT_DEBUG_VARIABLE
1355  if (comp->type == XSLT_FUNC_PARAM)
1357  "Defining global param %s\n", name);
1358  else
1360  "Defining global variable %s\n", name);
1361 #endif
1362 
1364  if (elem == NULL)
1365  return(-1);
1366  elem->comp = comp;
1367  elem->name = xmlDictLookup(style->dict, name, -1);
1368  elem->select = xmlDictLookup(style->dict, sel, -1);
1369  if (ns_uri)
1370  elem->nameURI = xmlDictLookup(style->dict, ns_uri, -1);
1371  elem->tree = tree;
1372  tmp = style->variables;
1373  if (tmp == NULL) {
1374  elem->next = NULL;
1375  style->variables = elem;
1376  } else {
1377  while (tmp != NULL) {
1378  if ((elem->comp->type == XSLT_FUNC_VARIABLE) &&
1379  (tmp->comp->type == XSLT_FUNC_VARIABLE) &&
1380  (xmlStrEqual(elem->name, tmp->name)) &&
1381  ((elem->nameURI == tmp->nameURI) ||
1382  (xmlStrEqual(elem->nameURI, tmp->nameURI))))
1383  {
1385  "redefinition of global variable %s\n", elem->name);
1386  style->errors++;
1387  }
1388  if (tmp->next == NULL)
1389  break;
1390  tmp = tmp->next;
1391  }
1392  elem->next = NULL;
1393  tmp->next = elem;
1394  }
1395  if (value != NULL) {
1396  elem->computed = 1;
1397  elem->value = xmlXPathNewString(value);
1398  }
1399  return(0);
1400 }
struct _tree tree
static xsltStackElemPtr xsltNewStackElem(xsltTransformContextPtr ctxt)
Definition: variables.c:485
struct _xsltStackElem * next
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
xsltStyleType type
void * xsltGenericDebugContext
Definition: xsltutils.c:549
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
const xmlChar * nameURI
xsltStylePreCompPtr comp
Definition: name.c:38
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678
Arabic default style
Definition: afstyles.h:93
const xmlChar * name

Referenced by xsltParseGlobalParam(), and xsltParseGlobalVariable().

◆ xsltRegisterLocalRVT()

int xsltRegisterLocalRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

xsltRegisterLocalRVT: @ctxt: an XSLT transformation context @RVT: a result value tree (Result Tree Fragment; xmlDocPtr)

Registers a result value tree (XSLT 1.0 term: Result Tree Fragment) in the RVT garbage collector. The fragment will be freed when the instruction which created the fragment exits.

Returns 0 in case of success and -1 in case of API or internal errors.

Definition at line 138 of file variables.c.

140 {
141  if ((ctxt == NULL) || (RVT == NULL))
142  return(-1);
143 
144  RVT->prev = NULL;
145  RVT->psvi = XSLT_RVT_LOCAL;
146 
147  /*
148  * When evaluating "select" expressions of xsl:variable
149  * and xsl:param, we need to bind newly created tree fragments
150  * to the variable itself; otherwise the fragment will be
151  * freed before we leave the scope of a var.
152  */
153  if ((ctxt->contextVariable != NULL) &&
155  {
156  RVT->next = (xmlNodePtr) XSLT_TCTXT_VARIABLE(ctxt)->fragment;
157  XSLT_TCTXT_VARIABLE(ctxt)->fragment = RVT;
158  return(0);
159  }
160  /*
161  * Store the fragment in the scope of the current instruction.
162  * If not reference by a returning instruction (like EXSLT's function),
163  * then this fragment will be freed, when the instruction exits.
164  */
165  RVT->next = (xmlNodePtr) ctxt->localRVT;
166  if (ctxt->localRVT != NULL)
167  ctxt->localRVT->prev = (xmlNodePtr) RVT;
168  ctxt->localRVT = RVT;
169  return(0);
170 }
#define XSLT_RVT_LOCAL
Definition: variables.h:46
smooth NULL
Definition: ftsmooth.c:416
#define XSLT_VAR_IN_SELECT
Definition: variables.c:26
xmlNode * xmlNodePtr
Definition: tree.h:488
void * psvi
Definition: tree.h:581
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define XSLT_TCTXT_VARIABLE(c)
Definition: variables.c:27
GLbitfield flags
Definition: glext.h:7161
struct _xmlNode * next
Definition: tree.h:558
struct _xmlNode * prev
Definition: tree.h:559

Referenced by xsltFreeStackElem(), and xsltReleaseLocalRVTs().

◆ xsltRegisterPersistRVT()

int xsltRegisterPersistRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

xsltRegisterPersistRVT: @ctxt: an XSLT transformation context @RVT: a result value tree (Result Tree Fragment)

Register the result value tree (XSLT 1.0 term: Result Tree Fragment) in the fragment garbage collector. The fragment will be freed when the transformation context is freed.

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

Definition at line 399 of file variables.c.

400 {
401  if ((ctxt == NULL) || (RVT == NULL)) return(-1);
402 
403  RVT->psvi = XSLT_RVT_GLOBAL;
404  RVT->prev = NULL;
405  RVT->next = (xmlNodePtr) ctxt->persistRVT;
406  if (ctxt->persistRVT != NULL)
407  ctxt->persistRVT->prev = (xmlNodePtr) RVT;
408  ctxt->persistRVT = RVT;
409  return(0);
410 }
#define XSLT_RVT_GLOBAL
Definition: variables.h:62
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
void * psvi
Definition: tree.h:581
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct _xmlNode * next
Definition: tree.h:558
struct _xmlNode * prev
Definition: tree.h:559

Referenced by xsltEvalGlobalVariable(), and xsltReleaseLocalRVTs().

◆ xsltRegisterTmpRVT()

int xsltRegisterTmpRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

xsltRegisterTmpRVT: @ctxt: an XSLT transformation context @RVT: a result value tree (Result Tree Fragment)

Registers the result value tree (XSLT 1.0 term: Result Tree Fragment) in the garbage collector. The fragment will be freed at the exit of the currently instantiated xsl:template. Obsolete; this function might produce massive memory overhead, since the fragment is only freed when the current xsl:template exits. Use xsltRegisterLocalRVT() instead.

Returns 0 in case of success and -1 in case of API or internal errors.

Definition at line 99 of file variables.c.

100 {
101  if ((ctxt == NULL) || (RVT == NULL))
102  return(-1);
103 
104  RVT->prev = NULL;
105  RVT->psvi = XSLT_RVT_LOCAL;
106 
107  /*
108  * We'll restrict the lifetime of user-created fragments
109  * insinde an xsl:variable and xsl:param to the lifetime of the
110  * var/param itself.
111  */
112  if (ctxt->contextVariable != NULL) {
113  RVT->next = (xmlNodePtr) XSLT_TCTXT_VARIABLE(ctxt)->fragment;
114  XSLT_TCTXT_VARIABLE(ctxt)->fragment = RVT;
115  return(0);
116  }
117 
118  RVT->next = (xmlNodePtr) ctxt->tmpRVT;
119  if (ctxt->tmpRVT != NULL)
120  ctxt->tmpRVT->prev = (xmlNodePtr) RVT;
121  ctxt->tmpRVT = RVT;
122  return(0);
123 }
#define XSLT_RVT_LOCAL
Definition: variables.h:46
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
void * psvi
Definition: tree.h:581
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define XSLT_TCTXT_VARIABLE(c)
Definition: variables.c:27
struct _xmlNode * next
Definition: tree.h:558
struct _xmlNode * prev
Definition: tree.h:559

◆ xsltRegisterVariable()

static int xsltRegisterVariable ( xsltTransformContextPtr  ctxt,
xsltStylePreCompPtr  castedComp,
xmlNodePtr  tree,
int  isParam 
)
static

xsltRegisterVariable: @ctxt: the XSLT transformation context @comp: the compiled XSLT-variable (or param) instruction @tree: the tree if select is NULL @isParam: indicates if this is a parameter

Computes and registers a new variable.

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

Definition at line 1810 of file variables.c.

1813 {
1814 #ifdef XSLT_REFACTORED
1815  xsltStyleBasicItemVariablePtr comp =
1816  (xsltStyleBasicItemVariablePtr) castedComp;
1817 #else
1818  xsltStylePreCompPtr comp = castedComp;
1819  int present;
1820 #endif
1822 
1823 #ifdef XSLT_REFACTORED
1824  /*
1825  * REFACTORED NOTE: Redefinitions of vars/params are checked
1826  * at compilation time in the refactored code.
1827  * xsl:with-param parameters are checked in xsltApplyXSLTTemplate().
1828  */
1829 #else
1830  present = xsltCheckStackElem(ctxt, comp->name, comp->ns);
1831  if (isParam == 0) {
1832  if ((present != 0) && (present != 3)) {
1833  /* TODO: report QName. */
1834  xsltTransformError(ctxt, NULL, comp->inst,
1835  "XSLT-variable: Redefinition of variable '%s'.\n", comp->name);
1836  return(0);
1837  }
1838  } else if (present != 0) {
1839  if ((present == 1) || (present == 2)) {
1840  /* TODO: report QName. */
1841  xsltTransformError(ctxt, NULL, comp->inst,
1842  "XSLT-param: Redefinition of parameter '%s'.\n", comp->name);
1843  return(0);
1844  }
1845 #ifdef WITH_XSLT_DEBUG_VARIABLE
1847  "param %s defined by caller\n", comp->name));
1848 #endif
1849  return(0);
1850  }
1851 #endif /* else of XSLT_REFACTORED */
1852 
1854  xsltAddStackElem(ctxt, variable);
1855  return(0);
1856 }
const xmlChar * ns
static int xsltCheckStackElem(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI)
Definition: variables.c:701
smooth NULL
Definition: ftsmooth.c:416
GLenum GLenum variable
Definition: glext.h:9031
void * xsltGenericDebugContext
Definition: xsltutils.c:549
xmlGenericErrorFunc xsltGenericDebug
Definition: xsltutils.c:548
static int xsltAddStackElem(xsltTransformContextPtr ctxt, xsltStackElemPtr elem)
Definition: variables.c:736
#define XSLT_TRACE(ctxt, code, call)
Definition: xsltutils.h:128
static xsltStackElemPtr xsltBuildVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr castedComp, xmlNodePtr tree)
Definition: variables.c:1763
const xmlChar * name
void xsltTransformError(xsltTransformContextPtr ctxt, xsltStylesheetPtr style, xmlNodePtr node, const char *msg,...)
Definition: xsltutils.c:678

Referenced by xsltParseStylesheetParam(), and xsltParseStylesheetVariable().

◆ xsltReleaseRVT()

void xsltReleaseRVT ( xsltTransformContextPtr  ctxt,
xmlDocPtr  RVT 
)

xsltReleaseRVT: @ctxt: an XSLT transformation context @RVT: a result value tree (Result Tree Fragment)

Either frees the RVT (which is an xmlDoc) or stores it in the context's cache for later reuse.

Definition at line 328 of file variables.c.

329 {
330  if (RVT == NULL)
331  return;
332 
333  if (ctxt && (ctxt->cache->nbRVT < 40)) {
334  /*
335  * Store the Result Tree Fragment.
336  * Free the document info.
337  */
338  if (RVT->_private != NULL) {
340  xmlFree(RVT->_private);
341  RVT->_private = NULL;
342  }
343  /*
344  * Clear the document tree.
345  * REVISIT TODO: Do we expect ID/IDREF tables to be existent?
346  */
347  if (RVT->children != NULL) {
349  RVT->children = NULL;
350  RVT->last = NULL;
351  }
352  if (RVT->ids != NULL) {
354  RVT->ids = NULL;
355  }
356  if (RVT->refs != NULL) {
358  RVT->refs = NULL;
359  }
360 
361  /*
362  * Reset the ownership information.
363  */
364  RVT->psvi = NULL;
365 
366  RVT->next = (xmlNodePtr) ctxt->cache->RVT;
367  ctxt->cache->RVT = RVT;
368 
369  ctxt->cache->nbRVT++;
370 
371 #ifdef XSLT_DEBUG_PROFILE_CACHE
372  ctxt->cache->dbgCachedRVTs++;
373 #endif
374  return;
375  }
376  /*
377  * Free it.
378  */
379  if (RVT->_private != NULL) {
381  xmlFree(RVT->_private);
382  }
383  xmlFreeDoc(RVT);
384 }
xsltTransformCachePtr cache
XMLPUBFUN void XMLCALL xmlFreeIDTable(xmlIDTablePtr table)
Definition: valid.c:2729
XMLPUBFUN void XMLCALL xmlFreeNodeList(xmlNodePtr cur)
void * refs
Definition: tree.h:576
smooth NULL
Definition: ftsmooth.c:416
void * ids
Definition: tree.h:575
xmlNode * xmlNodePtr
Definition: tree.h:488
void * psvi
Definition: tree.h:581
void * _private
Definition: tree.h:552
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
struct _xmlNode * next
Definition: tree.h:558
void xsltFreeDocumentKeys(xsltDocumentPtr idoc)
Definition: keys.c:925
struct _xmlNode * last
Definition: tree.h:556
struct _xmlNode * children
Definition: tree.h:555
XMLPUBFUN void XMLCALL xmlFreeRefTable(xmlRefTablePtr table)
Definition: valid.c:3071

Referenced by xsltApplyXSLTTemplate(), xsltFreeStackElem(), and xsltReleaseLocalRVTs().

◆ xsltStackLookup()

static xsltStackElemPtr xsltStackLookup ( xsltTransformContextPtr  ctxt,
const xmlChar name,
const xmlChar nameURI 
)
static

Definition at line 632 of file variables.c.

633  {
634  int i;
635  xsltStackElemPtr cur;
636 
637  if ((ctxt == NULL) || (name == NULL) || (ctxt->varsNr == 0))
638  return(NULL);
639 
640  /*
641  * Do the lookup from the top of the stack, but
642  * don't use params being computed in a call-param
643  * First lookup expects the variable name and URI to
644  * come from the disctionnary and hence pointer comparison.
645  */
646  for (i = ctxt->varsNr; i > ctxt->varsBase; i--) {
647  cur = ctxt->varsTab[i-1];
648  while (cur != NULL) {
649  if ((cur->name == name) && (cur->nameURI == nameURI)) {
650 #if 0
651  stack_addr++;
652 #endif
653  return(cur);
654  }
655  cur = cur->next;
656  }
657  }
658 
659  /*
660  * Redo the lookup with interned string compares
661  * to avoid string compares.
662  */
663  name = xmlDictLookup(ctxt->dict, name, -1);
664  if (nameURI != NULL)
665  nameURI = xmlDictLookup(ctxt->dict, nameURI, -1);
666 
667  for (i = ctxt->varsNr; i > ctxt->varsBase; i--) {
668  cur = ctxt->varsTab[i-1];
669  while (cur != NULL) {
670  if ((cur->name == name) && (cur->nameURI == nameURI)) {
671 #if 0
672  stack_cmp++;
673 #endif
674  return(cur);
675  }
676  cur = cur->next;
677  }
678  }
679 
680  return(NULL);
681 }
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
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
const xmlChar * nameURI
xsltStackElemPtr * varsTab
Definition: name.c:38
const xmlChar * name

Referenced by xsltCheckStackElem(), and xsltVariableLookup().

◆ xsltVariableLookup()

xmlXPathObjectPtr 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()

xmlXPathObjectPtr 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

Variable Documentation

◆ xsltComputingGlobalVarMarker

const xmlChar* xsltComputingGlobalVarMarker
static
Initial value:
=
(const xmlChar *) " var/param being computed"
unsigned char xmlChar
Definition: xmlstring.h:28

Definition at line 22 of file variables.c.

Referenced by xsltEvalGlobalVariable(), and xsltGlobalVariableLookup().