mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-11-08 11:02:18 +03:00
trying to incorporate comments from bug #59220 Daniel
* win32/dsp/libxslt.def libxslt/variables.[ch]: trying to incorporate comments from bug #59220 Daniel
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
Wed Sep 12 17:00:53 CEST 2001 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* win32/dsp/libxslt.def libxslt/variables.[ch]: trying to
|
||||||
|
incorporate comments from bug #59220
|
||||||
|
|
||||||
Wed Sep 12 05:51:32 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
|
Wed Sep 12 05:51:32 CEST 2001 Thomas Broyer <tbroyer@ltgt.net>
|
||||||
|
|
||||||
* configure.in libexslt/date.c libexslt/Makefile.am
|
* configure.in libexslt/date.c libexslt/Makefile.am
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
/* Define if you have the gettimeofday function. */
|
/* Define if you have the gettimeofday function. */
|
||||||
#undef HAVE_GETTIMEOFDAY
|
#undef HAVE_GETTIMEOFDAY
|
||||||
|
|
||||||
|
/* Define if you have the gmtime function. */
|
||||||
|
#undef HAVE_GMTIME
|
||||||
|
|
||||||
/* Define if you have the localtime function. */
|
/* Define if you have the localtime function. */
|
||||||
#undef HAVE_LOCALTIME
|
#undef HAVE_LOCALTIME
|
||||||
|
|
||||||
@@ -30,6 +33,9 @@
|
|||||||
/* Define if you have the stat function. */
|
/* Define if you have the stat function. */
|
||||||
#undef HAVE_STAT
|
#undef HAVE_STAT
|
||||||
|
|
||||||
|
/* Define if you have the time function. */
|
||||||
|
#undef HAVE_TIME
|
||||||
|
|
||||||
/* Define if you have the <ansidecl.h> header file. */
|
/* Define if you have the <ansidecl.h> header file. */
|
||||||
#undef HAVE_ANSIDECL_H
|
#undef HAVE_ANSIDECL_H
|
||||||
|
|
||||||
|
|||||||
@@ -657,40 +657,64 @@ xsltRegisterGlobalVariable(xsltStylesheetPtr style, const xmlChar *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xsltEvalUserParams:
|
* xsltProcessUserParamInternal
|
||||||
* @ctxt: the XSLT transformation context
|
|
||||||
* @params: a NULL terminated arry of parameters names/values tuples
|
|
||||||
*
|
*
|
||||||
* Evaluate the global variables of a stylesheet. This needs to be
|
* @ctxt: the XSLT transformation context
|
||||||
* done on parsed stylesheets before starting to apply transformations
|
* @name: a null terminated parameter name
|
||||||
|
* @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
|
* Returns 0 in case of success, -1 in case of error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static
|
||||||
int
|
int
|
||||||
xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
xsltProcessUserParamInternal(xsltTransformContextPtr ctxt,
|
||||||
|
const xmlChar * name,
|
||||||
|
const xmlChar * value,
|
||||||
|
int eval) {
|
||||||
|
|
||||||
xsltStylesheetPtr style;
|
xsltStylesheetPtr style;
|
||||||
int indx = 0;
|
xmlChar *ncname;
|
||||||
const xmlChar *name;
|
xmlChar *prefix;
|
||||||
const xmlChar *value;
|
|
||||||
xmlChar *ncname, *prefix;
|
|
||||||
const xmlChar *href;
|
const xmlChar *href;
|
||||||
xmlXPathCompExprPtr comp;
|
xmlXPathCompExprPtr comp;
|
||||||
xmlXPathObjectPtr result;
|
xmlXPathObjectPtr result;
|
||||||
int oldProximityPosition, oldContextSize;
|
int oldProximityPosition;
|
||||||
|
int oldContextSize;
|
||||||
int oldNsNr;
|
int oldNsNr;
|
||||||
xmlNsPtr *oldNamespaces;
|
xmlNsPtr *oldNamespaces;
|
||||||
|
xsltStackElemPtr elem;
|
||||||
|
int res;
|
||||||
|
|
||||||
if (ctxt == NULL)
|
if (ctxt == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
if (params == NULL)
|
if (name == NULL)
|
||||||
|
return(0);
|
||||||
|
if (value == NULL)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
style = ctxt->style;
|
style = ctxt->style;
|
||||||
while (params[indx] != NULL) {
|
|
||||||
name = (const xmlChar *)params[indx++];
|
|
||||||
value = (const xmlChar *)params[indx++];
|
|
||||||
if ((name == NULL) || (value == NULL))
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef WITH_XSLT_DEBUG_VARIABLE
|
#ifdef WITH_XSLT_DEBUG_VARIABLE
|
||||||
xsltGenericDebug(xsltGenericDebugContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
@@ -700,6 +724,7 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
|||||||
/*
|
/*
|
||||||
* Name lookup
|
* Name lookup
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ncname = xmlSplitQName2(name, &prefix);
|
ncname = xmlSplitQName2(name, &prefix);
|
||||||
href = NULL;
|
href = NULL;
|
||||||
if (ncname != NULL) {
|
if (ncname != NULL) {
|
||||||
@@ -727,9 +752,11 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do the evaluation
|
* Do the evaluation if @eval is non-zero.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result = NULL;
|
result = NULL;
|
||||||
|
if (eval != 0) {
|
||||||
comp = xmlXPathCompile(value);
|
comp = xmlXPathCompile(value);
|
||||||
if (comp != NULL) {
|
if (comp != NULL) {
|
||||||
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
|
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
|
||||||
@@ -740,6 +767,7 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
|||||||
* There is really no in scope namespace for parameters on the
|
* There is really no in scope namespace for parameters on the
|
||||||
* command line.
|
* command line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
oldNsNr = ctxt->xpathCtxt->nsNr;
|
oldNsNr = ctxt->xpathCtxt->nsNr;
|
||||||
oldNamespaces = ctxt->xpathCtxt->namespaces;
|
oldNamespaces = ctxt->xpathCtxt->namespaces;
|
||||||
ctxt->xpathCtxt->namespaces = NULL;
|
ctxt->xpathCtxt->namespaces = NULL;
|
||||||
@@ -756,9 +784,21 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
|||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericError(xsltGenericErrorContext,
|
||||||
"Evaluating user parameter %s failed\n", name);
|
"Evaluating user parameter %s failed\n", name);
|
||||||
ctxt->state = XSLT_STATE_STOPPED;
|
ctxt->state = XSLT_STATE_STOPPED;
|
||||||
} else {
|
xmlFree(ncname);
|
||||||
xsltStackElemPtr elem;
|
return(-1);
|
||||||
int res;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If @eval is 0 then @value is to be taken literally and result is NULL
|
||||||
|
*
|
||||||
|
* If @eval is not 0, then @value is an XPath expression and has been
|
||||||
|
* successfully evaluated and result contains the resulting value and
|
||||||
|
* is not NULL.
|
||||||
|
*
|
||||||
|
* Now create an xsltStackElemPtr for insertion into the context's
|
||||||
|
* global variable/parameter hash table.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef WITH_XSLT_DEBUG_VARIABLE
|
#ifdef WITH_XSLT_DEBUG_VARIABLE
|
||||||
#ifdef LIBXML_DEBUG_ENABLED
|
#ifdef LIBXML_DEBUG_ENABLED
|
||||||
@@ -780,27 +820,140 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
|||||||
elem->nameURI = xmlStrdup(href);
|
elem->nameURI = xmlStrdup(href);
|
||||||
elem->tree = NULL;
|
elem->tree = NULL;
|
||||||
elem->computed = 1;
|
elem->computed = 1;
|
||||||
|
if (eval == 0) {
|
||||||
|
elem->value = xmlXPathNewString(value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
elem->value = result;
|
elem->value = result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global parameters are stored in the XPath context
|
* Global parameters are stored in the XPath context variables pool.
|
||||||
* variables pool.
|
|
||||||
*/
|
*/
|
||||||
res = xmlHashAddEntry2(ctxt->globalVars,
|
|
||||||
ncname, href, elem);
|
res = xmlHashAddEntry2(ctxt->globalVars, ncname, href, elem);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
xsltFreeStackElem(elem);
|
xsltFreeStackElem(elem);
|
||||||
xsltPrintErrorContext(ctxt, style, NULL);
|
xsltPrintErrorContext(ctxt, style, NULL);
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericError(xsltGenericErrorContext,
|
||||||
"Global parameter %s already defined\n", ncname);
|
"Global parameter %s already defined\n", ncname);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
xmlFree(ncname);
|
xmlFree(ncname);
|
||||||
}
|
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
||||||
|
int indx = 0;
|
||||||
|
const xmlChar *name;
|
||||||
|
const xmlChar *value;
|
||||||
|
|
||||||
|
if (params == NULL)
|
||||||
|
return(0);
|
||||||
|
while (params[indx] != NULL) {
|
||||||
|
name = (const xmlChar *) params[indx++];
|
||||||
|
value = (const xmlChar *) params[indx++];
|
||||||
|
if (xsltEvalOneUserParam(ctxt, name, value) != 0)
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
xsltQuoteUserParams(xsltTransformContextPtr ctxt, const char **params) {
|
||||||
|
int indx = 0;
|
||||||
|
const xmlChar *name;
|
||||||
|
const xmlChar *value;
|
||||||
|
|
||||||
|
if (params == NULL)
|
||||||
|
return(0);
|
||||||
|
while (params[indx] != NULL) {
|
||||||
|
name = (const xmlChar *) params[indx++];
|
||||||
|
value = (const xmlChar *) params[indx++];
|
||||||
|
if (xsltQuoteOneUserParam(ctxt, name, value) != 0)
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xsltEvalOneUserParam:
|
||||||
|
*
|
||||||
|
* @ctxt: the XSLT transformation context
|
||||||
|
* @name: a null terminated string giving the name of the parameter
|
||||||
|
* @value a null terminated string giving the XPath expression to be evaluated
|
||||||
|
*
|
||||||
|
* This is normally called from xsltEvalUserParams to process a single
|
||||||
|
* parameter from a list of parameters. The @value is evaluated as an
|
||||||
|
* XPath expression and the result is stored in the context's global
|
||||||
|
* variable/parameter hash table.
|
||||||
|
*
|
||||||
|
* To have a parameter treated literally (not as an XPath expression)
|
||||||
|
* use xsltQuoteUserParams (or xsltQuoteOneUserParam). For more
|
||||||
|
* details see description of xsltProcessOneUserParamInternal.
|
||||||
|
*
|
||||||
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
xsltEvalOneUserParam(xsltTransformContextPtr ctxt,
|
||||||
|
const xmlChar * name,
|
||||||
|
const xmlChar * value) {
|
||||||
|
return xsltProcessUserParamInternal(ctxt, name, value,
|
||||||
|
1 /* xpath eval ? */);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xsltQuoteOneUserParam:
|
||||||
|
*
|
||||||
|
* @ctxt: the XSLT transformation context
|
||||||
|
* @name: a null terminated string giving the name of the parameter
|
||||||
|
* @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
|
||||||
|
xsltQuoteOneUserParam(xsltTransformContextPtr ctxt,
|
||||||
|
const xmlChar * name,
|
||||||
|
const xmlChar * value) {
|
||||||
|
return xsltProcessUserParamInternal(ctxt, name, value,
|
||||||
|
0 /* xpath eval ? */);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xsltBuildVariable:
|
* xsltBuildVariable:
|
||||||
* @ctxt: the XSLT transformation context
|
* @ctxt: the XSLT transformation context
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ extern "C" {
|
|||||||
int xsltEvalGlobalVariables (xsltTransformContextPtr ctxt);
|
int xsltEvalGlobalVariables (xsltTransformContextPtr ctxt);
|
||||||
int xsltEvalUserParams (xsltTransformContextPtr ctxt,
|
int xsltEvalUserParams (xsltTransformContextPtr ctxt,
|
||||||
const char **params);
|
const char **params);
|
||||||
|
int xsltQuoteUserParams (xsltTransformContextPtr ctxt,
|
||||||
|
const char **params);
|
||||||
|
int xsltEvalOneUserParam (xsltTransformContextPtr ctxt,
|
||||||
|
const xmlChar * name,
|
||||||
|
const xmlChar * value);
|
||||||
|
int xsltQuoteOneUserParam (xsltTransformContextPtr ctxt,
|
||||||
|
const xmlChar * name,
|
||||||
|
const xmlChar * value);
|
||||||
|
|
||||||
void xsltParseGlobalVariable (xsltStylesheetPtr style,
|
void xsltParseGlobalVariable (xsltStylesheetPtr style,
|
||||||
xmlNodePtr cur);
|
xmlNodePtr cur);
|
||||||
void xsltParseGlobalParam (xsltStylesheetPtr style,
|
void xsltParseGlobalParam (xsltStylesheetPtr style,
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ EXPORTS
|
|||||||
|
|
||||||
xsltEvalGlobalVariables
|
xsltEvalGlobalVariables
|
||||||
xsltEvalUserParams
|
xsltEvalUserParams
|
||||||
|
xsltQuoteUserParams
|
||||||
|
xsltEvalOneUserParam
|
||||||
|
xsltQuoteOneUserParam
|
||||||
xsltParseGlobalVariable
|
xsltParseGlobalVariable
|
||||||
xsltParseGlobalParam
|
xsltParseGlobalParam
|
||||||
xsltParseStylesheetVariable
|
xsltParseStylesheetVariable
|
||||||
|
|||||||
Reference in New Issue
Block a user